Store Espeasy State
Moderators: grovkillen, Stuntteam, TD-er
Store Espeasy State
I have Esp8266 relay in Spain. Elektricity and Wifi are a bit unreliable.
SO i give the esp8266 commands with user variables. PumpSchedule=1
Depending on the number i want to make an on/off schedule that is totally run on the esp itself. No other commands would be needed, so the epseay functions standalone. It only reports through MQTT or HTTP the on/off state. This i can manage.
QUestion is: How can i "store" the eventvalue, so i can run the correct schedule after a powerloss (=reboot) using on System#boot.
I use domoticz and i am considering moving to homeAssistant. This depends on the ability of either one of them to support the storage of a state and the ability of espeasy to "ask" the current state to either Domoticz or HomeAssistant. THis is the second best option. The best would be: The value is stored locally on the ESP
SO i give the esp8266 commands with user variables. PumpSchedule=1
Depending on the number i want to make an on/off schedule that is totally run on the esp itself. No other commands would be needed, so the epseay functions standalone. It only reports through MQTT or HTTP the on/off state. This i can manage.
QUestion is: How can i "store" the eventvalue, so i can run the correct schedule after a powerloss (=reboot) using on System#boot.
I use domoticz and i am considering moving to homeAssistant. This depends on the ability of either one of them to support the storage of a state and the ability of espeasy to "ask" the current state to either Domoticz or HomeAssistant. THis is the second best option. The best would be: The value is stored locally on the ESP
Re: Store Espeasy State
I guess it would be best to add a rule to restore the desired situation using the on reboot event.
And when set, allow the timer based rules to process.
Especially with operating a pump, you don't want to have the incorrect state on for hours.
And when set, allow the timer based rules to process.
Especially with operating a pump, you don't want to have the incorrect state on for hours.
Re: Store Espeasy State
That I Know. I try to clearify it a bit more
Scheme1: Pump 1 hour a day
Scheme2: Pump 4 hourse a day
Scheme3: Pump 2x2 hours a day
Scheme4: Pump 8 hours a day
Question is: How do i return to my previouw Scheme. How can i have the Esp "remember" which scheme it was is before the powerloss
Scheme1: Pump 1 hour a day
Scheme2: Pump 4 hourse a day
Scheme3: Pump 2x2 hours a day
Scheme4: Pump 8 hours a day
Question is: How do i return to my previouw Scheme. How can i have the Esp "remember" which scheme it was is before the powerloss
Re: Store Espeasy State
With MQTT it should not be a problem. For me this works and the ESP restores the last state after reboot. 

-
- Normal user
- Posts: 307
- Joined: 06 Nov 2016, 13:45
Re: Store Espeasy State
Not supported yet in ESPEasy, but nice
https://nl.aliexpress.com/item/FM24CLXX ... Title=true
Or .. Wemos D1 with battery shield?
In Spain ... maintained by a solar cell.

https://nl.aliexpress.com/item/FM24CLXX ... Title=true
Or .. Wemos D1 with battery shield?
In Spain ... maintained by a solar cell.
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.
Re: Store Espeasy State
You'll never knowDomosapiens wrote: ↑04 Mar 2018, 20:18 Not supported yet in ESPEasy, but nice![]()
https://nl.aliexpress.com/item/FM24CLXX ... Title=true
[...]

Re: Store Espeasy State
I have got the same problem with my ESPeasy thermostat.
Not only power loss, but randomly reboot.
So I am sending correct values every minutes from Domoticz to ESPeasy through LUA scripts.
If I was not lazy:
I define user variable "ESP_003_BOOT" in Domoticz and set it to 0.
When ESPeasy boots, I change this variable to 1 via JSON API.
Domoticz script detects this change and sends actual values to ESP and resets variable back to 0.
Not only power loss, but randomly reboot.
So I am sending correct values every minutes from Domoticz to ESPeasy through LUA scripts.
If I was not lazy:
I define user variable "ESP_003_BOOT" in Domoticz and set it to 0.
When ESPeasy boots, I change this variable to 1 via JSON API.
Domoticz script detects this change and sends actual values to ESP and resets variable back to 0.
Re: Store Espeasy State
Hi kimot
Can you send me the (part of) the LUA script?
Thanks
Ton
Can you send me the (part of) the LUA script?
Thanks
Ton
Re: Store Espeasy State
dzVents:
Code: Select all
-- Check the wiki at
-- http://www.domoticz.com/wiki/%27dzVents%27:_next_generation_LUA_scripting
return {
-- 'active' controls if this entire script is considered or not
active = true, -- set to false to disable this script
-- trigger
-- can be a combination:
on = {
timer = {
-- timer triggers.. if one matches with the current time then the script is executed
'every minute',
}
},
-- actual event code
-- in case of a timer event or security event, device == nil
execute = function(domoticz)
--[[
The domoticz object holds all information about your Domoticz system. E.g.:
local myDevice = domoticz.devices('myDevice')
local myVariable = domoticz.variables('myUserVariable')
local myGroup = domoticz.groups('myGroup')
local myScene = domoticz.sceneds('myScene')
The device object is the device that was triggered due to the device in the 'on' section above.
]] --
-- example
local HDO_PV = domoticz.devices('HDO-PV')
-- Kacka
local urlHDO = 'http://192.168.1.102/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Filip
local urlHDO = 'http://192.168.1.105/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
--Kuchyne
local urlHDO = 'http://192.168.1.103/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
--Obyvak
local urlHDO = 'http://192.168.1.104/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Kacka
local setpoint = domoticz.devices('Kacka_Setpoint')
local url= 'http://192.168.1.102/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
local mode = domoticz.devices('Kacka_Control')
local url2= 'http://192.168.1.102/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- Filip
local setpoint = domoticz.devices('Filip_Setpoint')
local url= 'http://192.168.1.105/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
local mode = domoticz.devices('Filip_Control')
local url2= 'http://192.168.1.105/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- Kuchyne
local setpoint = domoticz.devices('Kuchyne_Setpoint')
local url= 'http://192.168.1.103/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
local mode = domoticz.devices('Kuchyne_Obyvak_Control')
local url2= 'http://192.168.1.103/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- Obyvak nastaveni stejne jako pro kuchyn, nema vlastni ovladani
local setpoint = domoticz.devices('Kuchyne_Setpoint')
local url= 'http://192.168.1.104/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
local mode = domoticz.devices('Kuchyne_Obyvak_Control')
local url2= 'http://192.168.1.104/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- do something
end
}
Re: Store Espeasy State
HI
I finally managed and like to have some comment
1. I can set startingtimes and durations of a pump relay
2. In nodered i gather al the values and compose a rules2.txt file
Rules2.txt begins with: On NewValues do
...
in the event I set 4 values in 2 dummy devices. (total of 8 values)
3. I send the rules2.txt to the espeasy with a POST command
4 i call Event, Newvalues (as i also do on system#reboot)
5 in Rules1 all the events with the dunnydevice values are handled.
What did i achieve:
I can reschedule the esp and even after a powerloss and connection failures aftwer reboort that sometimes happen, i have a more or less standalone working device.
I finally managed and like to have some comment
1. I can set startingtimes and durations of a pump relay
2. In nodered i gather al the values and compose a rules2.txt file
Rules2.txt begins with: On NewValues do
...
in the event I set 4 values in 2 dummy devices. (total of 8 values)
3. I send the rules2.txt to the espeasy with a POST command
4 i call Event, Newvalues (as i also do on system#reboot)
5 in Rules1 all the events with the dunnydevice values are handled.
What did i achieve:
I can reschedule the esp and even after a powerloss and connection failures aftwer reboort that sometimes happen, i have a more or less standalone working device.
Who is online
Users browsing this forum: No registered users and 13 guests