ESPHome Smart Oil Diffuser & Nightlight

Can anyone explain the RST pin in the linked asakuki guide?

Update: I got it to work. I just ignored the comment about RST/Reset pins in the guide and tried using esptool/whatever flasher right after I saw it appear in my device manager after powering on. If I got it early enough, it worked. If I waited too long, I think the MCU took over.

I now have my Asakuki flashed with ESPHome using the config I mentioned before, as a lot of other Tuya compatible diffusers use the same way.
As someone has replaced the WBR3 for me all is possible :slight_smile: this diffuser looks like better than this from Maxcio.

2 Likes

Is there anyone in the UK who would be willing to set one of these up for me (for a fee)?

I’m not familiar with the hardware or firmware side of things, and don’t really have the time to play around with this myself.

If you can’t message me here, feel free to grab an email address from my website: https://sambull.org/

@sgvj First of all, thanx for your code. :slight_smile:

I flashed my Asakuki with your ESPHome code and I have one question, not sure if I’m doing wrong or not. How can I change the color of the light? I have the rainbow and I can use that to go through the color cycles. Is there anyway to choose what color I would like the diffuser to use, like when using a color bulb to get the color palatte?

Yes, thanks largely to brand new Tuya support in ESPhome.

First you’ll need to stop rainbow mode which activates whenever the light switch is toggled.
Create a number sensor. 0=Rainbow(default) 1=Static Color(even if it’s black aka off) 2= some weird hard coded color I guess they thought was theraputic.

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

Great, but now you want to control it like a light.
I tried to use the following code but it results in ugly light flashing and bootloops. Oddly this worked in an earlier version of ESPhome, before they implemented the Tuya number component.

light(warning do not use):
  - platform: tuya
    name: Diffuser LEDs
    dimmer_datapoint: 111
    switch_datapoint: 11
    min_value: 1
    rgb_datapoint: 108 #beware this makes it go mental

If anyone can pull the debug with a physical wired connection, the devs may fix it.

2 Likes

And if this kind person could send result to this issue please: Tuya RGB datapoint doesn't work since ESPHome 2022.1 · Issue #3057 · esphome/issues · GitHub

I also spent some times on understanding it :wink: and unfortunately I won’t be able to do more.

OK, I’ll wait with the light: config then.

Another question, the sensor for water “Out of water 0”.
I assume it say 0 when there is water, what does it say when the tank is empty?
I tested it and saw 0 when there is water in the tank and 1 when it’s empty.

Is there a way to make it say OK or Normal when there’s water and Refill when the tank is empty?

There are a ton of ways to approach this. Including a text sensor on the diffuser or template sensor in home-assistant that has a value dependent on the 1/0.
I personally don’t show it in the UI, instead using this to have a self-dismissing alert:

description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.asakuki_water_alert
    id: empty
    to: 'on'
  - platform: state
    entity_id: binary_sensor.asakuki_water_alert
    id: refilled
    to: 'off'
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: empty
        sequence:
          - service: notify.notify
            data:
              title: Diffuser is out of water
              message: Please refill
              data:
                tag: diffuser
      - conditions:
          - condition: trigger
            id: refilled
        sequence:
          - service: notify.notify
            data:
              message: clear_notification
              data:
                tag: diffuser
    default: []
mode: single```

Well, I tried
The wires are still soldered inside my device so I figured I’d give it a shot. After attempting to connect it to 3 computers and tearing all my hair out, I came to realize that I’ll actually need an FTDI instead of a direct usb connection. So… until then.

1 Like

Hi,

Any news here?
I might try to debug with the cables attached if someone could guide me how and what to debug.

Awesome, appreciated. IIRC use the tuya light component.
The key part is the rgb_datapoint.

light:
  - platform: tuya
    name: lightname
    switch_datapoint: 11
    min_value: 1
    rgb_datapoint: 108

After flashing, your device won’t be happy, and hopefully will show logs showing why/how. Copy the error messages and post on the bug above. I don’t know what log level will be required.

When done you can reflash without the RGB line to fix it.

will do this this weekend, do I need to enable some debug option and that it should log to the usb/serial in the code?

@DariBer log_level should be set to at least debug to have enough information.

I don’t know how to debug Tuya via USB using ESPHome, in the documentation they set baud_rate to 0 and I don’t know what happens if it is not the case but maybe @sgvj can answer better?

Setting the log level makes sense.
IIRC after flashing via usb you will just see all the debug data in the install window as the device reboots.

In other news the v2022.6.0 update brings us a better way to select modes

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

Instead of

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

The RGB issue isn’t accidentally fixed :face_with_head_bandage: but it seems a bit less alarming when it glitches out, so something may have shifted.

FOr information, it should also allow to use native timer by using dpID13 for people who wish to use integrated functions instead of time in ESPHome.
Remaining time is reported using dpID14.

Does it make it exploitable or it only make the device not crashing?

@DariBer did you have the possibility to try to debug it to better understand this issue?

Neither, could be my imagination but I think it flickered differently is all. Thanks for the tips on the timer. How do you convert the countdown?

1 Like

OK, so I won’t change anything on that side for my diffuser :grin: hop someone will be able to make some debugging :slight_smile:

The countdown is specified in minutes.
The human readable uptime sensor helped me a lot, we can do for example:

select:
  - platform: tuya
    name: timer
    enum_datapoint: 13
    options:
      0: "Off"
      1: "1 hour"
      2: "3 hours"

sensor:
  - platform: tuya
    name: ""
    id: diffuser_timer
    internal: true
    sensor_datapoint: 14
    on_raw_value:
      then:
        - text_sensor.template.publish:
            id: timer_human
            state: !lambda |-
              int minutes = id(diffuser_timer).raw_state;
              int hours = minutes / 60;
              minutes = minutes % 60;
              return (
                (hours ? to_string(hours) + ":" : "0:") +
                (minutes ? to_string(minutes) : "00")
              ).c_str();

text_sensor:
  - platform: template
    name: "Remaining time"
    id: timer_human
    icon: mdi:clock-start

Using this configuration the select allows to choose the desired timer and the remaining time is showed using h:mm format so 0:00 by default.
It might be enhanced by displaying a 0 before the remaining minutes if lesser than 10 if we really want a perfect format but it should be OK for a POC as it is :slight_smile:

Hi Peter,
Could you tell me exactly how you put the wires?

So if i use a TTL usb serial adapter, i put :
tx-rx usb adapter
rx-tx usb adapter
3v-3v usb adapter
gnd - gnd usb adapter
gpi0 - to gnd on usb adapter

is that correct ?