[SOLVED] BasicUI refresh data issue for "ping"

openhab2
Tags: #<Tag:0x00007f0142c75cc8>

(Bjorn Vandeuren) #24

no extra thing in the PaperUI.
I think i need this to have a channel to use with my switch


(CM6.5 H102) #25

Make an item like:

Group:Switch:AND(OFF,ON) gPresent <present>
Switch Present "Phone is home" <present>
Switch Present_Timer { expire="20m, command=OFF" }
Switch MyDevice <network> (gPresent) { channel="network:pingdevice:SiPhone:online" }

All the extra info is for a rule and presents detection.

rule "start gPresent on system start"
when
    System started
then
    Present.sendCommand(OFF) // assume no one is home
end

rule "gPresent updated, at least one change of state"
when
    Item gPresent received update
then
    // someone came home
    if(gPresent.state == ON && Present.state != ON) { 
        Present_Timer.postUpdate(OFF) // cancel the timer if necessary
        Present.sendCommand(ON)
    }

    // no one is home and timer is not yet ticking (otherwise endless loop)
    else if(gPresent.state == OFF && Present.state != OFF && Present_Timer.state != ON) {
        Present_Timer.sendCommand(ON) // start the timer
    }
end

rule "Present_Timer expired"
when
	Item Present_Timer received command OFF
then
	Present.sendCommand(OFF)
end


(Bjorn Vandeuren) #26

First things first :slight_smile:
Shouldnt this thing be visible in my Paper UI after creating that one single line?

Thing network:pingdevice:Bjornphone2 [ hostname="192.168.1.3", uses_ios_wakeup=0, uses_arp_pings=0, retry=30, timeout=15000, refreshInterval=60000 ]

Because i dont have a channel to link now.
Or is this because i already have a different item for my phone available?


(Bjorn Vandeuren) #27

sorry forget about this.
I failed with something old in my things file :stuck_out_tongue:
had something with // that was recognized as code.

it is visibile in the PaperUI


(CM6.5 H102) #28

If you need arping let me know and I can share the setup.


(Bjorn Vandeuren) #29

i created the thing and items but it is not showing up.
I think because of the sitemap needs to be filled.
Any chance you have a sitemap config for this as well please?


(CM6.5 H102) #30

Just change the item names to match yours.

Frame label="iPhone"
	{
		Switch item=MyDevice label="iPhone home"
		Text item=MyDevice label="Device [%s]"
	}

Network Binding arping not working
(Bjorn Vandeuren) #31

seems that once ur code has been triggered as “online” it does not go back to offline.
tried do disable my wifi on my phone and then changing group and go back over and over untill yours or mine jumps offline.
Result:

or do i understand this wrong?


(CM6.5 H102) #32

Is the bottom phone the one just added?

Your correct, in the items file I use the expire binding as a timer. This helps with false presence e.g. I walk over to the neighbors for 10 min. my presents remains. When I’m away for 20 min then I’m detected as away and can use other rules to turn off lights and such.

You can adjust the 20 min to suit your needs.


(Bjorn Vandeuren) #33

the bottom one is indeed yours with a few small name changes.
Been testing some more in the mean while :slight_smile:
Your “Bjorn Phone home” and “Device” what you see in the screenshot does not seem to ever go in a “off” state for me.
Although i changed the expire to 1m.
But when i disable my wifi on the phone and manually set ur switch to off…
And then turn on wifi on my phone… i start by clicking “open group” and going back “Home”, and doing this over and over to “refresh”.
Omg, your button instantly changed to “on” after 1 “refresh”
Then after about 4-5 times (and often more) opening the group and going back, finally my button jumps to a “on” state.
Then again my button goes back to “off” when disabling wifi on my phone, this does require more about 15 refreshes, did not count it but it takes ages :stuck_out_tongue:
I dont see much difference beside that in my code i also use “lastseen”, but this should have nothing to do with this i think.

sitemap:

    Frame label="iPhone"
	{
		Switch item=Bjornphone2 label="Bjorn Phone home"
		Text item=Bjornphone2 label="Device [%s]"
	}

item:

Group:Switch:AND(OFF,ON) gPresent <present>
Switch Present "Phone is home" <present>
Switch Present_Timer { expire="1m, command=OFF" }
Switch Bjornphone2 <network> (gPresent) { channel="network:pingdevice:Bjornphone2:online" }

thing:

Thing network:pingdevice:Bjornphone2 [ hostname="192.168.1.3", uses_ios_wakeup=0, uses_arp_pings=0, retry=30, timeout=15000, refreshInterval=60000 ]

Extra:
I also noticed that when my phone goes to sleep that my button will jump to off, which is arping i need to fix if this is an issue.
But just browsing or w/e on my mobile makes my button go back to online.
Once my button would show “off” because my mobile is a sleep i tried turning your button to off, though now it does not jump back on by itself by browsing.
Again… wifi off and on makes it instantly show “on”


(CM6.5 H102) #34

What do you see in the logs?


(Bjorn Vandeuren) #35
2018-10-21 17:44:56.794 [vent.ItemStateChangedEvent] - Bjornphone2lastseen changed from 2018-10-21T17:31:25.341+0200 to 2018-10-21T17:44:56.768+0200

2018-10-21 17:44:56.804 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:Bjornphone2' has been updated.

2018-10-21 17:45:11.003 [vent.ItemStateChangedEvent] - Date changed from 2018-10-21T17:44:10.975+0200 to 2018-10-21T17:45:10.983+0200

2018-10-21 17:45:14.525 [vent.ItemStateChangedEvent] - BjornphoneResponseTime changed from 14.0 to 17.0

2018-10-21 17:45:14.573 [vent.ItemStateChangedEvent] - Bjornphonelastseen changed from 2018-10-21T17:44:14.405+0200 to 2018-10-21T17:45:14.512+0200

2018-10-21 17:45:56.934 [vent.ItemStateChangedEvent] - Bjornphone2lastseen changed from 2018-10-21T17:44:56.768+0200 to 2018-10-21T17:45:56.909+0200

2018-10-21 17:46:11.010 [vent.ItemStateChangedEvent] - Date changed from 2018-10-21T17:45:10.983+0200 to 2018-10-21T17:46:10.989+0200

2018-10-21 17:46:14.643 [vent.ItemStateChangedEvent] - BjornphoneResponseTime changed from 17.0 to 61.0

2018-10-21 17:46:14.660 [vent.ItemStateChangedEvent] - Bjornphonelastseen changed from 2018-10-21T17:45:14.512+0200 to 2018-10-21T17:46:14.624+0200

2018-10-21 17:46:57.100 [vent.ItemStateChangedEvent] - Bjornphone2lastseen changed from 2018-10-21T17:45:56.909+0200 to 2018-10-21T17:46:57.054+0200

2018-10-21 17:47:11.016 [vent.ItemStateChangedEvent] - Date changed from 2018-10-21T17:46:10.989+0200 to 2018-10-21T17:47:10.994+0200

2018-10-21 17:47:14.762 [vent.ItemStateChangedEvent] - BjornphoneResponseTime changed from 61.0 to 106.0

2018-10-21 17:47:14.779 [vent.ItemStateChangedEvent] - Bjornphonelastseen changed from 2018-10-21T17:46:14.624+0200 to 2018-10-21T17:47:14.749+0200

2018-10-21 17:47:57.170 [vent.ItemStateChangedEvent] - Bjornphone2lastseen changed from 2018-10-21T17:46:57.054+0200 to 2018-10-21T17:47:57.127+0200

2018-10-21 17:48:11.024 [vent.ItemStateChangedEvent] - Date changed from 2018-10-21T17:47:10.994+0200 to 2018-10-21T17:48:11.000+0200

2018-10-21 17:48:14.857 [vent.ItemStateChangedEvent] - BjornphoneResponseTime changed from 106.0 to 77.0

2018-10-21 17:48:14.873 [vent.ItemStateChangedEvent] - Bjornphonelastseen changed from 2018-10-21T17:47:14.749+0200 to 2018-10-21T17:48:14.844+0200

==> /var/log/openhab2/openhab.log <==

2018-10-21 17:49:01.504 [WARN ] [sitemap.internal.SitemapProviderImpl] - Filename `home.sitemap` does not match the name `Home` of the sitemap - please fix this as you might see unexpected behavior otherwise.

==> /var/log/openhab2/events.log <==

2018-10-21 17:49:08.668 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:Bjornphone2' has been updated.

2018-10-21 17:49:11.028 [vent.ItemStateChangedEvent] - Date changed from 2018-10-21T17:48:11.000+0200 to 2018-10-21T17:49:11.006+0200

==> /var/log/openhab2/openhab.log <==

2018-10-21 17:49:17.257 [WARN ] [sitemap.internal.SitemapProviderImpl] - Filename `home.sitemap` does not match the name `Home` of the sitemap - please fix this as you might see unexpected behavior otherwise.

2018-10-21 17:49:17.279 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Text

2018-10-21 17:49:17.284 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Temperature' for widget org.eclipse.smarthome.model.sitemap.Text

2018-10-21 17:49:17.289 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Temperature' for widget org.eclipse.smarthome.model.sitemap.Text

2018-10-21 17:49:17.294 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Temperature' for widget org.eclipse.smarthome.model.sitemap.Text

2018-10-21 17:49:17.323 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Group

2018-10-21 17:49:17.327 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Alarm' for widget org.eclipse.smarthome.model.sitemap.Group

2018-10-21 17:49:17.332 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Alarm' for widget org.eclipse.smarthome.model.sitemap.Group

2018-10-21 17:49:17.336 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Alarm' for widget org.eclipse.smarthome.model.sitemap.Group

==> /var/log/openhab2/events.log <==

2018-10-21 17:49:19.887 [vent.ItemStateChangedEvent] - Bjornphone changed from ON to OFF

2018-10-21 17:49:19.894 [vent.ItemStateChangedEvent] - BjornphoneResponseTime changed from 77.0 to UNDEF

2018-10-21 17:49:19.910 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_1_3' has been updated.

(CM6.5 H102) #36

Need to change the file name to Home.sitemap or change the top of your sitemap file from Home to home.


(Bjorn Vandeuren) #37

ok changed :slight_smile:

i think this is what u needed:

2018-10-21 17:53:11.056 [vent.ItemStateChangedEvent] - Date changed from 2018-10-21T17:52:11.024+0200 to 2018-10-21T17:53:11.036+0200

2018-10-21 17:53:32.574 [vent.ItemStateChangedEvent] - Bjornphone changed from ON to OFF

2018-10-21 17:53:32.582 [vent.ItemStateChangedEvent] - BjornphoneResponseTime changed from 2130.0 to UNDEF

2018-10-21 17:53:32.607 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_1_3' has been updated.

2018-10-21 17:54:11.064 [vent.ItemStateChangedEvent] - Date changed from 2018-10-21T17:53:11.036+0200 to 2018-10-21T17:54:11.042+0200

2018-10-21 17:54:32.737 [vent.ItemStateChangedEvent] - Bjornphone changed from OFF to ON

2018-10-21 17:54:32.753 [vent.ItemStateChangedEvent] - BjornphoneResponseTime changed from UNDEF to 112.0

2018-10-21 17:54:32.758 [vent.ItemStateChangedEvent] - Bjornphonelastseen changed from 2018-10-21T17:52:32.087+0200 to 2018-10-21T17:54:32.716+0200

2018-10-21 17:54:32.773 [vent.ItemStateChangedEvent] - Bjornphone2lastseen changed from 2018-10-21T17:47:57.127+0200 to 2018-10-21T17:54:32.716+0200

2018-10-21 17:54:32.776 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:Bjornphone2' has been updated.

2018-10-21 17:54:32.781 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_1_3' has been updated.

2018-10-21 17:54:56.200 [vent.ItemStateChangedEvent] - Katrienphone changed from OFF to ON

2018-10-21 17:54:56.232 [vent.ItemStateChangedEvent] - Katrienphonelastseen changed from 2018-10-21T17:20:20.470+0200 to 2018-10-21T17:54:56.186+0200

2018-10-21 17:54:56.238 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_1_32' has been updated.

2018-10-21 17:55:11.067 [vent.ItemStateChangedEvent] - Date changed from 2018-10-21T17:54:11.042+0200 to 2018-10-21T17:55:11.049+0200

2018-10-21 17:55:37.788 [vent.ItemStateChangedEvent] - Bjornphone changed from ON to OFF

2018-10-21 17:55:37.801 [vent.ItemStateChangedEvent] - BjornphoneResponseTime changed from 112.0 to UNDEF

2018-10-21 17:55:37.814 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_1_3' has been updated.

2018-10-21 17:55:44.255 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:Bjornphone2' has been updated.

2018-10-21 17:55:57.355 [vent.ItemStateChangedEvent] - Katrienphonelastseen changed from 2018-10-21T17:54:56.186+0200 to 2018-10-21T17:55:57.322+0200

2018-10-21 17:56:11.078 [vent.ItemStateChangedEvent] - Date changed from 2018-10-21T17:55:11.049+0200 to 2018-10-21T17:56:11.057+0200

2018-10-21 17:56:57.559 [vent.ItemStateChangedEvent] - Katrienphonelastseen changed from 2018-10-21T17:55:57.322+0200 to 2018-10-21T17:56:57.532+0200

so i make up that its registering the correct value.
Only the button does not change, even after refresh


(CM6.5 H102) #38

I never used or tried to use the switch, its just an indication, you can change that to something else if you like.
Why it’s not updating on the sitemap is strange. Have you restarted OH after making all the changes? Sometimes that is helpful when making sitemap changes.


(Bjorn Vandeuren) #39

restarted openhab again.
Opened my sitemap with my wifi disabled.
Enable wifi… and without any refresh my button instant becomes green…
after 1 min your button becomes green without refresh.
Turned of wifi and waited.
About a minute and my button becomes red again…

5mins in the newly created one is still green, even refresh does not change it.

So just as an extra test i just turned on wifi and again my firstly created button instantly turns green…
i am getting confused :slight_smile:
that would mean there never was an issue…
i dont believe it… wifi back off!
about 1 min and it turns off automatically.


(CM6.5 H102) #40

Strange.:thinking: Mine seems to work fine.

One other thing to note is when making lots of changes and troubleshooting it a good idea to clean the cache and tmp files. Have you ever done this?


(Bjorn Vandeuren) #41

no, the only thing i do is a service restart for openhab2


(CM6.5 H102) #42

For future needs.:wink:

sudo systemctl stop openhab2.service

sudo openhab-cli clean-cache

sudo systemclt start openhab2.service


(Bjorn Vandeuren) #43

thx, added it to my documentation document :slight_smile:
Thx for all the assistance you already gave