The following steps provide a way to connect the sensor to Home Assistance.
-
install Home Assistant
-
install the Mosquitto MQTT broker add-on: Settings > Add-ons > Add-on store > Mosquitto broker
-
install the File editor add-on: Settings > Add-ons > Add-on store > File editor
-
install the MQTT integration: Settings > Devices & services > Add integration > MQTT
-
edit the
/homeassistant/configuration.yaml
file using the File editor add-on with the following sensors:mqtt: sensor: - name: Leaving room temperature state_topic: "home/sensor/leaving-room/environment" device_class: "temperature" unit_of_measurement: "°C" value_template: "{{value_json.temperature | round(1)}}" - name: Leaving room pressure state_topic: "home/sensor/leaving-room/environment" device_class: "pressure" unit_of_measurement: "hpa" value_template: "{{value_json.pressure | round(1)}}" - name: Leaving room humidity state_topic: "home/sensor/leaving-room/environment" device_class: "humidity" unit_of_measurement: "%" value_template: "{{value_json.humidity | round(1)}}"
-
reload the Yaml configuration: Developer tools > All yaml configuration
-
create a dedicated user for the sensor: Settings > People > Add person. Make sure the user can login with credentials, then use the credentials when you will be flashing the chip.
Now that Home Assistant is correctly setup, update the cfg.toml
in the root
of this repository with the corresponding MQTT values, e.g.:
[esp32_home_sensor]
wifi_ssid = "wifi-ssid"
wifi_psk = "wifi-password"
hostname = "esp32-leaving-room"
mqtt_hostname = "homeassistant"
mqtt_port = 1883
mqtt_username = "esp32"
mqtt_password = "esp32"
mqtt_topic = "home/sensor/leaving-room/environment"
location = "leaving-room"
Flash the chip:
. $HOME/export-esp.sh
cargo espflash flash --release --features json