# \[SOLVED\] Check if Shelly device is online?

**URL:** <https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628>\
**Category:** Beginners\
**Created:** [May 11, 2020, 8:37pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628 "2020-05-11T20:37:48Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hubschra01](https://community.openhab.org/letter_avatar_proxy/v4/letter/h/d2c977/32.png) [@Hubschra01](https://community.openhab.org/u/Hubschra01)\
**Post date:** [May 11, 2020, 8:37pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/1 "2020-05-11T20:37:48Z")

</div>

Hello…  
Is it possible to check if a Shelly device is online?

I am using Openhab 2.5.3 with an MQTT broker. The Shellies send their MQTT messages to the broker.  
When i turn on the shellies sends  
/ shellies / device / online: true

I am using some shelly plugs and want to know if the plug is offline and display it via sitemap.

How do i manage this?

Thanks  
Andre

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [May 11, 2020, 9:36pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/2 "2020-05-11T21:36:42Z")

</div>

Network binding.

---

<div class="post-metadata">

**Author:** ![hmerk](https://community.openhab.org/user_avatar/community.openhab.org/hmerk/32/56432_2.png) [@hmerk](https://community.openhab.org/u/hmerk)\
**Post date:** [May 12, 2020, 5:38am UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/3 "2020-05-12T05:38:07Z")

</div>

Shelly binding with things created.

---

<div class="post-metadata">

**Author:** ![Hubschra01](https://community.openhab.org/letter_avatar_proxy/v4/letter/h/d2c977/32.png) [@Hubschra01](https://community.openhab.org/u/Hubschra01)\
**Post date:** [May 12, 2020, 12:29pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/4 "2020-05-12T12:29:17Z")

</div>

I think your solution is to ping the Shelly device every x minutes? But how do this work on more than 6 Plug devices? Must i create for each device a rule or something else?  
And how is the evaluation by a rule?  
Do you have an example?

---

<div class="post-metadata">

**Author:** ![Hubschra01](https://community.openhab.org/letter_avatar_proxy/v4/letter/h/d2c977/32.png) [@Hubschra01](https://community.openhab.org/u/Hubschra01)\
**Post date:** [May 12, 2020, 12:37pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/5 "2020-05-12T12:37:56Z")

</div>

@hmerk  
How does it work?  
I create an mqtt.thing for the Devices and switch on the Mqtt feature in the Shelly. Will the Mqtt and Shelly Binding work together? I work with the Files and not with the PaperUI… 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [May 12, 2020, 12:50pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/6 "2020-05-12T12:50:56Z")

</div>

> [@Hubschra01](#):
>
> Must i create for each device a rule or something else?

You can put all your pingable Items in a Group, and trigger one rule from the Group.  
What do you want to happen when one goes offline?

> [@\[SOLVED\] Intelligent Rule for E-mail notification for online/offline devices](https://community.openhab.org/t/solved-intelligent-rule-for-e-mail-notification-for-online-offline-devices/62481):
>
> OH 2.4 on RasPI using Openhabian. Hm - I hope that is the best title here. So basically I want to get an E-Mail when the status of an item representing a device being online/offline. The items for that are defined as follows: //Online status of switches / plugs Switch Plug\_Garden\_TerraceLeft\_Ping "Steckdose Terrasse links [MAP(network.map):%s]" \<zwaveonline\> (gDeviceOnlineState) Switch Illumination\_GroundFloor\_LivingRoom\_Ping "Licht Wohnzimmer [MAP(network.map):%s]" \<zwaveonline\>…

---

<div class="post-metadata">

**Author:** ![hmerk](https://community.openhab.org/user_avatar/community.openhab.org/hmerk/32/56432_2.png) [@hmerk](https://community.openhab.org/u/hmerk)\
**Post date:** [May 12, 2020, 1:05pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/7 "2020-05-12T13:05:38Z")

</div>

> [@Hubschra01](#):
>
> I create an mqtt.thing for the Devices and switch on the Mqtt feature in the Shelly. Will the Mqtt and Shelly Binding work together? I work with the Files and not with the PaperUI…

If you use the Shelly Binding, there is no need to use MQTT for them at all. But both would work parallell. You can configure the Shelly binding Things via config files as well.  
Using the Shelly Binding, you can create a rule to check if the Thing is ONLINE or OFFLINE.

---

<div class="post-metadata">

**Author:** ![Hubschra01](https://community.openhab.org/letter_avatar_proxy/v4/letter/h/d2c977/32.png) [@Hubschra01](https://community.openhab.org/u/Hubschra01)\
**Post date:** [May 12, 2020, 3:35pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/8 "2020-05-12T15:35:14Z")

</div>

I want to display it on a sitemap of the Device by a color changing point  
red for offline  
green for online  
to make status visible.

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [May 12, 2020, 3:53pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/9 "2020-05-12T15:53:07Z")

</div>

> [@Hubschra01](#):
>
> I want to display it on a sitemap of the Device by a color changing point

Okay, so have your rule postUpdate the text to some Item  
Display the Item using colour options -  
[https://www.openhab.org/docs/configuration/sitemaps.html#label-and-value-colors](https://www.openhab.org/docs/configuration/sitemaps.html#label-and-value-colors)

---

<div class="post-metadata">

**Author:** ![hmerk](https://community.openhab.org/user_avatar/community.openhab.org/hmerk/32/56432_2.png) [@hmerk](https://community.openhab.org/u/hmerk)\
**Post date:** [May 12, 2020, 6:18pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/10 "2020-05-12T18:18:07Z")

</div>

I have done this myself and will post an example later tonight or tomorrow.  
It is not that difficult.

1. Create dummy items to hold the state.
2. Create a rule for each thing you want to monitor, triggered by change to offline and post update to according dummy item.
3. Create Sitemap entrys with visibility pattern.

---

<div class="post-metadata">

**Author:** ![hmerk](https://community.openhab.org/user_avatar/community.openhab.org/hmerk/32/56432_2.png) [@hmerk](https://community.openhab.org/u/hmerk)\
**Post date:** [May 13, 2020, 6:57am UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/11 "2020-05-13T06:57:08Z")

</div>

Ok, here we go:

**Things:**

```csv
Thing shelly:shelly2-roller:559470 "Dachfenster" @ "Arbeitszimmer" [deviceIp="192.168.0.180", coap="true", eventsRelayButton="false", eventsRelaySwitch="false", eventsCoIoT="true"]
Thing shelly:shellyflood:68fa6f "WasserSchaden" @ "Waschküche" [deviceIp="192.168.0.187", coap="true", eventsSensorReport="false", eventsCoIoT="true"]

```

**Dummy-Items and Group:**

```csv
Group:Switch:OR(OFF, ON) DeviceHealth	"Gerätestatus [(%d)]"	<status>	(All)

Switch FloodLaundryHealth "Shelly Flood Waschküche" (DeviceHealth)
Switch ShellyWindowOfficeHealth "Fensterantrieb Arbeitszimmer" (DeviceHealth)

```

**Map-Transformation “health.map”**

```csv
OFF=OFFLINE
ON=ONLINE
NULL=undefiniert

```

**Rules**

```csv
val mailActions = getActions("mail","mail:smtp:xxxx")
rule "ONLINE/OFFLINE Alert"
	when
		Member of DeviceHealth changed
	then
		if (triggeringItem.state == OFF) {
			var message = triggeringItem.label + " ist OFFLINE"
			//sendBroadcastNotification(triggeringItem.label + " ist OFFLINE")
			mailActions.sendMail("xxx@xxx.dd", "openHAB Gerätealarm", message)
		}
end

rule "Dachfensterantrieb Arbeitszimmer Health"
	when
		Thing "shelly:shelly2-roller:559470" changed
		then
			var message = "Shelly Dachfensterantrieb ist " + getThingStatusInfo("shelly:shelly2-roller:559470").getStatus.toString()
			logInfo("shelly2-roller:559470", message)
			if (getThingStatusInfo("shelly:shelly2-roller:559470").getStatus.toString() == "ONLINE") {
			ShellyWindowOfficeHealth.sendCommand(ON)
			} else {
			ShellyWindowOfficeHealth.sendCommand(OFF)
			}
end
rule "ShellyFlood Health"
	when
		Thing "shelly:shellyflood:68fa6f" changed
		then
			var message = "ShellyFlood ist " + getThingStatusInfo("shelly:shellyflood:68fa6f").getStatus.toString()
			logInfo("shellyflood:68fa6f", message)
			if (getThingStatusInfo("shelly:shellyflood:68fa6f").getStatus.toString() == "ONLINE") {
			FloodLaundryHealth.sendCommand(ON)
			} else {
			FloodLaundryHealth.sendCommand(OFF)
			}
end

```

**Sitemap, showing Status if at least one Thing is offline**

```csv
Group item=DeviceHealth label="Geräte Alarme" icon="status" visibility=[DeviceHealth==OFF]{
	Text item=FloodLaundryHealth label="ShellyFlood Waschküche [MAP(health.map):%s]" icon="status" visibility=[FloodLaundryHealth==OFF]
	Text item=ShellyWindowOfficeHealth label="Dachfenster Arbeitszimmer [MAP(health.map):%s]" icon="status" visibility=[ShellyWindowOfficeHealth==OFF]
}

```

**Alternative Sitemap, showing status all the time :**

```csv
Text item=FloodLaundryHealth label="ShellyFlood Waschküche [MAP(health.map):%s]" icon="status" valuecolor=[OFF="red"] visibility=[FloodLaundryHealth==OFF] 
Text item=FloodLaundryHealth label="ShellyFlood Waschküche [MAP(health.map):%s]" icon="status" valuecolor=[ON="green"] visibility=[FloodLaundryHealth==ON]
Text item=ShellyWindowOfficeHealth label="Dachfenster Arbeitszimmer [MAP(health.map):%s]" icon="status" valuecolor=[OFF="red"] visibility=[ShellyWindowOfficeHealth==OFF]
Text item=ShellyWindowOfficeHealth label="Dachfenster Arbeitszimmer [MAP(health.map):%s]" icon="status" valuecolor=[ON="green"] visibility=[ShellyWindowOfficeHealth==ON]

```

---

<div class="post-metadata">

**Author:** ![Hubschra01](https://community.openhab.org/letter_avatar_proxy/v4/letter/h/d2c977/32.png) [@Hubschra01](https://community.openhab.org/u/Hubschra01)\
**Post date:** [May 14, 2020, 6:01pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/12 "2020-05-14T18:01:55Z")

</div>

Thanks. I will give this an try and report the result…

---

<div class="post-metadata">

**Author:** ![curlyel](https://community.openhab.org/letter_avatar_proxy/v4/letter/c/71e660/32.png) [@curlyel](https://community.openhab.org/u/curlyel)\
**Post date:** [May 14, 2020, 6:29pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/13 "2020-05-14T18:29:18Z")

</div>

Hi Hans-Jörg,  
I notice in your examples here as well as in the “Shelly Binding” thread, that you have additional `coap="true"` in your thing definitions, e.g:

> [@hmerk](#):
>
> Thing shelly:shellyflood:68fa6f “WasserSchaden” @ “Waschküche” [deviceIp=“192.168.0.187”, coap=“true”, eventsSensorReport=“false”, eventsCoIoT=“true”]

What is this needed for? Isn’t `eventCoIoT="true"` sufficient already?

---

<div class="post-metadata">

**Author:** ![hmerk](https://community.openhab.org/user_avatar/community.openhab.org/hmerk/32/56432_2.png) [@hmerk](https://community.openhab.org/u/hmerk)\
**Post date:** [May 14, 2020, 7:14pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/14 "2020-05-14T19:14:26Z")

</div>

This is just a leftover and can be igored, doesn‘t harm either.  
It was needed before Markus made it a default.

---

<div class="post-metadata">

**Author:** ![curlyel](https://community.openhab.org/letter_avatar_proxy/v4/letter/c/71e660/32.png) [@curlyel](https://community.openhab.org/u/curlyel)\
**Post date:** [May 14, 2020, 7:20pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/15 "2020-05-14T19:20:50Z")

</div>

O.k. makes sense.  
Thanks for clarifying!

---

<div class="post-metadata">

**Author:** ![Hubschra01](https://community.openhab.org/letter_avatar_proxy/v4/letter/h/d2c977/32.png) [@Hubschra01](https://community.openhab.org/u/Hubschra01)\
**Post date:** [May 15, 2020, 12:57pm UTC](https://community.openhab.org/t/solved-check-if-shelly-device-is-online/98628/16 "2020-05-15T12:57:33Z")

</div>

Hi I solved this problem with your help. Thanks! For anybody how search for something similar here my solution:  
I use the Networkbinding and do a ping from this binding.

The network.things:

```php
network:pingdevice:1_device "PlugS-01" [hostname="192.168.xxx.yyy", retry=1, timeout=5000, refreshInterval=60000]
network:pingdevice:2_device "PlugS-02" [hostname="192.168.xxx.yyy", retry=1, timeout=5000, refreshInterval=60000]
network:pingdevice:3_device "PlugS-03" [hostname="192.168.xxx.yyy", retry=1, timeout=5000, refreshInterval=60000]
network:pingdevice:4_device "PlugS-04" [hostname="192.168.xxx.yyy", retry=1, timeout=5000, refreshInterval=60000]
network:pingdevice:5_device "PlugS-05" [hostname="192.168.xxx.yyy", retry=1, timeout=5000, refreshInterval=60000]
network:pingdevice:6_device "PlugS-06" [hostname="192.168.xxx.yyy", retry=1, timeout=5000, refreshInterval=60000]

```

Here The network.items

```php
Group:Switch:OR(OFF, ON) DeviceHealth	"Gerätestatus [(%d)]"	<status>	(All)

Switch 1_device "online" (DeviceHealth) { channel = " network:pingdevice:1_device:online " }
Switch 2_device "online" (DeviceHealth) { channel = " network:pingdevice:2_device:online " }
Switch 3_device "online" (DeviceHealth) { channel = " network:pingdevice:3_device:online " }
Switch 4_device "online" (DeviceHealth) { channel = " network:pingdevice:4_device:online " }
Switch 5_device "online" (DeviceHealth) { channel = " network:pingdevice:5_device:online " }
Switch 6_device "online" (DeviceHealth) { channel = " network:pingdevice:6_device:online " }

```

The net\_status.rules  
aktually there is only a Info in the Logfile written. later more…

```php
rule "ONLINE/OFFLINE Alert"
	when
		Member of DeviceHealth changed
	then
		if (triggeringItem.state == OFF) {
			var message = triggeringItem.name + " ist OFFLINE"
			logInfo("RULE", "--> Geräte status: "+ message)
		}
		if (triggeringItem.state == ON) {
			var message = triggeringItem.name + " ist ONLINE"
			logInfo("RULE", "--> Geräte status: "+ message)
		}
end

```

An the  
Sitemap  
the code is shortened

```php
sitemap plug_s label="Plugs " {
    	Text item=1_device label="Plug 01 [MAP(health.map):%s]" valuecolor=[OFF="red"] visibility=[1_device==OFF] 
	Text item=1_device label="Plug 01 [MAP(health.map):%s]" valuecolor=[ON="green"] visibility=[1_device==ON] 
	{
    
            Frame label="Plug 01" 
			{
                Default item=Plug_S_01_relay label="Plug_S_01 Ein / Aus "
                Default item=Plug_S_01_power label="Leistung"
                Default item=Plug_S_01_energy label="W Zähler"
            }
            Frame label="Leistung"
			{
					Switch item=Chart_Zeitraum_D_W_M_Y label="" mappings=[0="Stunde", 1="12 h", 2="Tag", 3="Woche", 4="Monat"]
					Chart item=Plug_S_01_power period=h refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==0, Chart_Zeitraum_D_W_M_Y=="Uninitialized"]
					Chart item=Plug_S_01_power period=12h refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==1]
					Chart item=Plug_S_01_power period=D refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==2]
					Chart item=Plug_S_01_power period=W refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==3]
					Chart item=Plug_S_01_power period=M refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==4]
			}
			Frame label="Temperatur"
			{
					Chart item=Plug_S_01_temp period=h refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==0, Chart_Zeitraum_D_W_M_Y=="Uninitialized"]
					Chart item=Plug_S_01_temp period=12h refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==1]
					Chart item=Plug_S_01_temp period=D refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==2]
					Chart item=Plug_S_01_temp period=W refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==3]
					Chart item=Plug_S_01_temp period=M refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==4]
			}
	}
	
	//Text label="Plug_S : Plug 03" 
		Text item=3_device label="Plug 03 [MAP(health.map):%s]" valuecolor=[OFF="red"] visibility=[3_device==OFF] 
		Text item=3_device label="Plug 03 [MAP(health.map):%s]" valuecolor=[ON="green"] visibility=[3_device==ON]
		{
    
            Frame label="Plug 03" 
			{
                Default item=Plug_S_03_relay label="Plug_S_01 Ein / Aus "
                Default item=Plug_S_03_power label="Leistung"
                Default item=Plug_S_03_energy label="W Zähler"
            }
            Frame label="Leistung"
				{
					Switch item=Chart_Zeitraum_D_W_M_Y label="" mappings=[0="Stunde", 1="12 h", 2="Tag", 3="Woche", 4="Monat"]
					Chart item=Plug_S_03_power period=h refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==0, Chart_Zeitraum_D_W_M_Y=="Uninitialized"]
					Chart item=Plug_S_03_power period=12h refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==1]
					Chart item=Plug_S_03_power period=D refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==2]
					Chart item=Plug_S_03_power period=W refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==3]
					Chart item=Plug_S_03_power period=M refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==4]
				}
			Frame label="Temperatur"
				{
					Chart item=Plug_S_03_temp period=h refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==0, Chart_Zeitraum_D_W_M_Y=="Uninitialized"]
					Chart item=Plug_S_03_temp period=12h refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==1]
					Chart item=Plug_S_03_temp period=D refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==2]
					Chart item=Plug_S_03_temp period=W refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==3]
					Chart item=Plug_S_03_temp period=M refresh=60000 service="rrd4j" visibility=[Chart_Zeitraum_D_W_M_Y==4]
				}
		}

}

```

The Transform Map is as like the map from hmerk.

Look of the Sitemap:

 ![grafik](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/7/b79477f15a41590e90557a5e33a5257f12f3437d.png)

Thanks again…  
And I hope I can help someone with that too…
