@moci and @tom_l You could actually use this method…
Set up a ESP like this (code below) and it will subscribe to the message on the MQTT server, se it when it wakes up and take that value and set it to be the deep sleep duration value. Make sure the value you are sending as the topic however is in milliseconds.
I moved to different projects and didn’t pay attention. I wrote my code for this… But this is great . @runevad Thank you very much for sharing. Appreciate. I’ll try it.
I experiment with @runevad solution. It works for me. However I found some things that I don’t like.
First, here is mine code, it’s basically copy paste:
As you can see I set unit_of_measurement to minutes, but I compensate this in lambda expression.
Problem that I noticed is burst of messages which are catch in MQTT Broker when I listen topic:
I think that this is not related with home assistant part, where I set deep sleep timer just once. I even disabled some automation I have for deep sleep timer.
I would say that sensor on device (mqtt_subscribe) actually enters a loop where it sets state and generate messages over again until board enters deep sleep. Could that be the reason? If so, how could be fixed?
@exiledyorkie I’m curious, if you still have this project working… How long were you able to keep the Wemos alive and reporting on one battery cycle? Thanks for your time! Do you have any pictures as well?
Why no API with deep sleep? Are there known problems with this combination?
It works sort of for me, except that all sensors are most of the time marked as “unknown”, which is a bit annoying (expire_after is only available with mqtt, which I do not use atm)
Hmmm nice to know… . Before (have not tested how it behaves nowadays) the issue was that you can’t get the API to behave with “keep alive”-settings. The moment the ESP goes down to sleep the sensorns and everything gets the state “Unavaliable” in Home Assistant (wich is the correct behaviour with the API since you want to know when the ESP is down).
But… this is not the best for like a weather station or similar projects when you (probably) want the sensors to be set to the latest state until a new value is sent and only be set to the state “Unavailiable” if no new value has been sent for a set period of time, the keep alive-setting.
I essentially use the method described at the below link, which uses API to prevent deep sleep from reoccurring. I haven’t fully implemented my final product, but the deep sleep/prevention works fine. It’s set to delay going back into deep sleep for 10s, and that seems to be plenty of time to connect to the api.
I haven’t played around with it enough to see how low I can get the delay to be, but 10s doesn’t seem that bad to me.
Hi, I’ve just tried to use that link - I got to this thread after trying to do the setup - exactly as described and I just get errors about not being allow to map id: when the yaml is parsed. Can you please share what you have done if it is something different?
I’m working with an esp8266 by that shouldn’t matter as I’m not getting past the binary_sensor/homeassistant config for some reason.
i need some help with deep sleep…
so i what to make doors to open at 7 in the morning and close in evening at 6.
i have “cover” to open and close doors and it already works… BUT… now i would
like to sleep between this two times…
im reading topics but i just dont get it how to set deep sleep to make it work.
(mostly is just wake up every 20min and go back to sleep after 15s)
This is what times when to open and close doors look like right now:
yes i did find this… but didnt figured out where to put it and didnt find any more
detailed example… Do you mind giving me some more details? like do i just put it
in there between times i alredy have or do i need to compleatly replace what i
alredy have,…?
sorry if its a stupid question but i really cant figure it out or find what i am looking
for.