Page 1 of 1
"watchdog" relay
Posted: 06 Dec 2020, 15:15
by miralant
Hi,
Currently I use espeasy on ESP01 to manage relay card. I want to create a rules who can switch off my relay after 20min for example whatever the state of the relay.
ex :
My domoticz call :
http://192.168.1.23/control?cmd=gpio,0,1
>>timer is set ON at 20min.
At the end of the timer, the event set GPIO0 to 0
Thanks for your help.
Re: "watchdog" relay
Posted: 06 Dec 2020, 16:03
by TD-er
There are several ways to do it (all requiring a fairly recent build)
By far the simplest one:
Change your command from "gpio" to "longpulse"
See:
https://espeasy.readthedocs.io/en/lates ... =longpulse
Another option using rules:
First add monitoring to the pin, which does allow you to receive an event in case the pin state changes.
N.B. you also receive the new state as %eventvalue%, but you can also act on a specific state.
See:
https://espeasy.readthedocs.io/en/lates ... ore-events
In the event handling this state change you can set a timer, which will generate an event which you can also act on in the rules to set the GPIO to 0.
Re: "watchdog" relay
Posted: 07 Dec 2020, 09:05
by miralant
TD-er wrote: ↑06 Dec 2020, 16:03
There are several ways to do it (all requiring a fairly recent build)
By far the simplest one:
Change your command from "gpio" to "longpulse"
See:
https://espeasy.readthedocs.io/en/lates ... =longpulse
Another option using rules:
First add monitoring to the pin, which does allow you to receive an event in case the pin state changes.
N.B. you also receive the new state as %eventvalue%, but you can also act on a specific state.
See:
https://espeasy.readthedocs.io/en/lates ... ore-events
In the event handling this state change you can set a timer, which will generate an event which you can also act on in the rules to set the GPIO to 0.
solution long pulse not impossible
Just to be more clear
I use my esp to drive my boiler. domoticz is used to enslave esp to temperature. So I've a lua program who sends every minute 1 or 0 to drive ESP.
my need is simply to have a watch dog in case if my esp loose wifi or domoticz becomes crazy.
1. GPIO change state 0 to 1
2. launch 20 min timer
3. event end of timer => GPIO = 0
Re: "watchdog" relay
Posted: 07 Dec 2020, 09:12
by TD-er
Then you should go for the rules option.
Re: "watchdog" relay
Posted: 11 Dec 2020, 19:31
by miralant
ok, I think I inderstand but I'm a little bit lost.
1. GPIO change state 0 to 1
Code: Select all
How catch 0 to 1 change ?
timerSet,1,1200
2. launch 20 min timer
3. event end of timer => GPIO = 0
Code: Select all
on Rules#Timer=1 do
GPIO,0,0
endon
tks
Re: "watchdog" relay
Posted: 11 Dec 2020, 19:55
by TD-er
See the documentation on the "monitor" command:
https://espeasy.readthedocs.io/en/lates ... ore-events
Code: Select all
on System#Boot do
Monitor GPIO,15
endon
on GPIO#15=0 do
if [Plugin#GPIO#Pinstate#13]=0
// do something
endif
endon
on GPIO#15=1 do
if [Plugin#GPIO#Pinstate#13]=1
// do something
endif
endon
This is the example from the docs, showing how to activate monitoring GPIO 15 and also if it changes, how to check the state of another GPIO (13) and act on it.
See here for documentation on "timerset":
https://espeasy.readthedocs.io/en/lates ... rset#timer
So this can be combined into something like this:
Code: Select all
on System#Boot do
Monitor GPIO,15
endon
on GPIO#0=1 do
timerSet,1,20 // Set timer to 20 seconds
endon
On Rules#Timer=1 do
GPIO,0,0
endon
Re: "watchdog" relay
Posted: 13 Dec 2020, 19:09
by miralant
Thanks, I've activate rules menu and try :
Code: Select all
on System#Boot do
Monitor GPIO,0
endon
on GPIO#0=1 do
timerSet,1,20 // Set timer to 20 seconds
endon
On Rules#Timer=1 do
GPIO,0,0
endon
But nothing happens after 20s switching ON GPIO0 and nothing in logs (only "694884 : WD : Uptime 11 ConnectFailures 0 FreeMem 28544")
I'm on
Build: 120
Core Version: 2_3_0
Re: "watchdog" relay
Posted: 13 Dec 2020, 19:30
by TD-er
Ah build 120, that one is ancient and does not support "monitor" and likely other calls may also not yet work as they do now.
Can you please try a build which isn't like 3 years old?
See:
https://github.com/letscontrolit/ESPEasy/releases
Re: "watchdog" relay
Posted: 14 Dec 2020, 08:47
by miralant
of course.
Is there a specific build for Puya version ? I remember that it was a specific for R120.
Re: "watchdog" relay
Posted: 14 Dec 2020, 09:12
by TD-er
All builds should be able to handle Puya chips as it has been integrated in the esp8266/Arduino core since 2.5.x
Re: "watchdog" relay
Posted: 16 Dec 2020, 19:43
by miralant
I've update firmware to
Code: Select all
Build:⋄ 20111 - Mega
System Libraries:⋄ ESP82xx Core 2843a5ac, NONOS SDK 2.2.2-dev(38a443e), LWIP: 2.1.2 PUYA support
Git Build:⋄
Plugin Count:⋄ 46 [Normal]
Build Origin: Travis
Build Time:⋄ Nov 30 2020 00:37:49
Binary Filename:⋄ ESP_Easy_mega_20201130_normal_ESP8266_1M
Build Platform:⋄ Linux-4.19.104-microsoft-standard-x86_64-with-glibc2.29
Git HEAD:⋄ mega-20201130_f4f960c
see logs bellow :
Code: Select all
890624: HTTP: gpio,0,0
890626: GPIO : port#0: set to 0
895338: HTTP: gpio,0,1
895340: GPIO : port#0: set to 1
903763: WD : Uptime 15 ConnectFailures 0 FreeMem 20728 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
928620: EVENT: Clock#Time=Thu,00:16
933753: WD : Uptime 16 ConnectFailures 0 FreeMem 24080 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
nothing happens after switching On GPIO0
I've some strange connection failures but I can connect to it...
Re: "watchdog" relay
Posted: 23 Dec 2020, 20:40
by miralant
I apologies
It works !!
So, I've try to add a return status to domoticz by calling API.
Code: Select all
SendToHTTP domoticz,8080,/json.htm?type=command[b]¶[/b]m=switchlight&idx=88&switchcmd=On
>>
Code: Select all
12584300: ACT : SendToHTTP domoticz,8080,/json.htm?type=command[b]¶[/b]m=switchlight&idx=88&switchcmd=On
but something goes wrong, ¶m is not correctly sends to http.
Re: "watchdog" relay
Posted: 23 Dec 2020, 20:59
by Ath
miralant wrote: ↑23 Dec 2020, 20:40
Code: Select all
12584300: ACT : SendToHTTP domoticz,8080,/json.htm?type=command[b]¶[/b]m=switchlight&idx=88&switchcmd=On
but something goes wrong, ¶m is not correctly sends to http.
If you got this log from the web-interface: Nothing is going wrong, that's just the web-log page doing its 'thing' replacing ¶ with a paragraph sign, that's a known 'feature'.
Why not send the state to Domoticz using a Controller? Way easier and less error-prone. For a simple one-way status update, Domoticz HTTP is fine.
From an older message:
miralant wrote:
Code: Select all
WD : Uptime 16 ConnectFailures 0 FreeMem 24080 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
...
I've some strange connection failures but I can connect to it...
It says: Uptime 16 (minutes), Connection failures: 0 ...
Again, nothing to worry about
Re: "watchdog" relay
Posted: 23 Dec 2020, 21:06
by miralant
Ath wrote: ↑23 Dec 2020, 20:59
miralant wrote: ↑23 Dec 2020, 20:40
Code: Select all
12584300: ACT : SendToHTTP domoticz,8080,/json.htm?type=command[b]¶[/b]m=switchlight&idx=88&switchcmd=On
but something goes wrong, ¶m is not correctly sends to http.
If you got this log from the web-interface: Nothing is going wrong, that's just the web-log page doing its 'thing' replacing ¶ with a paragraph sign, that's a known 'feature'.
Why not send the state to Domoticz using
Sure but I've a specific need. That's why I want to use API. So if it's not an issue, I've to investigate on my domoticz to understand why it does not work.
Re: "watchdog" relay
Posted: 23 Dec 2020, 21:13
by TD-er
miralant wrote: ↑23 Dec 2020, 20:40
I apologies
It works !!
So, I've try to add a return status to domoticz by calling API.
Code: Select all
SendToHTTP domoticz,8080,/json.htm?type=command[b]¶[/b]m=switchlight&idx=88&switchcmd=On
>>
Code: Select all
12584300: ACT : SendToHTTP domoticz,8080,/json.htm?type=command[b]¶[/b]m=switchlight&idx=88&switchcmd=On
but something goes wrong, ¶m is not correctly sends to http.
You actually send the url with the forum bold tags?
Here without the bold tags:
Code: Select all
SendToHTTP domoticz,8080,/json.htm?type=command¶m=switchlight&idx=88&switchcmd=On
Re: "watchdog" relay
Posted: 23 Dec 2020, 21:15
by miralant
TD-er wrote: ↑23 Dec 2020, 21:13
miralant wrote: ↑23 Dec 2020, 20:40
I apologies
It works !!
So, I've try to add a return status to domoticz by calling API.
Code: Select all
SendToHTTP domoticz,8080,/json.htm?type=command[b]¶[/b]m=switchlight&idx=88&switchcmd=On
>>
Code: Select all
12584300: ACT : SendToHTTP domoticz,8080,/json.htm?type=command[b]¶[/b]m=switchlight&idx=88&switchcmd=On
but something goes wrong, ¶m is not correctly sends to http.
You actually send the url with the forum bold tags?
Here without the bold tags:
Code: Select all
SendToHTTP domoticz,8080,/json.htm?type=command¶m=switchlight&idx=88&switchcmd=On
No
I've use bold to focus on the issue between code and log
Re: "watchdog" relay
Posted: 24 Dec 2020, 12:04
by miralant
let me gave us more information.
when I launch :
Code: Select all
http://domoticz:8080/json.htm?type=command¶m=switchlight&idx=88&switchcmd=On
> my switch is set to ON
on the rules :
Code: Select all
On Rules#Timer=1 do
GPIO,0,0
SendToHTTP domoticz,8080,/json.htm?type=command¶m=switchlight&idx=88&switchcmd=On
endon
the log resultin :
Code: Select all
68307215: HTTP: gpio,0,1
68307217: GPIO : port#0: set to 1
68307225: EVENT: GPIO#0=1
68307231: ACT : timerSet,1,5
68312233: EVENT: Rules#Timer=1,1
68312241: ACT : GPIO,0,0
68312242: GPIO : port#0: set to 0
68312245: ACT : SendToHTTP domoticz,8080,/json.htm?type=command¶m=switchlight&idx=88&switchcmd=On
68312319: EVENT: GPIO#0=0
Event is fired but switch is not set to ON
Re: "watchdog" relay
Posted: 24 Dec 2020, 12:36
by Ath
Does your Domoticz require a username/password to be able to get access? Most likely it does, and your browser is quietly providing those to Domoticz, so there it will work.
When sending commands to Domoticz from other sources, like ESPEasy, the username & password need to be supplied (base64 encoded) as arguments in the url:
Code: Select all
SendToHTTP,domoticz,8080,/json.htm?username=BASE64USERNAME&password=BASE64PASSWORD&type=command¶m=switchlight&idx=%eventvalue1%&switchcmd=On
AFAICS, the base64 has to include padding.
Re: "watchdog" relay
Posted: 24 Dec 2020, 13:11
by miralant
Yes, I've credentials to access to front of Domoticz. But to access to json, I'm not sure. I remember that I've sh where I push credentials in url (for IFTTT). I dont know why but I was thinking that from local (192.168.x.x) it will need no credentials
.
Just a question, concerning credentials.
In some example, Username and passeword are sent in before URL :
Code: Select all
http://username:pwd@domoticz:8080/json.htm?type=command¶m=switchlight&idx=88&switchcmd=On&level=0&passcode=
and in other case, like you're exemple with pwd and username in base 64 directly to json.
Code: Select all
http://username:pwd@domoticz:8080/json.htm?username=BASE64USERNAME&password=BASE64PASSWORD&type=command¶m=switchlight&idx=88&switchcmd=On
It's the same results ?
Re: "watchdog" relay
Posted: 24 Dec 2020, 13:28
by Ath
Haven't tried to authenticate with username:pwd@domoticz but I'd assume that's not directly supported by ESPEasy, so the &username= and &password= arguments in the url is easy to apply, just use Notepad++ with the MIME Tools plugin (installed by default, I think, not sure) or an on-line service will provide you with something useful, f.e. admin will translate to YWRtaW4= so you use that result (with the = padding included) in the url.
Re: "watchdog" relay
Posted: 27 Dec 2020, 08:26
by miralant
works like a charm by pusching credentials to json.
Thanks for your help
Re: "watchdog" relay
Posted: 06 Feb 2021, 19:06
by miralant
Hi,
Just to add new technology to my domoticz and acquire new skills
, I've mount MQTT server (mosquitto) and connects my espeasy to domoticz with MQTT.
It works like a charm but i've a question
My rules is like that :
Code: Select all
on System#Boot do
Monitor GPIO,0
endon
on GPIO#0=1 do
timerSet,1,5 // Set timer to 5 seconds
endon
On Rules#Timer=1 do
GPIO,0,0
SendToHTTP domoticz,8080,/json.htm?username=xxx&password=yyyy&type=command¶m=switchlight&idx=88&switchcmd=Off&level=0&passcode=
endon
as you can see, at the end of the timer, the return state is made with json request. Sure it works but how can I do the same with MQTT to be consistent ?
Thanks
Re: "watchdog" relay
Posted: 06 Feb 2021, 19:17
by Ath
This is where the Domoticz MQTT Controller comes in
- Configure the Domoticz MQTT Controller using the correct username/password
- Lookup in Domoticz what the matching Dummy device's IDX is
- In ESPEasy set up a Switch device using GPIO-0.
- Enable the Controller on the Device Configuration for the switch using the IDX obtained before
That should report the status to Domoticz, using the Domoticz/in topic, no need to report status every time, it will be sent when status changes (both on and off).
Re: "watchdog" relay
Posted: 06 Feb 2021, 19:27
by miralant
That's exactly what I did.
When I click on the dummy device in domoticz (Switch), the GPio is set to 1 (and Relay click
).
But when the timer sets GPio to 0, in domoticz the switch does not change state.
Re: "watchdog" relay
Posted: 06 Feb 2021, 21:38
by Ath
miralant wrote: ↑06 Feb 2021, 19:27
But when the timer sets GPio to 0, in domoticz the switch does not change state.
That's exactly what the Controller selection (and IDX) on the Device configuration page is for... quite surprising you can't get it working, as it is exactly how I set up my Sonoff S20's to make them work reliably. And they react to and show their state however I change the relay GPIO state.
For controlling a GPIO pin on an ESP, I use the Domoticz MQTT Helper plugin to set the relay in the correct state. (That also takes an IDX, and expects the Domoticz MQTT Controller active.)
Re: "watchdog" relay
Posted: 07 Feb 2021, 00:41
by TD-er
See here for more info on the Domoticz Helper plugin:
https://espeasy.readthedocs.io/en/lates ... #p029-page
Re: "watchdog" relay
Posted: 07 Feb 2021, 16:47
by miralant
Thanks for your help.
I only had created the Domoticz MQTT Helper not the Switch input. That's why return stat does not work I think.
really thanks!