Skip to content

HASS Integration

root edited this page Sep 13, 2019 · 1 revision

Home Assistant Integration

These lights can easily 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

Additionally there is developmental support for HA MQTT Discovery. This is done through the php page mqttdiscovery.php 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

Trigger on HASS Startup

One option to trigger discovery on HASS startup is through the use of a shell command and a startup automation. For example

Shell Command

shell_command:
  ha_on: "curl -k 'https://lighting.local/mqttdiscovery.php' > /dev/null"

Automation

- alias: Startup Discovery Trigger
  trigger:
    platform: homeassistant
    event: start
  action:
    - service: shell_command.ha_on