ESPHome Smart Oil Diffuser & Nightlight

thanx, no it validated the code without error.

OK tried to both of this configs

#RGB#
number:
   - platform: "tuya"
     name: "Light Mode"
     number_datapoint: 110
     min_value: 0
     max_value: 2
     step: 1

light:
  - platform: tuya
    name: Diffuser LEDs
    dimmer_datapoint: 111
    switch_datapoint: 11
    min_value: 1
    color_datapoint: 108
    color_type: rgb
####

and this one

#RGB#
select:
  - platform: "tuya"
    name: "Light Mode"
    enum_datapoint: 110
    options:
      0: Rainbow
      1: Static
      2: Spa Green

light:
  - platform: tuya
    name: Diffuser LEDs
    dimmer_datapoint: 111
    switch_datapoint: 11
    min_value: 1
    color_datapoint: 108
    color_type: rgb
####

It didnā€™t go ā€œmentalā€ as @sgvj wrote it went before. I didnā€™t need to reflash the diffuser, ESPHome and my HA still are connected, it wasnā€™t lost.

But unfortuanlty I canā€™t pick what color I want and I canā€™t dim the light.

Maybe someone that is better with ESPHome could look at it now, might be the code I put in my ESPHome yaml file is wrong now since the latest version.

IMO your code is OK, now it looks it simply does not workā€¦
Maybe testing with rgbhsv but I am not convinced at all.

rgvhsv didnā€™t help.

Iā€™m thinking of, if itā€™s possible to get to the LED and connect that to another ESP32 and use it with WLED, or install another LED strip, like WS2812B.

But not sure it can be open to that part.

Looks complicated, out of my competences anyway :slight_smile:

By reading again the tasmota template it looks like the dimmer can have a minimum value of 0 instead of 1 but it does not look changing anything.

It has worked, then it crasheed, now it simply does not work for RGB. Very strange.

My Asakuki with ESPHome, ran out ow water and the sensor changed to empty, but now I canā€™t clear it, it state the tank is out of water. Can any help me to clear the sensor state

This is how my ESPHome water sensor looks like this:

# enable tuya sensor platform
tuya:
#
sensor:
  - platform: "tuya"
    name: $device_name out of water
    sensor_datapoint: 12

I used a binary sensor:

binary_sensor:
- platform: "tuya"
  name: Eau Diffuseur Bureau
  id: eau
  sensor_datapoint: 12
  device_class: "problem"

When out of water it is set to on but as soon as I put some water and switch the diffuser on again the binary sensor is set to off.

I will try your configuration, thanx.

Hi, I am trying to get my Asakuki 500ml link diffuser to work with Tasmosa. I have replaced the original WBR3 with a ESP-12F. Flashed the ESP-12F and followed following guide: Asakuki 500ml Aroma Diffuser Configuration for Tasmota

Then I noticed it appeared twice so I disabled the automatic discovery by changing SetOption19 to 1.

Now it is using the set up in my configuration.yaml. I did have to change the code slightly to get it, at least partially, to work:

  fan:
      name: "Diffuser fan"
      unique_id: "diffuser_fan"
      state_topic: "stat/diffuser/RESULT"
      state_value_template: "{% if value_json.POWER1 is defined %}{{ value_json.POWER1 }}{% endif%}"
      command_topic: "cmnd/diffuser/POWER1"
      preset_modes:
      -  "high"
      -  "low"
      preset_mode_state_topic: "stat/diffuser/fanmode"
      preset_mode_command_topic: "cmnd/diffuser/tuyaenum1"
      preset_mode_command_template: '{{ 1 if value == "high" else 0 }}'
      availability_topic: "tele/diffuser/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"

  binary_sensor:
      name: "Diffuser error"
      unique_id: "diffuser_error"
      state_topic: "stat/diffuser/error"
      value_template: "{{ 'ON' if value != '0X00' else 'OFF' }}"
      device_class: problem
      availability_topic: "tele/diffuser/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"    

  light:
      name: "Diffuser light"
      unique_id: "diffuser_led"
      availability_topic: "tele/diffuser/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"
      command_topic: "cmnd/diffuser/POWER2GW"
      state_topic: "stat/diffuser/RESULT"
      state_value_template: "{% if value_json.POWER2 is defined %}{{ value_json.POWER2 }}{% endif %}" 
      payload_on: "ON"
      payload_off: "OFF"
      rgb_command_topic: "cmnd/diffuser/tuyasend3"
      rgb_command_template: "{% set brightness = state_attr('light.diffuser_led','brightness') | int %}{{ '108,%02x%02x%02x646464' | format(red, green, blue)}}{{ '%02x' | format(brightness) }}"
      rgb_value_template: "{% if value_json.POWER2 is defined and value_json.POWER2 == 'ON' %}{{value_json.Color.split(',')[0:3]|join(',')}}{% endif %}"
      rgb_state_topic: "stat/diffuser/RESULT"
      brightness_command_topic: "cmnd/diffuser/dimmer"
      brightness_state_topic: "stat/diffuser/RESULT"
      brightness_scale: 100
      brightness_value_template: "{% if value_json.POWER2 is defined and value_json.POWER2 == 'ON' %}{{value_json.dimmer}}{% endif %}"
      effect_list:
      - "cycle"
      - "solid"
      effect_command_topic: "cmnd/diffuser/tuyaenum2GW"
      effect_state_topic : "stat/diffuser/RESULT"
      effect_value_template : "{% if value_json.TuyaEnum2 is defined and value_json.TuyaEnum2 == 0 %}{{'cycle'}}{% elif value_json.TuyaEnum2 is defined and value_json.TuyaEnum2 is defined and value_json.TuyaEnum2 == 1 %}{{'No'}}{% endif %}"

And added the automations in the automations.yaml:

automation:
  - alias: "Diffuser Forwarder MQTT1"
    id: diffuser_forwarder_mqtt1
    trigger:
      - platform: mqtt
        topic: 'cmnd/diffuser/POWER2GW'
    condition:
      condition: template
      value_template: "{{ trigger.payload | lower != states('light.diffuser_led') }}"
    action:
      - service: mqtt.publish
        data_template:
          topic: 'cmnd/diffuser/POWER2'
          payload: "{{ trigger.payload }}"

  - alias: "Diffuser Forwarder MQTT2"
    id: diffuser_forwarder_mqtt2
    trigger:
      - platform: mqtt
        topic: 'cmnd/diffuser/tuyaenum2GW'
    action:
      - service: mqtt.publish
        data_template:
          topic: 'cmnd/diffuser/tuyaenum2'
          payload_template: >
            {% if 'cycle' in trigger.payload -%}
              {{ 0 }}
            {%- elif 'solid' in trigger.payload -%}
              {{ 1 }}
            {%- else -%}
              {{ 2 }}
            {%- endif %}

The diffuser fan etc seems to work, however I get errors with the light:

Parsing template {% set brightness = state_attr('light.diffuser_led','brightness') | int %}{{ '108,%02x%02x%02x646464' | format(red, green, blue)}}{{ '%02x' | format(brightness) }} for entity light.diffuser_light failed with error: ValueError: Template error: int got invalid input ā€˜Noneā€™ when rendering template ā€˜{% set brightness = state_attr(ā€˜light.diffuser_ledā€™,ā€˜brightnessā€™) | int %}{{ ā€˜108,%02x%02x%02x646464ā€™ | format(red, green, blue)}}{{ ā€˜%02xā€™ | format(brightness) }}ā€™ but no default was specified.

Failed to call service light/turn_on. color_RGB_to_hs() missing 2 required positional arguments: ā€˜iGā€™ and ā€˜iBā€™

I am not sure what is asking me to do. Does anyone have any tips?

too confusing, I have a Maxcio 440ml, is there a 100% functional template for esphome?

100% functional, as fare as I know, no.
With my config all you loose is RGB control using HA, if it is essential for your use you might consider to switch to Tasmota.
I have not set anything to switch from different color mode because I wonā€™t use it, which is something which could be added.

thanks for reply, i am currently on Tasmota and waiting to migrate to Esphome, since it is the only device I need to make.

So if you really want to migrate to ESPHome you might have to accept some compromise with this diffuser except if I have missed something and someone else in this topic have succeeded with RGB.

1 Like

Hi @Nardol @roberdlv , technically if it work in tasmota it should work in esphome.
Juste need to find how to create the RGB/light/template to drive those led.

Indeed you didnā€™t use it I already know why and understand.

I set log level to debug and it is very strange because it looks color value is never updated.
When there is a new value it is always FFFFFF000000FF and when I switch the diffuser on, the value never changes even if color changes on the diffuser itself, I checked with someone who confirmed light color was changing.

The light config is as follow:

light:
  - platform: tuya
    name: Leds
    id: leds
    dimmer_datapoint: 111
    switch_datapoint: 11
    min_value: 0
    color_datapoint: 108
    color_type: rgbhsv
    entity_category: CONFIG

If ESPHome debug mode does not report change, there is a bug on ESPHome or something wrong on all my three devices.

This is what Iā€™m using as an alternative. I hope it helps someone.
You have to switch on the LED before you can change the color.

substitutions:
  devicename: master_bedroom_aroma_diffuser
  name: master-bedroom-aroma-diffuser
  friendly_name: Master Bedroom Aroma Diffuser
  device_description: Tellur XD800W - TYWE3S

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  platformio_options:
    board_build.f_cpu: 160000000L

esp8266:
  board: esp_wroom_02
  restore_from_flash: true

preferences:
  flash_write_interval: 1min

# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:
  reboot_timeout: 1h
  encryption:
    key: !secret api_encryption_key

ota:
  safe_mode: true
  password: !secret ota_password

web_server:
  port: 80
  auth:
    username: !secret username
    password: !secret password
  include_internal: true

time:
  - platform: homeassistant
    id: homeassistant_time

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  power_save_mode: none
  ap:
    ssid: "${friendly_name}"

captive_portal:

uart:
  baud_rate: 9600
  tx_pin: GPIO1
  rx_pin: GPIO3

tuya:
    id: master_bedroom_aroma_diffuser

button:
  - platform: restart
    name: Restart
    id: ${devicename}_reset
    entity_category: diagnostic

  - platform: factory_reset
    name: Factory Reset
    id: ${devicename}_fatory_reset
    internal: true
    entity_category: diagnostic

  - platform: safe_mode
    name: Safe Mode Boot
    id: ${devicename}_safe_mode_boot
    entity_category: diagnostic


text_sensor:
  - platform: wifi_info
    ip_address:
      name: IP Address
    ssid:
      name: Connected SSID
    bssid:
      name: Connected BSSID
    mac_address:
      name: MAC WiFi Address

  - platform: version
    name: ESPHome Version

  - platform: tuya
    name: Selected Color
    id: ${devicename}_selected_color
    internal: true
    sensor_datapoint: 8
    on_value:
      then:
        - lambda: |-
            if (x == "00000000000000") {
              id(${devicename}_color).publish_state("None");
            } else if (x == "ff00000000ffff") {
              id(${devicename}_color).publish_state("Bright Red");
            } else if (x == "8000000000ff80") {
              id(${devicename}_color).publish_state("Dark Red");
            } else if (x == "ffff00003cffff") {
              id(${devicename}_color).publish_state("Bright Yellow");
            } else if (x == "808000003cff80") {
              id(${devicename}_color).publish_state("Dark Yellow");
            } else if (x == "00ff000078ffff") {
              id(${devicename}_color).publish_state("Bright Green");
            } else if (x == "0080000078ff80") {
              id(${devicename}_color).publish_state("Dark Green");
            } else if (x == "00ffff00b4ffff") {
              id(${devicename}_color).publish_state("Bright Cyan");
            } else if (x == "00808000b4ff80") {
              id(${devicename}_color).publish_state("Dark Cyan");
            } else if (x == "0000ff00f0ffff") {
              id(${devicename}_color).publish_state("Bright Blue");
            } else if (x == "00008000f0ff80") {
              id(${devicename}_color).publish_state("Dark Blue");
            } else if (x == "ff00ff012cffff") {
              id(${devicename}_color).publish_state("Bright Magenta");
            } else if (x == "800080012cff80") {
              id(${devicename}_color).publish_state("Dark Magenta");
            }

binary_sensor:
# sense water alert. 1 = fine. 0 = Out of water
  - platform: tuya
    name: Out of water
    id: ${devicename}_out_of_water
    sensor_datapoint: 2
    device_class: safety
    filters:
      - invert:

  - platform: status
    name: Status

sensor:
  - platform: wifi_signal
    name: WiFi Signal
    update_interval: 60s
    id: ${devicename}_wifi_signal

  - platform: uptime
    name: Device Uptime
    id: ${devicename}_device_uptime

switch:
  - platform: tuya
    name: Diffuser
    id: ${devicename}_diffuser
    switch_datapoint: 1

light:
  - platform: tuya
    name: LED
    id: ${devicename}_led
    switch_datapoint: 5
    on_turn_off:
      - delay: 1s
      - script.execute: ${devicename}_turn_off_led

select:
  - platform: tuya
    name: Light Mode
    id: ${devicename}_light_mode
    enum_datapoint: 6
    options:
      0: Static Color
      1: RGB Cycle

  - platform: tuya
    name: Set Timer
    id: ${devicename}_set_timer
    enum_datapoint: 3
    options:
      0: "Off"
      1: 1 Hour
      2: 3 Hours
      3: 6 Hours

  - platform: template
    name: Color
    id: ${devicename}_color
    optimistic: true
    options:
      - None
      - Bright Red
      - Dark Red
      - Bright Yellow
      - Dark Yellow
      - Bright Green
      - Dark Green
      - Bright Cyan
      - Dark Cyan
      - Bright Blue
      - Dark Blue
      - Bright Magenta
      - Dark Magenta
    initial_option: None
    on_value:
      then:
        - if:
            condition:
              lambda: |-
                return x != "None";
            then:
              - light.turn_on: ${devicename}_led
              - lambda: |-
                  if (x == "Bright Red") {
                    id(master_bedroom_aroma_diffuser).set_string_datapoint_value(8, "ff00000000ffff");
                  } else if (x == "Dark Red") {
                    id(master_bedroom_aroma_diffuser).set_string_datapoint_value(8, "8000000000ff80");
                  } else if (x == "Bright Yellow") {
                    id(master_bedroom_aroma_diffuser).set_string_datapoint_value(8, "ffff00003cffff");
                  } else if (x == "Dark Yellow") {
                    id(master_bedroom_aroma_diffuser).set_string_datapoint_value(8, "808000003cff80");
                  } else if (x == "Bright Green") {
                    id(master_bedroom_aroma_diffuser).set_string_datapoint_value(8, "00ff000078ffff");
                  } else if (x == "Dark Green") {
                    id(master_bedroom_aroma_diffuser).set_string_datapoint_value(8, "0080000078ff80");
                  } else if (x == "Bright Cyan") {
                    id(master_bedroom_aroma_diffuser).set_string_datapoint_value(8, "00ffff00b4ffff");
                  } else if (x == "Dark Cyan") {
                    id(master_bedroom_aroma_diffuser).set_string_datapoint_value(8, "00808000b4ff80");
                  } else if (x == "Bright Blue") {
                    id(master_bedroom_aroma_diffuser).set_string_datapoint_value(8, "0000ff00f0ffff");
                  } else if (x == "Dark Blue") {
                    id(master_bedroom_aroma_diffuser).set_string_datapoint_value(8, "00008000f0ff80");
                  } else if (x == "Bright Magenta") {
                    id(master_bedroom_aroma_diffuser).set_string_datapoint_value(8, "ff00ff012cffff");
                  } else if (x == "Dark Magenta") {
                    id(master_bedroom_aroma_diffuser).set_string_datapoint_value(8, "800080012cff80");
                  }
            else:
              - lambda: |-
                  id(master_bedroom_aroma_diffuser).set_string_datapoint_value(8, "00000000000000");
              - light.turn_off: ${devicename}_led

status_led:
  pin:
    number: GPIO13
    inverted: true

script:
  - id: ${devicename}_turn_off_led
    mode: parallel
    then:
      - lambda: |-
          id(master_bedroom_aroma_diffuser).set_string_datapoint_value(8, "00000000000000");

Hey everyone,

I recently ran into an issue with my ASAKUKI diffuser that had a WBR3 chip. The chip stopped working, so I replaced it with an ESP12F and flashed Tasmota on it. Now, Iā€™d like to restore it to the original firmware.

Does anyone have a backup of the original firmware on a flashable chip? If possible, could you send it to my email at [email protected]? Iā€™d really appreciate any help you can offer.

Thanks!

I have the asakuki duffuser with the wbr3 chip. How i have to connect the chip to the serial adapter to flash it with esphome ?

@Nardol