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

Fix bug when trying to read states of MQTT light when it is off. #19193

Closed
wants to merge 1 commit into from
Closed

Fix bug when trying to read states of MQTT light when it is off. #19193

wants to merge 1 commit into from

Conversation

pszafer
Copy link
Contributor

@pszafer pszafer commented Dec 11, 2018

Description:

This week I started to using RGB MQTT light and found a bug in mqtt light implementation.
When I call to turn off light, it tried to read rgb state when light is already off.
It occurs if state topic and brightness/color topic etc. are the same.

Exception thrown:

2018-12-11 15:15:07 ERROR (MainThread) [homeassistant.helpers.template] Error parsing value: 'dict object' has no attribute 'Color' (value: {"POWER":"OFF"}, template: {{value_json.Color.split(',')[0:3]|join(',')}})                                                         
2018-12-11 15:15:07 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback MQTT._mqtt_handle_message(<paho.mqtt.cl...x7fb43fb67dd8>)                                                                                                                   
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/events.py", line 145, in _run
    self._callback(*self._args)
  File "/root/homeassistant/lib/python3.6/site-packages/homeassistant/components/mqtt/__init__.py", line 775, in _mqtt_handle_message
    subscription.callback, msg.topic, payload, msg.qos)
  File "/root/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 327, in async_run_job
    target(*args)
  File "/root/homeassistant/lib/python3.6/site-packages/homeassistant/components/light/mqtt.py", line 331, in rgb_received
    rgb = [int(val) for val in payload.split(',')]
  File "/root/homeassistant/lib/python3.6/site-packages/homeassistant/components/light/mqtt.py", line 331, in <listcomp>
    rgb = [int(val) for val in payload.split(',')]
ValueError: invalid literal for int() with base 10: '{"POWER":"OFF"}'

**Related issue (if applicable): couldn't find any.

Example entry for configuration.yaml (if applicable):

Config which threw error:

- platform: mqtt
  name: "LED light"
  command_topic: "cmnd/led/POWER"
  state_topic: "stat/led/RESULT"
  state_value_template: "{{value_json.POWER}}"
  availability_topic: "tele/led/LWT"
  brightness_command_topic: "cmnd/led/Dimmer"
  brightness_state_topic: "stat/led/RESULT"
  brightness_scale: 100
  on_command_type: "brightness"
  brightness_value_template: "{{value_json.Dimmer}}"
  color_temp_command_topic: "cmnd/led/CT"
  color_temp_state_topic: "stat/led/RESULT"
  color_temp_value_template: "{{value_json.CT}}"
  rgb_command_topic: "cmnd/led/Color2"
  rgb_state_topic: "stat/led/RESULT"
  rgb_value_template: "{{value_json.Color.split(',')[0:3]|join(',')}}"
  effect_command_topic: "cmnd/led/Scheme"
  effect_state_topic: "stat/led/RESULT"
  effect_value_template: "{{value_json.Scheme}}"
  effect_list:
    - 0
    - 1
    - 2
    - 3
    - 4
  payload_on: "ON"
  payload_off: "OFF"
  payload_available: "Online"
  payload_not_available: "Offline"

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • Tests have been changed to verify that the new code works.

@emontnemery
Copy link
Contributor

emontnemery commented Dec 11, 2018

This is not a bug in Hass, and has been fixed in Tasmota.

However, Tasmota documentation has not been updated yet.

Please open an issue on Tasmota and ping me.

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

Successfully merging this pull request may close these issues.

None yet

3 participants