ESPHome Smart Oil Diffuser & Nightlight

Tags: #<Tag:0x00007f326b8555a8>

Hi, I have a Asakuki 500ml Oil Diffuser. If you have a similar wifi-enabled diffuser, the chances are the below, or something similar will work for you.

*Update, I’m using tasmota for now and most seem to be doing the same, it isn’t perfect but seems better.

I flashed it with tyua-convert and had it setup with Tasmota and realized that much of the information on the template page were incorrect. Fortunately a better way of doing things and correct codes were in a similar device. Everything was working 100% but I wanted to use the home-assistant API and I <3 ESPHome.

I compiled an ESPHome config, uploaded it and… boom was unable to reach the device completely :dizzy_face:.

Fortunately a co-worker helped me with some soldering so I flashed it manually, this time with a minimal configuration and one small thing that I believe prevented whatever loop that screwed things up first time.

logger:
  baud_rate: 0

After some tinkering I managed to get 80% of the functionality of tasmota up and running.
The two key exceptions (perhaps you can help?) are:

  1. No empty water notification to home asssistant. AFAIK there is no UART ‘listen’ function in esphome. This isn’t a huge problem as the device shuts down the mist function anyway.
  2. Perhaps related to the above, everything is running on ‘optimistic’ - I’d rather know for sure the state of the switch.
  3. No perfect ‘light’ configuration to control the LED. I can send of specific RGB strings, but don’t know enough lambda magic to create a custom light component.

This is the best diffuser I have owned, and the price is cheaper than smaller, dumber diffusers.

For anyone else looking to use esphome with their diffuser, this esphome config may be a useful starting point:

substitutions:
  devicename: asakuki

esphome:
  name: asakuki
  platform: ESP8266
  board: esp01_1m

# disable rainbow LED mode (allowing custom led color selection)
  on_boot:
    then:
      - uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x05, 0x6e, 0x04, 0x00, 0x01, 0x01, 0x7E]
      
wifi:
  ssid: "yours"
  password: "yours"

switch:
  - platform: template
    name: $devicename LED
    optimistic: true
    turn_on_action:
      - uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x05, 0x0b, 0x01, 0x00, 0x01, 0x01, 0x18]
    turn_off_action:
      - uart.write: [0x55, 0xAA, 0x00, 0x06, 0x00, 0x05, 0x0B, 0x01, 0x00, 0x01, 0x00, 0x17]

  - platform: template
    name: $devicename Rainbow Mode
    optimistic: true
    turn_on_action:
      - uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x05, 0x0b, 0x01, 0x00, 0x01, 0x01, 0x18]
    turn_off_action:
      - uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x05, 0x6e, 0x04, 0x00, 0x01, 0x01, 0x7E]

uart:
  baud_rate: 9600
  tx_pin: GPIO1
  rx_pin: GPIO3

# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:
  services:
    - service: asakuki_off
      then:
        - uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x05, 0x67, 0x04, 0x00, 0x01, 0x02, 0x78]
    - service: asakuki_wifi_led
      then:
        - uart.write: [0x55, 0xaa, 0x00, 0x03, 0x00, 0x01, 0x03, 0x06]
    - service: asakuki_fast
      then:
        - uart.write: [0x55, 0xAA, 0x00, 0x06, 0x00, 0x05, 0x67, 0x04, 0x00, 0x01, 0x01, 0x77]
    - service: asakuki_slow
      then:
        - uart.write: [0x55, 0xAA, 0x00, 0x06, 0x00, 0x05, 0x67, 0x04, 0x00, 0x01, 0x00, 0x76]
    - service: asakuki_purple
      then:
        - uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x12, 0x6c, 0x03, 0x00, 0x0e, 0x64, 0x38, 0x30, 0x30, 0x66, 0x66, 0x30, 0x31, 0x32, 0x32, 0x66, 0x66, 0x66, 0x66, 0xb9]
    - service: asakuki_color_green1
      then:
        - uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x12, 0x6c, 0x03, 0x00, 0x0e, 0x37, 0x38, 0x66, 0x66, 0x30, 0x30, 0x30, 0x30, 0x35, 0x63, 0x66, 0x66, 0x66, 0x66, 0xBF]
    - service: asakuki_color_orange
      then:
        - uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x12, 0x6c, 0x03, 0x00, 0x0e, 0x66, 0x66, 0x34, 0x32, 0x30, 0x30, 0x30, 0x30, 0x30, 0x66, 0x66, 0x66, 0x66, 0x66, 0xb4]
    - service: asakuki_color_yellow
      then:
        - uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x12, 0x6c, 0x03, 0x00, 0x0e, 0x66, 0x66, 0x63, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x64, 0x66, 0x66, 0x66, 0x66, 0xe1]
    - service: asakuki_color_green2
      then:
        - uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x12, 0x6c, 0x03, 0x00, 0x0e, 0x30, 0x30, 0x66, 0x66, 0x34, 0x32, 0x30, 0x30, 0x38, 0x37, 0x66, 0x66, 0x66, 0x66, 0x8d]
    - service: asakuki_color_blue
      then:
        - uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x12, 0x6c, 0x03, 0x00, 0x0e, 0x30, 0x30, 0x63, 0x33, 0x66, 0x66, 0x30, 0x30, 0x63, 0x33, 0x66, 0x66, 0x66, 0x66, 0xe4]
    - service: asakuki_color_pink
      then:
        - uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x12, 0x6c, 0x03, 0x00, 0x0e, 0x66, 0x66, 0x30, 0x30, 0x61, 0x38, 0x30, 0x31, 0x34, 0x31, 0x66, 0x66, 0x66, 0x66, 0xb7]
    - service: asakuki_color_red1
      then:
        - uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x12, 0x6c, 0x03, 0x00, 0x0e, 0x66, 0x66, 0x30, 0x30, 0x32, 0x34, 0x30, 0x31, 0x36, 0x30, 0x66, 0x66, 0x66, 0x66, 0x85]
    - service: asakuki_color_red2
      then:
        - uart.write: [0x55, 0xaa, 0x00, 0x06, 0x00, 0x12, 0x6c, 0x03, 0x00, 0x0e, 0x66, 0x66, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x66, 0x66, 0x66, 0x66, 0x78]
ota:

In the future I hope to use the ‘fan’ component so homeassistant will show better controls for off/low/high and a colorpicker for the LED - perhaps even effects- why not.

8 Likes

thx for your codes !!!

Thank you very much for sharing! Can you tell us how you did the tuya convert? Is it like any other plug convert, over Wifi? Or any soldering?

Tuya convereted over wifi just like a plug. I don’t recall if I had to hold the wifi button to get it into the correct state - or if it just worked without additional interaction. It did take me several attempts and I think I had to fix my tuya convert installation but that’s just due to my setup.

Just be careful to disable logging if/when you flash esphome -

logger:
  baud_rate: 0
1 Like

OK clear thanks a lot…
So basically step by step:
1 Tuya convert to Tasmota
2 Flash with ESPHome with logging disabled
3 Tinker with ESPHome or put the config you proposed here, but make sure you keep logging disabled
Right?

If you know how to use the ‘compile’ option in esphome, you could probably flash that .bin file instead of the tasmota one at the outset and skip a few steps.
Otherwise your steps look good.

1 Like

I use Jinvoo Smart but believe Tuya and Jinvoo Smart work the same… To simply control turning on and off(and disabling rainbow light on start up) I created an automation for On( Triggered by Power On, Actions are Light: Off and Fog: Large Spray) and Off(Triggered by Power Off, Actions are Light: Off and Fog: Off) you can then find them in Home assistant as Scenes that you can activate to turn on or off. Hopefully this helps someone as I did not want to solder.

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

Nice! This all makes a lot of sense. I eventually setup all this kind of thing in Homeassistant itself using template switches and service calls (see below). Doing it in esphome would have been way better,.

My main usecase is that it turn itself on and off automatically based on presence and time of day. also only stay on for a few minutes at a time. This means I can stop wasting oil due to olfactory fatigue (noseblindness). It also means the water lasts a very long time.

Have you wondered how to set it up as a light in homeassistant?

I wondered a little bit, but I barely use the light anyway. If I do use it, it’s generally Rainbow Mode just for fun.

So, I didn’t really bother as it wasn’t worth the effort. I think it would be possible, but probably would be fairly hacky.

If you or someone does make it work as a proper light, please post the configs here!

Also, I really wish there was a way to read the state from the diffuser. I would love to know when it runs out of water so I can refill it. When it runs out, it turns off automatically, but HA/ESPHome still think it’s on, as the updated state doesn’t get reported anywhere. One idea I had was to use an energy monitoring smart plug, and if the diffuser is on according to HA but not using a certain number of watts, mark it as off in HA.

I usually like using esphome whenever possible but in this particular cases, you lose functionality by choosing it over tasmota. With tasmota I can configure to show the states should anyone press the physical buttons. If this feedback would be present in esphome, I would switch in an instant

Hey people… I’d be highly interested in this awesome pice of hack! I just ordered a ASAKUKI Humidifier which should arrive me already tomorrw. Amazon thanks :stuck_out_tongue:

No I am a bit wondering how to Flash this device. I normally work with ESPHome but already playe with Tasmota back in the days… What’s the softare to slash this Humidifier Tuya COnverster? Nev heard if this. Is it part of tasmota?

If yomeone could write a small quick and dirty how-to I’d highly appreciate :slight_smile: I need a WAF immediately… if not I am in D A N G E R :stuck_out_tongue:

@JibbsIsMe I totally agree with @gureyes Tasmota has some clear advantages here such as getting no-water notifications and granular light control.
I may switch back at some point.

@thundergreen, Everything you’ll need to OTA convert is here https://github.com/ct-Open-Source/tuya-convert.
WAF?

You have me interested. I’ve only used Tasmota as a temporary firmware to flash ESPHome. How would I get this working with Tasmota? Do you have example configs for this?

WAF = Wife Approval Factor. Basically, things need to work easily and as expected :slight_smile:

Shit I think I bought the wrong one …there’s no wifi and nothing maked on the device

You were so close! That looks exactly the same as mine, and the one I got was from your link, but you need to get the “WiFi Smart Version” which has the WiFi button on the device and in the pictures. I’d return that and swap it for the right one! It’s a couple bucks more but worth it.

Most recent wifi-diffusers have almost identical features and codes. Take a look through the tasmota ‘misc’ category for a ‘proven’ list. Each one has documentation provided by an author who may or may not have improved on the work of the previous.
IIRC the best one had the least setup instructions and utilized a feature only in the newer firmware called TuyaMCU : https://blakadder.github.io/templates/GD-30W.html

That page is rather complex, I might wait to see if someone gets it working on our model of diffuser first, before trying to switch over!