Store Espeasy State

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
tonse
New user
Posts: 8
Joined: 04 Jan 2017, 15:36

Store Espeasy State

#1 Post by tonse » 04 Mar 2018, 15:21

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

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Store Espeasy State

#2 Post by TD-er » 04 Mar 2018, 17:13

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.

tonse
New user
Posts: 8
Joined: 04 Jan 2017, 15:36

Re: Store Espeasy State

#3 Post by tonse » 04 Mar 2018, 19:28

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

User avatar
vader
Normal user
Posts: 241
Joined: 21 Mar 2017, 17:35

Re: Store Espeasy State

#4 Post by vader » 04 Mar 2018, 20:13

With MQTT it should not be a problem. For me this works and the ESP restores the last state after reboot. ;)

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Store Espeasy State

#5 Post by Domosapiens » 04 Mar 2018, 20:18

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.
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.

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Store Espeasy State

#6 Post by TD-er » 04 Mar 2018, 20:42

Domosapiens wrote: 04 Mar 2018, 20:18 Not supported yet in ESPEasy, but nice ;)
https://nl.aliexpress.com/item/FM24CLXX ... Title=true
[...]
You'll never know ;) https://github.com/letscontrolit/ESPEasy/issues/1011

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

Re: Store Espeasy State

#7 Post by kimot » 05 Mar 2018, 14:39

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.

tonse
New user
Posts: 8
Joined: 04 Jan 2017, 15:36

Re: Store Espeasy State

#8 Post by tonse » 05 Mar 2018, 20:52

Hi kimot
Can you send me the (part of) the LUA script?
Thanks
Ton

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

Re: Store Espeasy State

#9 Post by kimot » 06 Mar 2018, 20:34

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
}

tonse
New user
Posts: 8
Joined: 04 Jan 2017, 15:36

Re: Store Espeasy State

#10 Post by tonse » 25 May 2021, 18:04

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests