Hello to all! I managed to implement data storage using a dummy "Regulator - Level Control" device.
This device has one parameter stored in non-volatile memory.
https://www.letscontrolit.com/wiki/inde ... velControl
Parameter read and write commands are supported:
write
Code: Select all
config,task,<taskname>,setlevel,<value|calculation>
and read
My thermostat project uses 2 temperature settings - day and night, so i used two dummy "Regulator - Level Control".
Its names - TempDayNV and TempNightNV.
In settings in device must be:
GPIO → Level low: - Left NONE, its true dummy regulator!!
Check Task: - select any task, no matter what.
Check Value: - also any.
Set Level: - this is valye of stored parameter, you can predefine it.
This is how the parameters are read at the start of the board:
Code: Select all
on System#Boot do
TaskValueSet,DefaultTemperature,Day,[TempDayNV#getLevel]
TaskValueSet,DefaultTemperature,Night,[TempNightNV#getLevel]
TaskValueSet,Variables,ManualTemperature,[TempDayNV#getLevel]
endon
This is how the parameters are written to non-volatile memory:
Code: Select all
on Clock#Time=All,**:** do
if [DefaultTemperature#Day] <> [TempDayNV#getLevel]
config,task,TempDayNV,setlevel,[DefaultTemperature#Day]
endif
if [DefaultTemperature#Night] <> [TempNightNV#getLevel]
config,task,TempNightNV,setlevel,[DefaultTemperature#Night]
endif
endon
So every minute check, if parameter changed, and save if need. Not immediately!
This is how the dashboard.esp controls work:
Code: Select all
<table>
<caption>Default Temperature</caption>
<tr>
<th>Day=[DefaultTemperature#Day]C</th>
<th>Night=[DefaultTemperature#Night]C</th>
</tr>
<tr>
<td><a class='button link' href="dashboard.esp?cmd=event,DayTemperatureUp">+0.1C</a></td>
<td><a class='button link' href="dashboard.esp?cmd=event,NightTemperatureUp">+0.1C</a></td>
</tr>
<tr>
<td><a class='button link' href="dashboard.esp?cmd=event,DayTemperatureDown">-0.1C</a></td>
<td><a class='button link' href="dashboard.esp?cmd=event,NightTemperatureDown">-0.1C</a></td>
</tr>
</table>
These are the dashboard control handlers:
Code: Select all
on DayTemperatureUp do
TaskValueSet 5,1,[DefaultTemperature#Day]+0.1
endon
on DayTemperatureDown do
TaskValueSet 5,1,[DefaultTemperature#Day]-0.1
endon
on NightTemperatureUp do
TaskValueSet 5,2,[DefaultTemperature#Night]+0.1
endon
on NightTemperatureDown do
TaskValueSet 5,2,[DefaultTemperature#Night]-0.1
endon
TaskValueSet 5,2 and TaskValueSet 5,1 (TaskValueSet,DefaultTemperature,Day, TaskValueSet,DefaultTemperature,Night) - this is simple "Generic - Dummy Device", used for variables.
The above method has been tried and tested and works well.
I also tried to save the configuration directly from the dashboard, but apparently this operation takes a lot of processor time, the processor freezes, and the loading of the dashboard page is interrupted, although the parameters are saved.