Thanks OP, this worked very well. I have the exact same diffuser. Compiled the firmware with ESPHome
, then flashed with tuya-convert
.
I made some changes to your config, mainly to move away from API/service calls to switches.
For all of these I have assumed_state=True
, since I may use the buttons on the device itself. If you donāt plan on using the buttons, or donāt care that the state may become incorrect, you can set these to False
.
Replace the service
block from the OP with this:
switch:
- platform: template
name: ${devicename} Light Static
id: light_static
icon: mdi:lightbulb
optimistic: true
assumed_state: true
turn_on_action:
- if:
condition:
switch.is_off: light_rainbow
then:
- uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x05, 0x0b, 0x01, 0x00, 0x01, 0x01, 0x18]
- uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x05, 0x6e, 0x04, 0x00, 0x01, 0x01, 0x7E]
- switch.template.publish:
id: light_rainbow
state: OFF
turn_off_action:
- uart.write: [0x55, 0xAA, 0x00, 0x06, 0x00, 0x05, 0x0B, 0x01, 0x00, 0x01, 0x00, 0x17]
- switch.template.publish:
id: light_rainbow
state: OFF
- platform: template
name: ${devicename} Light Rainbow
id: light_rainbow
icon: mdi:lightbulb
optimistic: true
assumed_state: true
turn_on_action:
- uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x05, 0x0b, 0x01, 0x00, 0x01, 0x01, 0x18]
- switch.template.publish:
id: light_static
state: OFF
turn_off_action:
- uart.write: [0x55, 0xAA, 0x00, 0x06, 0x00, 0x05, 0x0B, 0x01, 0x00, 0x01, 0x00, 0x17]
- switch.template.publish:
id: light_static
state: OFF
- platform: template
name: ${devicename} Power High
id: power_high
icon: mdi:fan
optimistic: true
assumed_state: true
turn_on_action:
- uart.write: [0x55, 0xAA, 0x00, 0x06, 0x00, 0x05, 0x67, 0x04, 0x00, 0x01, 0x01, 0x77]
- switch.template.publish:
id: power_low
state: OFF
turn_off_action:
- uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x05, 0x67, 0x04, 0x00, 0x01, 0x02, 0x78]
- switch.template.publish:
id: power_low
state: OFF
- platform: template
name: ${devicename} Power Low
id: power_low
icon: mdi:fan
optimistic: true
assumed_state: true
turn_on_action:
- uart.write: [0x55, 0xAA, 0x00, 0x06, 0x00, 0x05, 0x67, 0x04, 0x00, 0x01, 0x00, 0x76]
- switch.template.publish:
id: power_high
state: OFF
turn_off_action:
- uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x05, 0x67, 0x04, 0x00, 0x01, 0x02, 0x78]
- switch.template.publish:
id: power_high
state: OFF