Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dimmer item on_off_topic not working per config.yaml template #3

Closed
bfranske opened this issue Dec 7, 2017 · 1 comment
Closed

Comments

@bfranske
Copy link

bfranske commented Dec 7, 2017

Switch items can be controlled like mosquitto_pub -t "insteon/17.4d.c8/set" -m 'on' but the same syntax does not work for dimmer items e.g. mosquitto_pub -t "insteon/40.b2.b9/set" -m 'on' returns:

2017-12-07 00:33:57 INFO Dimmer: Dimmer message insteon/40.b2.b9/set b'on'
2017-12-07 00:33:57 ERROR Base: MQTT failed to render template level_payload: { "cmd" : "{{json.state.lower()}}",
  "level" : {% if json.brightness is defined %}
               {{json.brightness}}
            {% else %}
               255
            {% endif %} }
 with '{'value': 'on', 'json': None}'
Traceback (most recent call last):
  File "/opt/insteon-mqtt/lib/python3.5/site-packages/insteon_mqtt/mqtt/Base.py", line 73, in render
    return templ.render(data)
  File "/opt/insteon-mqtt/lib/python3.5/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/opt/insteon-mqtt/lib/python3.5/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/opt/insteon-mqtt/lib/python3.5/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
  File "/opt/insteon-mqtt/lib/python3.5/site-packages/jinja2/environment.py", line 430, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'None' has no attribute 'state'

Even though the Dimmer template section of the config.yaml file has:

on_off_topic: 'insteon/{{address}}/set'
on_off_payload: '{ "cmd" : "{{value.lower()}}" }'

It seems this template is not being applied and the level payload template is and it is looking for mosquitto_pub -t "insteon/40.b2.b9/set" -m '{ "state" : "off" }' which does work.

@TD22057 TD22057 closed this as completed in 7cff446 Dec 7, 2017
@TD22057
Copy link
Owner

TD22057 commented Dec 7, 2017

Thanks for finding this. Dimmer had the on/off command signal connected to the wrong callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants