Check ESP-01/12 Online Status

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
User avatar
sisaenkov
Posts: 50
Joined: Friday 27 May 2016 7:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8
Location: Moscow, Russia
Contact:

Re: Check ESP-01/12 Online Status

Post 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
User avatar
sisaenkov
Posts: 50
Joined: Friday 27 May 2016 7:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8
Location: Moscow, Russia
Contact:

Re: Check ESP-01/12 Online Status

Post 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'
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: Check ESP-01/12 Online Status

Post 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.
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
inzuno
Posts: 13
Joined: Wednesday 22 November 2017 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Lyon FR
Contact:

Re: Check ESP-01/12 Online Status

Post 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
"I never make the same mistake twice. I make it like five or six times, you know, just to be sure."
kimot
Posts: 105
Joined: Saturday 25 November 2017 17:18
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8153
Location: Czech Rep.
Contact:

Re: Check ESP-01/12 Online Status

Post 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
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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest