not saving/loading current position on reboot #14
Description
Hi there, first, let me say thank you for this. I've been looking for something similar for several months now. I had resigned myself to using servos, which was VERY hit/miss with respect to the position it opened to/stopped at plus, was an all or nothing (up/down).
Now that I've got this all up and running, when it loads back up, and I restart the web interface, it doesn't load its previously saved 'current position'. I query whether this is due to the fact that the mqtt messages aren't being retained? But honestly, have no idea about how to start looking at this!
This wouldn't be a problem, but for the fact that I kill the power to them when they are down (ie - at MAX). If I killed it when they're up, it saves the relative position fine and once I put it up, it goes down fine, but want it to think it starts at 100, rather than 0.
Hope that makes sense -
Here's a copy of the code from serial monitor:
*WM: Connection result:
*WM: 3
*WM: IP Address:
*WM: 192.168.1.94
MDNS responder started
Connect to http://Blind2.0_test.local or http://192.168.1.94
Registering MQTT server
Attempting MQTT connection...connected
Trying to send msg.../raw/esp8266/register:{ "id": "1386893", "ip":"192.168.1.94"}
Subscribed to /raw/esp8266/1386893/in
[0] get Text: (update)
Trying to send msg.../raw/esp8266/1386893/out:{ "set":0, "position":0 }
[0] get Text: 100
Trying to send msg.../raw/esp8266/1386893/out:{ "set":100, "position":0 }
Trying to send msg.../raw/esp8266/1386893/out:{ "set":100, "position":100 }
Stopped. Reached wanted position
Saved JSON to SPIFFS
{"currentPosition":5876,"maxPosition":5876,"config_name":"Blind2.0_test","mqtt_server":"hidden","mqtt_port":"1883","mqtt_uid":"hidden","mqtt_pwd":"hidden","config_rotation":}
then I kill power, then this pops back up:
*WM: Connection result:
*WM: 3
*WM: IP Address:
*WM: 192.168.1.94
MDNS responder started
Connect to http://Blind2.0_test.local or http://192.168.1.94
Registering MQTT server
Attempting MQTT connection...connected
Trying to send msg.../raw/esp8266/register:{ "id": "1386893", "ip":"192.168.1.94"}
Subscribed to /raw/esp8266/1386893/in
[0] get Text: (update)
Trying to send msg.../raw/esp8266/1386893/out:{ "set":0, "position":0 }
Any help/guidance would be appreciated.
EDIT: upon further invesitgatin, I can confirm that the MQTT message of current position is not being saved (I'm not sure how to get it to store/load dictionary values?). When it reboots, it loads up as if it is at position 0. Any idea how I can get this to be retained by the mqtt server, or, upon reboot, get it to send a msg { "set":(retained value), "position":(retained value) } so the output is 'stopped motor, reached desired position' which effectively resolves my issue?
Alternatively, some way to program deep sleep into it, so it doesn't pull through so much power?