I’m trying to implement an RGB LED switch controller over MQTT. I have followed the example found at https://home-assistant.io/components/light.mqtt/ to get it integrated with HA.
The configuration.yaml section for the switch is:
# Example configuration.yml entry
light 1:
platform: mqtt
name: "Test Light RGB"
state_topic: "office/1stfl/light/status"
command_topic: "office/1stfl/light/switch"
# brightness_state_topic: "office/1stfl/brightness/status"
# brightness_command_topic: "office/1stfl/brightness/set"
rgb_state_topic: "office/1stfl/rgb/status"
rgb_command_topic: "office/1stfl/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
The code works as expected, but I keep getting the following errors logged to home-assistan.log every few seconds:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/template.py", line 35, in render_with_possible_json_value
return render(hass, template, variables)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/template.py", line 61, in render
raise TemplateError(err)
homeassistant.exceptions.TemplateError: UndefinedError: 'value_json' is undefined
16-05-06 19:06:25 homeassistant.core: Bus:Handling <Event mqtt_message_received[L]: payload=ON, qos=0, topic=office/1stfl/light/status>
16-05-06 19:06:25 homeassistant.helpers.template: Error parsing value
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/template.py", line 59, in render
}).render(kwargs).strip()
File "/usr/local/lib/python3.4/dist-packages/jinja2/environment.py", line 989, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/local/lib/python3.4/dist-packages/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.4/dist-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "<template>", line 1, in top-level template code
File "/usr/local/lib/python3.4/dist-packages/jinja2/sandbox.py", line 329, in getattr
value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'value_json' is undefined
The error is certainly related to the light 1 switch, but I’m just not sure what’s going wrong. I am running 0.18.2. Do anyone have any good suggestions to what might be causing this?
Regards,
Thomas