[SOLVED] Network Binding - Rule triggered by ping change

Hello, I’ve been running the network binding for months now, and up to sitemaps, it works great. My sitemaps show what answers to ping and what doesn’t, changing accordingly. I’m now trying to set up a rule to detect if some devices (cameras or other IoT devices) get disconnected from the network, but I can’t get it to work. This is my setup for a given device:

in network.things
Thing network:pingdevice:192_168_1_5 "PC Despacho" [ hostname="192.168.1.5"]
in network.items
Switch Ping_PC_Despacho "PC Despacho" <man_1> { channel="network:pingdevice:192_168_1_5:online" }
in network.sitemap (working)
Text item=Ping_PC_Despacho label="PC Despacho [MAP(es.map):%s]" valuecolor=[==ON="green"]

in events.log i see
2019-02-25 15:55:09.492 [vent.ItemStateChangedEvent] - Ping_PC_Despacho changed from OFF to ON
2019-02-25 23:21:55.523 [vent.ItemStateChangedEvent] - Ping_PC_Despacho changed from ON to OFF

so in network.rules i’ve tried these two, and none is working

rule “Despacho Ping”
when
Item Ping_PC_Despacho changed
then
if (Ping_PC_Despacho == OFF) {
sendMail("XXXX@XXX.com", “[OH] Ping PC Fran OFF”, “Ordenador de Fran SIN RED”)
}
if (Ping_PC_Despacho == ON) {
sendMail("XXXX@XXX.com", “[OH] Ping PC Fran ON”, “Ordenador de Fran conectado”)
}
end

rule "Despacho Ping 2 "
when
    Thing network:pingdevice:192_168_1_5 changed
then
    if (Ping_PC_Despacho == OFF) {
        sendMail("XXXX@XXXX.com", "[OH] Ping PC Fran OFF", "Ordenador de Fran SIN RED")
    }
    if (Ping_PC_Despacho == ON) {
        sendMail("XXXX@XXXX.com", "[OH] Ping PC Fran ON", "Ordenador de Fran conectado")
    }
end

Any clues of what am I doing wrong?

Thanks in advance

rule “Despacho Ping”
when
Item Ping_PC_Despacho changed
then
if (Ping_PC_Despacho.state == OFF) {
sendMail("XXXX@XXX.com", “[OH] Ping PC Fran OFF”, “Ordenador de Fran SIN RED”)
}
if (Ping_PC_Despacho.state == ON) {
sendMail("XXXX@XXX.com", “[OH] Ping PC Fran ON”, “Ordenador de Fran conectado”)
}
end

Ping_PC_Despacho is the item itself, to access its state you need to add .state

1 Like

Oh my!! So n00b!! Thanks a lot :hugs: