Hi,
I’m trying to start with the HA, but still I’m not able to make the stuff working the way I want (and what I understood from the examples).
Installation environment is Windows 7 64bit and standalone mosquitto MQTT broker (I’ll dig more details if needed), the installation is fresh (3 days old) so I assume it’s up to date…
I’m trying to setup a lights and switches via the MQTT. System itself is running fine, I can see messages running out of HASS to MQTT broker and I can even see my messages showig in the event log in so I assume the connection between hass and mosquitto is fine and even the topics are defined fine.
The problem starts with defining a template for the payload. If I keep the template empty/commented in the yaml configuration and the payload contain just the value, it works.
switch test1:
platform: mqtt
name: "test switch without value"
state_topic: "home/test/switch2"
command_topic: "home/test/switch2/set"
payload_on: "ON"
payload_off: "OFF"
while sending this to my mosquitto, the state is changed fine
mosquitto_pub.exe -t home/test/switch2 -m "ON"
What I’m unable to make working is the example of the RGB light
# Example configuration.yml entry
light:
platform: mqtt
name: “Office Light RGB”
state_topic: “office/rgb1/light/status”
command_topic: “office/rgb1/light/switch”
brightness_state_topic: “office/rgb1/brightness/status”
brightness_command_topic: “office/rgb1/brightness/set”
rgb_state_topic: “office/rgb1/rgb/status”
rgb_command_topic: “office/rgb1/rgb/set”
state_value_template: “{{ value_json.state }}”
brightness_value_template: “{{ value_json.brightness }}”
rgb_value_template: “{{ value_json.rgb | join(’,’) }}”
qos: 0
payload_on: “ON”
payload_off: “OFF”
optimistic: false
Could you please guide me, how the payload should look like to fit the templates?
I expected it to be for example
- { state: ON }
- { brightness: 128 }
- { rgb: 10,20,30 }
but this just ends with parsing error in the event log of HASS.
If the templates from the MQTT light example is not correct for any reason, I would appreciate providing any working combination of json parsing template + the expected payload.
Thank you in advance!