OK, I think that this does it. The problem with previous versions is the fact that Sonoff-Tasmota reuses the “stat/xxxxxx/RESULT” topic but doesn’t always supply all of the information that HA is looking for. So the fix is to check to see if the information is there, otherwise fill in with the current state. It’d be nice too if HA could make use of the “tele/xxxxxx/STATE” messages that Sonoff-Tasmota sends out periodically to refresh the state but that’ll take some coding.
- platform: mqtt
name: "Test B1"
command_topic: "cmnd/sonoff-xxxxxx/POWER"
state_topic: "stat/sonoff-xxxxxx/POWER"
payload_on: "ON"
payload_off: "OFF"
brightness_command_topic: "cmnd/sonoff-xxxxxx/DIMMER"
brightness_scale: 100
brightness_state_topic: "stat/sonoff-xxxxxx/RESULT"
brightness_value_template: "{% if value_json.Dimmer is defined %}{{ value_json.Dimmer }}{% else %}{{ states.light.test_b1.attributes.brightness / 255 * 100 }}{% endif %}"
rgb_command_topic: "cmnd/sonoff-xxxxxx/COLOR"
rgb_command_template: "{{ '%02X%02X%02X0000' | format(red, green, blue) }}"
rgb_state_topic: "stat/sonoff-xxxxxx/RESULT"
rgb_value_template: "{% if value_json.Color is defined %}{{ value_json.Color[0:2]|int(base=16) }},{{ value_json.Color[2:4]|int(base=16) }},{{ value_json.Color[4:6]|int(base=16) }}{% else %}{{ states.light.test_b1.attributes.rgb_color|join(',') }}{% endif %}"
color_temp_command_topic: "cmnd/sonoff-xxxxxx/CT"
color_temp_state_topic: "stat/sonoff-xxxxxx/RESULT"
color_temp_value_template: "{% if value_json.CT is defined %}{{ value_json.CT }}{% else %}{{ states.light.test_b1.attributes.color_temp }}{% endif %}"
effect_command_topic: "cmnd/sonoff-xxxxxx/SCHEME"
effect_state_topic: "stat/sonoff-xxxxxx/RESULT"
effect_value_template: "{% if value_json.Scheme is defined %}{{ value_json.Scheme }}{% else %}{{ states.light.test_b1.attributes.effect }}{% endif %}"
effect_list:
- 0
- 1
- 2
- 3
- 4
availability_topic: "tele/sonoff-995a08/LWT"
payload_available: "Online"
payload_not_available: "Offline"