Skip to content

HASS Integration

Paul edited this page Feb 16, 2021 · 5 revisions

Home Assistant Integration

The Manual Way

These lights can be integrated into Home Assistant with YAML. For example.

  - platform: mqtt
    name: "Back Entry"
    state_topic: "light/RearEntrance/BackDoor/216773570733040739/status"
    command_topic: "light/RearEntrance/BackDoor/216773570733040739/switch"
    brightness_state_topic: "light/RearEntrance/BackDoor/216773570733040739/brightness"
    brightness_command_topic: "light/RearEntrance/BackDoor/216773570733040739/brightness/set"
    availability_topic: "light/RearEntrance/BackDoor/216773570733040739/LWT"
    brightness_scale: 100
    qos: 0
    payload_on: "1"
    payload_off: "0"
    optimistic: false

The Easy Way

Home Assistant MQTT Discovery is supported. This is done through the PHP page mqttdiscovery.php

Trigger discovery on Home Assistant Startup

The subscription script is listening for an MQTT Birth Message from Home Assistant. By default, this is a payload of online sent to the topic homeassistant/status. The topic can be changed by editing the $HASSOnline variable in config.inc.php

Backup Trigger

As HA doesn't retain discovered devices on restart I have chosen to also run this page as a cron job every 5 minutes ie.

*/5 * * * * lynx -dump https://lighting.local/mqttdiscovery.php