Proof of concept for a bigger idea.
The Arduino’s code is completely independent from Home Assistant, it just posts attitude changes in the Y axis to one MQTT topic, so it can be used for anything.
In addition to the Arduino:
- MQTT broker. For exploring ideas, I am just running a simple installation of Mosquitto on a Pi.
- Home Assistant with the MQTT integration installed and configured.
- A Home Assistant MQTT switch tied to the topic where the Arduino sends the messages. (/ha_switch.yaml)
- A couple of automations in HA: one for increasing the brightness and one for decreasing the brightness of the light (/arduino_ha_automation_test.yaml).
The brightness of the light increases when you rotate the Arduino upwards and decreases when it is rotated downwards (over its X axis), but to activate this the Arduino must be turned at least 80 degrees left over the Y axis and then to lock the reading it must be turned “right” at least 80 degrees (this makes sense if the Arduino boots horizontal like the board sitting on a table and the antenna pointing away from you).