ESPHome Smart Oil Diffuser & Nightlight

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 ?

What does this mean ? Do i have to wire GPIO0 to GND on the TYWES or on the FTDI ?

Ground GPIO0 on either is fine (as long as the GND on the board is also attached to the FTDI). It is only required at boot, you can take it off seconds after power is supplied

i have an InnoGear diffuser that i flashed with Tasmota, running version 12.2

I used this configuration and i got the RGB to work perfectly (with the exception of not able to turn the light off, i would like to fix that), but i can’t seem to get the diffuser mist to work. I compared the configuration against a bunch of other ones on the tasmota templates, and i can’t seem to figure out how to get the mist to work. I see a few people with the opposite issues i have, where the mist work but no light control. i’ve reset my tasmota to stock and tried other configurations, still no luck. Can anyone help a dude out?

Has someone tested again to set RGB light using ESPHome?

@sgvj

Sorry for not coming back before, but rough time came inbetween.
I’m back now and thought I would try to pull some logs.

But when I tried to add this

#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
    rgb_datapoint: 108

I got this error message:
INFO ESPHome 2023.10.1
INFO Reading configuration /config/esphome/asakuki.yaml…
Failed config

light.tuya: [source /config/esphome/asakuki.yaml:106]
platform: tuya
name: Diffuser LEDs
dimmer_datapoint: 111
switch_datapoint: 11
min_value: 1

This option has been removed, use color_datapoint and color_type instead.
rgb_datapoint: 108

Unfortunately I don’t know how to use color_type and color_datapoint. I tried to just replace rgb_datapoint but that didn’t work. So got any ideas?

If I understand correctly the documentation, both color_datapoint: 108 and color_type: rgb should be set for the Tuya light.

And maybe if you have time, try to set to other values like hsv and and rgbhsv to see if behavior is different?

If it can help, the documentation: