Hello to all, i've tried to search on the forum but I have not found a clear solution.
I have this scenario:
Domoticz 3.8153 on a raspberry pi
1 esp8266 flashed with esp easy v2.0.0-dev12 and a 4 relay modules
for now i've configured only 1 relay, but the problem is simple, i can control the relay using the domoticz web page using:
http://esp_ip_addr/control?cmd=GPIO,0,0
http://esp_ip_addr/control?cmd=GPIO,0,0
and all works fine, but if i reboot the esp, the relay state it is not mantained.
I think that the best solution is to ask at the domoticz controller to give me the state of that relay but i'm not able to do that
Anyone can help me?
EspEasy,relay recovery the last state after power failure
Moderator: leecollings
Re: EspEasy,relay recovery the last state after power failure
This is why i use MQTT with retained messages. If the ESP module is rebooted, loses connection and re-connects to the broker, the broker sends the last 'known state' to my relay. Even if domoticz changes the state during the disconnect state, the relay is updated with this last state.
-
- Posts: 2
- Joined: Wednesday 29 November 2017 0:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: EspEasy,relay recovery the last state after power failure
Ok i know this possibility but i'm not able to configure that...i have done in this waySweetPants wrote: ↑Wednesday 29 November 2017 8:17 This is why i use MQTT with retained messages. If the ESP module is rebooted, loses connection and re-connects to the broker, the broker sends the last 'known state' to my relay. Even if domoticz changes the state during the disconnect state, the relay is updated with this last state.
IN DOMOTICZ
In Hadware i have set this: but i don't know how to set the actions for power on and power off (this is the device with idx 1) IN ESP: i have this configuration, but the log (last picture) give me that error
-
- Posts: 105
- Joined: Saturday 25 November 2017 17:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: v3.8153
- Location: Czech Rep.
- Contact:
Re: EspEasy,relay recovery the last state after power failure
I am using ESPEasy too.
For setting ESPeasy state according Domoticz after rebooting, I send status every minute to ESPEasy through LUA or dzVents.
Here is example for resending actual thermostat setpoint.
Setpoint is send immediately when changed :
And then every 60 seconds with other information for others sensors too:
( look at "HDO_PV" - it is switch in domoticz and its state is send to ESPEasy every minute too)
This way I have got actual state of ESPEasy within 1 minute after reboot.
For setting ESPeasy state according Domoticz after rebooting, I send status every minute to ESPEasy through LUA or dzVents.
Here is example for resending actual thermostat setpoint.
Setpoint is send immediately when changed :
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 = {
devices = {
-- timer triggers.. if one matches with the current time then the script is executed
'Kacka_Setpoint'
}
},
-- actual event code
-- in case of a timer event or security event, device == nil
execute = function(domoticz, device)
--[[
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
--if (device.name == 'Vychod_Setpoint') then
-- local DomValue=device.state
-- print(device.state)
-- local CalcValue = (DomValue*1)
-- print(CalcValue)
local url= 'http://192.168.1.102/control?cmd=event,HeatSetpoint='..(device.state)..''
print(url)
domoticz.openURL(url)
-- end
--if (device.name == 'Vychod_Control') then
-- local DomValue=device.level
-- print(device.level)
-- local CalcValue = (DomValue*1)
-- print(CalcValue)
-- local url= 'http://192.168.1.102/control?cmd=event,modeSet='..(device.level)..''
-- print(url)
-- domoticz.openURL(url)
--end
--commandArray['OpenURL']= url
-- do something
end
( look at "HDO_PV" - it is switch in domoticz and its state is send to ESPEasy every minute too)
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)
--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)
-- 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
RPi2 Domoticz v 4.10717
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
Who is online
Users browsing this forum: No registered users and 1 guest