I wanted to ask for your help, I have some problems with ESPHOME.
I have a Maxcio 400ML diffuser and I am not able to make it work 100% correctly, I looked for a template but I only found one that does not work correctly.
I would be happy to help you but “does not work correctly” does not help to know what problem(s) is/are nor what you mean by working correctly.
I’ve changed a lot this configuration since I made it so I could simply give you the last one I have or if you help me to help I could try to understand what is wrong.
I had a lot of compilation errors, I can send when I get home again, I also saw that there are 3 fan positions and my device only has two, RGB lights I didn’t see working as expected either, just random with a toggle on and off… .
I don’t remember more details now but I could send you of course!
I was wondering if there is a new version of the template, based on what you mentioned.
It is a workaround for a strangeness of this device.
It has only two positions but when it is switched off after it has been switched on once or more, the Tuya MCU reports a third position.
So I set three position and switch the ESPHome Tuya fan to off when the position is 100%.
Yes, as fare as I know nobody have succeeded in managing RGB and this issue made things worse.
I am blind so I cannot check what happens when I try to set something for light colors but now it stopped crashing my device but what I know is light color cannot be changed from Home Assistant.
Yes but I removed all substitution variables and some tweaks E.G. the ability to switch led off when the diffuser is switched on.
So if You are interested I still can update the template after I made some test because I have added a time entity for planned diffusion, which means it now requires ESPHome 2024.5.
Here is the template I used, I eliminated some things and I don’t get errors I think, even though I don’t use the device yet (I haven’t flashed)
I removed the old template so I can’t provide the errors obtained
This is my actual template, without any automation as you asked:
esphome:
name: room-diffuser
friendly_name: Room diffuser
area: Room
esp8266:
board: esp01_1m
# restore_from_flash: true # Some test are still to be done with or without it
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_key
ap:
password: !secret ap_key
# Remove next two lines if you don't need/want IPv6
network:
enable_ipv6: true
captive_portal:
api:
encryption:
key: !secret diffuseur_bureau_encryption_key
ota:
password: !secret diffuseur_bureau_ota_pass
uart:
baud_rate: 9600
tx_pin: GPIO1
rx_pin: GPIO3
logger:
baud_rate: 0
level: ERROR
esp8266_store_log_strings_in_flash: false # :doc:`recommanded for ESP8266 </components/sensor/custom>`
tuya:
on_datapoint_update:
- sensor_datapoint: 13
datapoint_type: enum
then:
- lambda: if (x>0x0) tuya_tuya_id->set_enum_datapoint_value(13, 0x0);
- sensor_datapoint: 103
datapoint_type: enum
then:
- lambda: if (x==0x2) {auto call = id(diffuseur).turn_off();call.perform();}
binary_sensor:
- platform: tuya
name: Water
id: eau
sensor_datapoint: 12
device_class: problem
entity_category: DIAGNOSTIC
fan:
- platform: tuya
name: None
id: diffuseur
switch_datapoint: 1
speed_datapoint: 103
speed_count: 3 # Workaround when diffuser is switched off
light:
- platform: tuya
name: Leds
id: leds
dimmer_datapoint: 111
switch_datapoint: 11
min_value: 0 # Maybe it is the same without any configured value
# Colors looks not very manageable
# color_datapoint: 108 # The only sure thing
# color_type: rgbhsv # Or something else (rgb or hsv)
entity_category: CONFIG
When reading your previously posted code, you added the web server component.
I hop it is for first tests, because it is not really recommended with ESP8266.
It works but if you plan to use your diffuser only with Home Assistant, consider to avoid using it, this is only my opinion of course.
With this config you will have the minimum features, no automation nor customization.
The data point which are watched are inspired from the Tasmota template to avoid a timer to be set and to set the fan state to off when speed is set to 100%.
The new entity naming is used.
I hop this helps I’m still here if you need more precision or information of course.
Thank you so much! I’ll try it and tell you how it works!
Why is the web server not recommended?
Is there a way to save the last state (from persistent home assistant or similar? in case the power goes out) I would not like to use flash memory for this, because it ends up being damaged and also according to esphome that option is obsolete
Please note that enabling this component will take up a lot of memory and may decrease stability, especially on ESP8266.
Not recommended is not the case but it is something to consider.
For last state stored in flash, where did you read ESPHome says it is obsolete?
I’ve just browsed the documentation again and did not find it, there is even a setting to mitigate too much write in flash.
Moreover, with this specific template, I don’t think it will change anything because the Tuya MCU looks manage things. But in my case, I added a time entity to be able to configure planned diffusion directly on the device so I have to enable it, which will not damage it because it won’t be changed so much and the mitigation will also help.
“Old-style platform options, which have been moved to the platform-specific esp32 and esp8266 sections but are still accepted here for compatibility reasons (usage not recommended for new projects):” ESP8266 Platform — ESPHome
Not recommended.
I have many esp8266 and I don’t know how to save their state correctly without killing the flash
Really, I have read again this documentation and particularly what you linked and don’t see how you could have understood ESPHome says it is deprecated to use restore_from_flash: true.
The only thing which is not recommended is to specify platform: esp8266 in the esphome section instead of using the esp8266 section.
The default values when setting restore_from_flash: true allows to have persistent state in flash without breaking flash too quickly:
preferences:
flash_write_interval: 1min
Because data will be written with a delay of a minute instead of immediately, which is stated in this part of the documentation. So if you use the default value when restore_from_flash is set to true in the esp8266 section of your configuration, you should not kill the flash of your ESP8266.
Everything I say is only from the documentation and from my experience with some ESP8266.
I would like to know if there is an alternative way to avoid damaging the flash, and use Home Assistant or something else to save the persistent state and thus avoid degrading the flash of the esp8266 that I have.,
I don’t know, but maybe someone knows and could answer you for an alternative.
But I really think you see the problem bigger than it is. Some years after I use this persist method, I had not to replace any esp as it looks it is a big issue for old devices especially when writing data very often. Good luck to find more complicated solution as this topic is for Maxcio diffuser, maybe you should open a separate topic specifically for persistent state alternative to restore from ESP internal flash except if you already done it, you might get more replies specifically on this matter.