home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.45k stars 30.69k forks source link

Tasmota integration fails to restore state from scenes #43872

Closed marknl closed 3 years ago

marknl commented 3 years ago

The problem

When setting a simple blue and red scene in HA, the light never changes to red as soon as it's been set to blue or the other way around. The light has been connected to HA with the Tasmota direct integration. The Light has been reset to factory defaults then WiFi and MQTT was configured. Everything else is dedault.

Environment

Problem-relevant scenes.yaml

- id: '1604592845429'
  name: blue scene
  entities:
    light.spot02:
      min_mireds: 153
      max_mireds: 500
      effect_list:
      - None
      - Wake up
      - Cycle up
      - Cycle down
      - Random
      brightness: 255
      effect: None
      friendly_name: Spot02
      supported_features: 183
      state: 'on'
- id: '1606949404250'
  name: red scene
  entities:
    light.spot02:
      min_mireds: 153
      max_mireds: 500
      effect_list:
      - None
      - Wake up
      - Cycle up
      - Cycle down
      - Random
      brightness: 255
      effect: None
      friendly_name: Spot02
      supported_features: 183
      state: 'on'

Additional information

When I look at the scenes in the scene.yaml I don't see any color information in the both scenes. I don't know what part is responsible for providing correct color information to be saved into the scene, but that seems to be missing.

probot-home-assistant[bot] commented 3 years ago

Hey there @emontnemery, mind taking a look at this issue as its been labeled with an integration (tasmota) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

emontnemery commented 3 years ago

@marknl Can you please paste the discovery message from the light, easiest way to get it is from command line:

mosquitto_sub -v -h <mqtt server> -t "tasmota/discovery/+/config"

Please also enable some additional log in HA and paste the log when changing the light to blue and red (not the non-working scenes, but from the UI):

logger:
  default: info
  logs:
    hatasmota: debug
    homeassistant.core: debug
    homeassistant.components.mqtt: debug
    homeassistant.components.tasmota: debug
marknl commented 3 years ago

I'm running Hass in a FreeNAS virtual machines (bhyve). I've tried to follow some documents on how to get shell access via ssh, but that doesn't seem to work. So I'll provide the MQTT console logs directly from the light bulb.

When I use a color picker to set the light to blue: Light console:

14:23:55 MQT: stat/tasmota_0DC328/RESULT = {"POWER":"ON"}
14:23:55 MQT: stat/tasmota_0DC328/POWER = ON
14:23:55 MQT: stat/tasmota_0DC328/RESULT = {"POWER":"ON","Dimmer":100,"Color":"0000FF0000","HSBColor":"240,100,100","White":0,"CT":153,"Channel":[0,0,100,0,0]}

HA logs:

2020-12-03 14:23:54 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=light, service=turn_on, service_data=entity_id=light.spot02, hs_color=[240, 100]>
2020-12-03 14:23:54 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=mqtt, service=publish, service_data=topic=cmnd/tasmota_0DC328/Backlog, payload=NoDelay;Fade 0;NoDelay;Power1 ON;NoDelay;Color2 0,0,255>
2020-12-03 14:23:54 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on cmnd/tasmota_0DC328/Backlog: 'NoDelay;Fade 0;NoDelay;Power1 ON;NoDelay;Color2 0,0,255', mid: 34
2020-12-03 14:23:55 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/tasmota_0DC328/RESULT: b'{"Fade":"OFF"}'
2020-12-03 14:23:55 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/tasmota_0DC328/RESULT: b'{"POWER":"ON"}'
2020-12-03 14:23:55 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/tasmota_0DC328/RESULT: b'{"POWER":"ON","Dimmer":100,"Color":"0000FF0000","HSBColor":"240,100,100","White":0,"CT":153,"Channel":[0,0,100,0,0]}'

When I use a color picker to set the light to red: Light console:

14:25:12 MQT: stat/tasmota_0DC328/RESULT = {"POWER":"ON"}
14:25:12 MQT: stat/tasmota_0DC328/POWER = ON
14:25:12 MQT: stat/tasmota_0DC328/RESULT = {"POWER":"ON","Dimmer":100,"Color":"FF00000000","HSBColor":"0,100,100","White":0,"CT":153,"Channel":[100,0,0,0,0]}

HA logs:

2020-12-03 14:25:11 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=light, service=turn_on, service_data=entity_id=light.spot02, hs_color=[360, 100]>
2020-12-03 14:25:11 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=mqtt, service=publish, service_data=topic=cmnd/tasmota_0DC328/Backlog, payload=NoDelay;Fade 0;NoDelay;Power1 ON;NoDelay;Color2 255,0,0>
2020-12-03 14:25:11 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on cmnd/tasmota_0DC328/Backlog: 'NoDelay;Fade 0;NoDelay;Power1 ON;NoDelay;Color2 255,0,0', mid: 35
2020-12-03 14:25:11 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/tasmota_0DC328/RESULT: b'{"Fade":"OFF"}'
2020-12-03 14:25:11 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/tasmota_0DC328/RESULT: b'{"POWER":"ON"}'
2020-12-03 14:25:11 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/tasmota_0DC328/RESULT: b'{"POWER":"ON","Dimmer":100,"Color":"FF00000000","HSBColor":"0,100,100","White":0,"CT":153,"Channel":[100,0,0,0,0]}'

MQTT discovery entries in the logs:

2020-12-03 13:44:19 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tasmota/discovery/#, mid: 2
2020-12-03 13:44:20 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/D8F15B0DC328/config (retained): b'{"ip":"192.168.1.152","dn":"Spot02","fn":["Spot02",null,null,null,null,null,null,null],"hn":"tasmota_0DC328-0808","mac":"D8F15B0DC328","md":"ZolderGU10","ty":0,"if":0,"ofln":"Offline","onln":"Online","state":["OFF","ON","TOGGLE","HOLD"],"sw":"9.1.0","t":"tasmota_0DC328","ft":"%prefix%/%topic%/","tp":["cmnd","stat","tele"],"rl":[2,0,0,0,0,0,0,0],"swc":[-1,-1,-1,-1,-1,-1,-1,-1],"swn":[null,null,null,null,null,null,null,null],"btn":[0,0,0,0],"so":{"4":0,"11":0,"13":0,"17":0,"20":0,"30":0,"68":0,"73":0,"82":0,"114":0},"lk":1,"lt_st":5,"ver":1}'
2020-12-03 13:44:20 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/D8F15B0DC328/sensors (retained): b'{"sn":{"Time":"2020-12-03T07:58:54"},"ver":1}'
2020-12-03 13:44:20 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tasmota/discovery/#, mid: 3
2020-12-03 13:44:20 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/D8F15B0DC328/config (retained): b'{"ip":"192.168.1.152","dn":"Spot02","fn":["Spot02",null,null,null,null,null,null,null],"hn":"tasmota_0DC328-0808","mac":"D8F15B0DC328","md":"ZolderGU10","ty":0,"if":0,"ofln":"Offline","onln":"Online","state":["OFF","ON","TOGGLE","HOLD"],"sw":"9.1.0","t":"tasmota_0DC328","ft":"%prefix%/%topic%/","tp":["cmnd","stat","tele"],"rl":[2,0,0,0,0,0,0,0],"swc":[-1,-1,-1,-1,-1,-1,-1,-1],"swn":[null,null,null,null,null,null,null,null],"btn":[0,0,0,0],"so":{"4":0,"11":0,"13":0,"17":0,"20":0,"30":0,"68":0,"73":0,"82":0,"114":0},"lk":1,"lt_st":5,"ver":1}'
2020-12-03 13:44:20 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/D8F15B0DC328/sensors (retained): b'{"sn":{"Time":"2020-12-03T07:58:54"},"ver":1}'
emontnemery commented 3 years ago

@marknl Can you try setoption17 1 on the Tasmota, and verify it works then?

marknl commented 3 years ago

When setOption17 1 was set, saving blue and red in the scenes now shows rgb color information in the scenes.yaml, the scenes now also work. I can now switch back and forth from blue to red scene, even a cold and warm white scene and switching between all 4 is working fine.

So it seems it's important that Tasmota lights have setOption17 set to 1.

Thank you @emontnemery!

emontnemery commented 3 years ago

Great, thanks for confirming! It's a bug, both setOption17 0 and setOption17 1 should work.

marknl commented 3 years ago

You're welcome. Glad to help out. It's a bug? Ah, then someone has some work to do! ;-)

Thanks again