Page 1 of 1

Re: Check ESP-01/12 Online Status

Posted: Thursday 23 November 2017 10:40
by sisaenkov
Crash123 wrote: Thursday 23 November 2017 7:11 Hello,

sometimes my ESP´s get lost. I do not sure whether the ESP lost the wifi connection or my wifi modem lost the esp´s.
So how could I check whether they are online or not? If they get lost, domoticz should push my a pushbullet message. Pushbullet is already working on my system.

Thanking you in Advance for your support!
1. Do you call ESP by hostname or IP-address?

2. In my case if I restart router without restarting Wi-Fi AP (UniFi), then the router lost ESP hostname and IP-address (given by DHCP) matching, and I can't reach it by hostname. Fixed it by setting static record for ESP hostname. I check my ESP in Zabbix. You can check it by cron with bash-sctipt like this:

Code: Select all

#!/bin/bash

ping -c2 172.16.1.101

if [[ $? -eq 0 ]]; then
	DO SOMETHING via Domoticz API;
fi

Re: Check ESP-01/12 Online Status

Posted: Thursday 23 November 2017 11:30
by sisaenkov
You can change ping checking by curl:

Code: Select all

curl -m 2 -iks http://192.168.5.15:80 | grep '200 OK'

Re: Check ESP-01/12 Online Status

Posted: Monday 27 November 2017 14:59
by woody4165
In this case you will have Ping device changed by the last value of the last IP address.

You should create one device for each IP address you are going to ping and then use

Code: Select all

commandArray['Ping_x']=state
where x is a progressive number.
Or just use for each device a name that identifies the pinged address.

Re: Check ESP-01/12 Online Status

Posted: Tuesday 28 November 2017 9:40
by inzuno
Hello,

If you use ESPeasy , there's an easy way to report ip and many status to domoticz check here:
https://www.letscontrolit.com/wiki/inde ... rial_Rules
https://www.letscontrolit.com/wiki/inde ... using_MQTT

And I used the Domoticz Json URLS: https://www.domoticz.com/wiki/Domoticz_ ... _variables

Personnaly I made this rules:

Code: Select all

On System#Boot do    //When the ESP boots, do
  SendToHTTP DomoticzIPorHostnameHere,8080,/json.htm?type=command&param=updateuservariable&vname=YourUserVariableHere&vtype=2&vvalue=%ip%
  SendToHTTP DomoticzIPorHostnameHere,8080,/json.htm?type=command&param=udevice&idx=123456789&nvalue=0&svalue=%ip%
timerSet,1,3600      //Set Timer 1 for the next event in x seconds
endon

On Rules#Timer=1 do  //When Timer1 expires, do
  SendToHTTP DomoticzIPorHostnameHere,8080,/json.htm?type=command&param=updateuservariable&vname=YourUserVariableHere&vtype=2&vvalue=%ip%
  SendToHTTP DomoticzIPorHostnameHere,8080,/json.htm?type=command&param=udevice&idx=123456789&nvalue=0&svalue=%ip%
  timerSet,1,3600       //Resets the Timer 1 for another x seconds
endon
You need to create a user variable in domoticz with string parameter or/and a text dummy.
Don't forget to change this values in the code, as well as Domoticz IP or hostname and port.

You need to be careful with this rules because when you update it in the ESP there's a bug with the "&param" becoming "¶m" so every time you change something in this rules you need to update this.

-------------------edit------------------
workaround for the &param issue:

Code: Select all

On System#Boot do    //When the ESP boots, do
  SendToHTTP DomoticzIPorHostnameHere,8080,/json.htm?param=updateuservariable&type=command&vname=YourUserVariableHere&vtype=2&vvalue=%ip%
  SendToHTTP DomoticzIPorHostnameHere,8080,/json.htm?param=udevice&type=command&idx=123456789&nvalue=0&svalue=%ip%
timerSet,1,3600      //Set Timer 1 for the next event in x seconds
endon

On Rules#Timer=1 do  //When Timer1 expires, do
  SendToHTTP DomoticzIPorHostnameHere,8080,/json.htm?param=updateuservariable&type=command&vname=YourUserVariableHere&vtype=2&vvalue=%ip%
  SendToHTTP DomoticzIPorHostnameHere,8080,/json.htm?param=udevice&type=command&idx=123456789&nvalue=0&svalue=%ip%
  timerSet,1,3600       //Resets the Timer 1 for another x seconds
endon

Re: Check ESP-01/12 Online Status

Posted: Thursday 30 November 2017 22:37
by kimot
I suppose your ESPeasy sends periodically some data to Domoticz.
If this data are not coming for certain time, Domoticz can send message to you.
Use .lastUpdate attribute.

Example script here:

https://github.com/dannybloe/dzVents/bl ... evices.lua