Home Assistant -  MQTT

26 August, 2018

21:36

 

 

RFLink-ESP, MQTT-mode

In the MQTT mode, RFLink-ESP communicates with an Home Automation program fully through the MQTT broker. In that case the serial port is used for debugging.

If an RF sequence is detected as valid by RFLink-ESP,  it sends the information through the MQTT-broker:

If the Home Automation program sends a command through the MQTT-broker, RFLink checks if the message is valid, then it performs the action and sends a response back to the Home Automation program.

 

If RFLink-ESP is set to MQTT-mode, you can watch the serial line to see what the topic and payloads from the different switches are. Here the serial ouput is shown when 4 different switches are pressed:

 

 

From here it's easy to implement the Home Assistant counterpart, a few examples :

Button

Configuration.yaml

Home Assistant

To activate the broker component

 

 

A simple Lamp Switch,

Based on the second button in the above list

 

https://www.home-assistant.io/components/switch.mqtt/

 

 

 

 

A Blind Cover,

Based on the last button in the above list

 

https://www.home-assistant.io/components/cover.mqtt/

 

 

 

If we look at the communication on the MQTT bus, we can see the following traffic:

 

 

Line 1:  Home Assistant commands to turn the light on

Line 2:  RFLink-ESP acknowledges that the command is valid and executed (this will update the state of the icons in Home Assitant)

Line 3:  Home Assistant commands to turn the light off

Line 4:  RFLink-ESP acknowledges that the command is valid and executed

Line 5:  Another remote control has turned the light on, this is the message to Home Assistant to change the state

Line 6:  Another remote control has turned the light off

 

 

 

Sensors via MQTT

 

MQTT berichten worden goed ontvangen,

JSON parts kunnen worden onderscheiden

 

 

MQTT

Configuration.yaml

HomeAssistant

 

 

huis/verdieping0/kamer1/CO3

{ " CO2" :222, "CO3" : 3234, "CO4":111}

 

  - platform: mqtt

    state_topic: "huis/verdieping0/kamer1/CO3"

    name: "CO3b"

    sensors:

      CO3:

        unit_of_measurement: 'ppm'

#        value_template: "{{ value_json['CO3'] }}"

    value_template: >

        {

            "CO3": {{ value_json.CO3 }}

        }

 

 

 

 

  - platform: mqtt

    state_topic: "huis/verdieping0/kamer1/CO3"

    name: "CO3c"

    sensors:

      CO4:

        unit_of_measurement: '%'

#        value_template: "{{ value_json['CO4'] }}"

    value_template: >

        {

            "CO4": {{ value_json.CO4 }}

        }

 

 

 

 

Template:

https://www.home-assistant.io/docs/configuration/templating/

https://www.home-assistant.io/docs/mqtt/processing_json/

 

 

 

Screen clipping taken: 28-Aug-18, 21:43

 

 

 

 

Screen clipping taken: 28-Aug-18, 21:43

 

 

 

 

Created with Microsoft Office OneNote 2007
One place for all your notes and information