User turns on and off constantly

Hi again,

I added multiple Users in a group “gUser”. They are all switch type ping devices via network binding. Android and IOS. Although online, the status changes from off to on and vice versa all the time. Thus my rule ‘to turn on a light when all users are offline and it´s dark’ turns the light on and back of again all the time. How can I fix this?

rule “Einbrecherlicht einschalten”

when

Item gUser changed from ON to OFF

then

if (Dunkel.state == ON) { GF_LivingRoom_Light.sendCommand(ON) }

end

rule “Einbrecherlicht ausschalten”

when

Item gUser changed from OFF to ON or

Time cron "0 30 23 1/1 * ? *" //oder um 23:30

then

GF_LivingRoom_Light.sendCommand(OFF)

end

You can try tweaking the setting in the network binding.

This is what I use:

binding.network:allowSystemPings=true
binding.network:allowDHCPlisten=false
binding.network:arpPingToolPath=arping
binding,network:cacheDeviceStateTimeInMS=2000
uses_arp_pings=yes

Also, the setting in the Thing can be tweaked as well.

My thing settings:

Thing network:pingdevice:SiPhone [ hostname="10.0.1.22", uses_ios_wakeup=1, uses_arp_pings=1, retry=30, timeout=15000, refreshInterval=60000 ]

If the setting do not help here is what I have for my home that works well.

My items, using the expire binding to allow 20 minutes before doing something (prevents turning something on/off if detection gets changed b/c I walk to the mailbox)

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" }

My rule:

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

What OH version are you running?
Is it an upgrade? Invalid addons cause them all to reload every minute. Many people do not read the Release Notes or CLI displayed Warnings when upgrading.

1 Like

I assumed the logs were checked and nothing regarding addons being reloaded. :crazy_face:

Thanks for the extra troubleshooting tip. :+1:

The logs do not always show that. Check the addons.config file in Userdata that was created by OH.

One common issue is restdocs because it got moved from misc to ui. Some v1 bindings ot moved to legacy since there are now v2 ones.

Thank you both for your suggestions.

I have got openhab 2.5.0. I am new to openhab and a rookie when it comes to programming. The addons.config looks like this:

:org.apache.felix.configadmin.revision:=L"14"
binding=“network,mihome,shelly,astro,ntp”
misc=“openhabcloud,ruleengine”
package=“standard”
service.pid=“org.openhab.addons”
ui=“basic,paper,habpanel,homebuilder,habmin”

@H102 Do you mean the network.config file and then add your lines? At the moment they don´t exist plus I found two files. One at userdata/config/binding and one at uesrdata/config/org/eclipse/smarthome. I guess the first one.Cannot find any .things file. The folder under conf/things is empty. I gues because I created the thing via the network binding. Shall I delete it and add it manually or where to add the suggested settings for the thing? I´ll try your settings on tuesday and give feedback to both of you here. Thanks again.

That looks good to me.

I recommend creating Things within openHAB if possible, even if you use files for Items and Rules like I do. Things are easy to mess up, causing strange issues.

I do not use the network binding though.

I know it’s in the docs but does that really work?
network is a v2 binding which shouldn’t use any input files (but thing config only).

1 Like

There’s a typo in there (comma) but that is the parameter you should be interested in. Retaining a ping result for only two seconds is probably not what you want.

1 Like

It’s been working fine for over a year as is and nothing broke when upgrading so I plan to keep using it. The old don’t fix what aint broke saying. :laughing:

You got me wrong. I was asking if the binding uses those values you’ve configured in the .cfg ?

1 Like

Sorry, I read the question wrong and now that you pointed it out, no it does not use this file. :upside_down_face: Thanks

1 Like

Sorry to bother you again. I cannot find either the file for the network settings nor the thing settings. Can you give me advise where to find them, location and name?

If I have to create them, can you tell me where to put them and the exact file names?

EDIT

That was a bit stupid. Still, I cannot find the files, but in paper UI settings you have most tof the options. Apart from “uses_ios” and “uses_arp_pings”. Is it possible to locate the setting files?

I´ll play around with the settings and then we´ll see.

files and PaperUI settings are in most cases alternatives. You use one method or the other.

Not really.
For v1 bindings and actions, you can only use files (*.cfg).
For v2 bindings, you can only use PaperUI (or any other UI to use the API) but *.cfg will be ignored.
(yes there’s .thing files but those obviously have a different syntax and are not really recommended to be used)

1 Like

I would recommend avoiding v1 bindings and actions if at all possible. OH3, the next major version, will not directly support v1. The code has already been stripped from the source, I believe.