I’m pretty new in HASS and I have some questions that you probably know so hope you can help me I am getting the soil humidity value from an external device (ESP-12E) via mqtt and I would like to show if the soil is wet or dry depending on the voltage level and the previous states (hysteresis) instead of the value I’m getting (between 0V - 3,3V).
What I was thing is to create a “global variable” that will report the state of the soil but it will be also a variable that helps me to apply the hysteresis. Thinking in C it would be:
The firts thing I need is the “global variable”… how can I create it?
The second thing is the automation that would be:
automation:
alias: Soil status
initial_state: “global_variable”
trigger:
platform: mqtt
event: adc_0
condition:
??? here it will be the if-else if condition
action:
??? depending on the condition global_variable = wet or dry
I don’t know if I have explain myself properly … if not, please ask me and I will try to clarify your doubts.
Not sure if this is exactly what you’re aiming for, but I use a slider as a “number holder” to remember the state of my front porch. This example shows how to set and retrieve the value:
An other solution (it is easier so personally i would go for that) is to do the «calculation» on the ESP and send another mqtt info for wet or not (then simply display it in hass with a template sensor). As the criterion for determining if the soil is wet should be constant and independent of anything else i dont think its absolutely nessecary to implement it in hass
You are right, that will be the easiest way but the problem is that the ESP-12E wakes up for a while to get the data and after that it goes to deep sleep, what means that ram memory is not powered so not possible to implement what you suggest.
But thanks anyway
when your ESP aquire new data, before you send it to you can retrieve the old one from MQTT, perform your calculation, then update the new value and change the value for wet or not… That way, no memory trouble.
You can store variables in the ESP’s flash memory so that when it goes to sleep they can be recovered when it wakes up, search the arduino website, it’s something like …