Store values between reboots

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
leel1967l
Normal user
Posts: 73
Joined: 30 Nov 2017, 18:29

Store values between reboots

#1 Post by leel1967l » 13 Mar 2018, 12:16

Hi all,
I wonder if it possible to store a value (in a dummy task) that will survive after a reboot.

I was thinking about an external SD card:
https://wiki.wemos.cc/products:d1_mini_ ... ard_shield

Is it supported?

Any other idea?

thanks

moebius
Normal user
Posts: 35
Joined: 22 May 2017, 19:36

Re: Store values between reboots

#2 Post by moebius » 13 Mar 2018, 12:36

You could use the mqtt feature "retain" to store values in combination with the mqtt import plugin.

leel1967l
Normal user
Posts: 73
Joined: 30 Nov 2017, 18:29

Re: Store values between reboots

#3 Post by leel1967l » 13 Mar 2018, 13:08

moebius wrote: 13 Mar 2018, 12:36 You could use the mqtt feature "retain" to store values in combination with the mqtt import plugin.
Hi,
thanks for the answer.

I have some questions:
How does it work?
Is it a global parameter?
When the value is restored? After boot?
Where does it stores the value?
Does it store the value everytime there it is published or only when it changes?
What are the implications on the life of the Flash Memory?

thanks

moebius
Normal user
Posts: 35
Joined: 22 May 2017, 19:36

Re: Store values between reboots

#4 Post by moebius » 13 Mar 2018, 14:05

>How does it work?
First, you need an mqtt broker for that solution.

>Is it a global parameter?
"mqtt retain msg" is a global advanced setting

>When the value is restored? After boot?
The value is restored after reboot, when the mqtt import plugin subscribes to a specific topic.

>Where does it stores the value?
in the mqtt broker

>Does it store the value everytime there it is published or only when it changes?
you can to publish the value via a rule to control the moment it is stored

>What are the implications on the life of the Flash Memory?
0

leel1967l
Normal user
Posts: 73
Joined: 30 Nov 2017, 18:29

Re: Store values between reboots

#5 Post by leel1967l » 13 Mar 2018, 14:15

moebius wrote: 13 Mar 2018, 14:05 >How does it work?
First, you need an mqtt broker for that solution.

>Is it a global parameter?
"mqtt retain msg" is a global advanced setting

>When the value is restored? After boot?
The value is restored after reboot, when the mqtt import plugin subscribes to a specific topic.

>Where does it stores the value?
in the mqtt broker

>Does it store the value everytime there it is published or only when it changes?
you can to publish the value via a rule to control the moment it is stored

>What are the implications on the life of the Flash Memory?
0
ok. thanks.
Now I understand it better.

But that is not what I need.

Assuming a thermostat (ESP1) and a device that controls the heating (ESP2).
I would like the ESP2 device to be fully independant in case any major failure occurs (such as wifi or router failure, power failure, reboot, etc)

So I need a way to store in the ESP2 device the temperature set in ESP1 and in case of reboot the ESP2 needs to restore the previous setting and restart his heating control.

Any idea?

moebius
Normal user
Posts: 35
Joined: 22 May 2017, 19:36

Re: Store values between reboots

#6 Post by moebius » 13 Mar 2018, 14:42

If there are already 2 devices involved, a router or wifi problem will also cause a failure...also if the measurement device does not work anymore. For that case, you need something like a heartbeat in the whole process.

Easiest way would be, to boot the heating device with a save setting - i assume you have a hardware safeguard also (like a bi-metal switch on the heating device).
I dont know of a way to save a value in flash and restore it at boot - you could take a look at micropython (there you have the ability to write and read files, etc)

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Store values between reboots

#7 Post by grovkillen » 13 Mar 2018, 15:03

This might come in handy in the future: https://github.com/letscontrolit/ESPEasy/issues/1011
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

kimot
Normal user
Posts: 190
Joined: 12 Oct 2017, 20:46

Re: Store values between reboots

#8 Post by kimot » 14 Mar 2018, 23:41

Dummy devices are persistent through reboot.
So you must find solution only for power lost.
First - backup battery.
Second:
Something like my solution for independent thermostat with Domoticz setting and logging only.
I am booting into safe setting for heater.
Setpoint and regulation rules are stored in ESPeasy thermostat ( so it works independently on Domoticz )
and setpoint in Domoticz too.
Domoticz sends this setpoint periodically to thermostat every minute.
So after one minute after power on, thermostat obtains correct setpoint.
You can ask controller for setpoint only when booting too, to eliminate periodical sending.

JamesSullivan
New user
Posts: 1
Joined: 09 Apr 2018, 11:47

Re: Store values between reboots

#9 Post by JamesSullivan » 09 Apr 2018, 12:22

leel1967l wrote: 13 Mar 2018, 14:15
moebius wrote: 13 Mar 2018, 14:05 >How does it work?
First, you need an mqtt broker for that solution.

>Is it a global parameter?
"mqtt retain msg" is a global advanced setting

>When the value is restored? After boot?
The value is restored after reboot, when the mqtt import plugin subscribes to a specific topic.

>Where does it stores the value?
in the mqtt broker

>Does it store the value everytime there it is published or only when it changes?
you can to publish the value via a rule to control the moment it is stored

>What are the implications on the life of the Flash Memory?
0
ok. thanks.
Now I understand it better.

But that is not what I need.

Assuming a thermostat (ESP1) and a device that controls the heating (ESP2).
I would like the ESP2 device to be fully independant in case any major failure occurs (such as wifi or router failure, power failure, reboot, etc)

So I need a way to store in the ESP2 device the temperature set in ESP1 and in case of reboot the ESP2 needs to restore the previous setting and restart his heating control.

Any idea?
I love to use standby automatic generator because it not only will the system power far more devices and appliances than a portable model, but it will also kick on automatically in the event of a power outage.

jgrad
Normal user
Posts: 92
Joined: 29 Aug 2016, 22:03
Location: Slovenia

Re: Store values between reboots

#10 Post by jgrad » 30 Oct 2020, 11:30

I would prefer following solution for keeping configuration which does not change often.

in dummy device (where you can keep up to 4 values) to add configuration if values are selected dummy device are persisted on local file system (similar as rules). And new values to be stored on local file system only if changed to those values already stored.

This can be (IMHO) good solution for keeping configuration parameters which does not change often and you can change such parameters via MQTT.

Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests