How to disable and enable things by script?

my problem:
KEBA-Wallbox is connectet via FRITZ-repeater and WLAN to my FRITZ-Box. After several houres the Repeater ist disconnectet for some seconds and then connectet again. I can´t fix this Problem.
Therfore:
Is it possible to disable and enable the Thing KEBA-Wallbox, when occours a connection error, my be after 10 seconds?
As i have no idea about programming i would be thankfull with help!
Raspberry Pi B01

OpenHABian, openHAB 2.5.2-1

Binding.keba-2.5.0

Keba-Wallbox P30 v 3.08.4

Keba.things
Thing keba:kecontact:1 [ ipAddress=“192.168.xxx.xxx”, refreshInterval=30 ]

Keba.items
Dimmer KebaCurrentRange {channel=“keba:kecontact:1:maxpresetcurrentrange”, autoupdate=“false”}
Switch KebaSwitch {channel=“keba:kecontact:1:enabled”, autoupdate=“false”}
Switch Fahrzeug_eingesteckt {channel=“keba:kecontact:1:vehicle”}
Number KebaPower {channel=“keba:kecontact:1:power”}
Number KebaSessionEnergy {channel=“keba:kecontact:1:sessionconsumption”}
Number KebaTotalEnergy {channel=“keba:kecontact:1:totalconsumption”}

The question is, what is your problem? If the plug is disconnected for some seconds and then reconnects, where is the harm? What do you want to do, where is the core of the problem?

I did that here. Just change the binding to adapt it:

Maybe its bit of an overkill for your problem.

Here’s how I disable THINGS in my rules.

		sendHttpPutRequest("http://192.168.0.230:8080/rest/things/hue:bridge:123abc/enable", "application/json", 'false', 5000)							// Disable Discovered HUE Bridge 1
			Thread::sleep(1500)  
		sendHttpPutRequest("http://192.168.0.230:8080/rest/things/hue:bridge:abc123/enable", "application/json", 'false', 5000)							// Disable Discovered HUE Bridge 2
		    Thread::sleep(1500) 

To ENABLE them; just change ‘false’ to ‘true’

I have rules to disable and enable THINGS based on Internet connectivity being lost and certain THINGS needing that Internet connectivity.

Best, Jay

https://openhab-scripters.github.io/openhab-helper-libraries/Guides/But%20How%20Do%20I.html#enable-disable-a-thing

@ NoneWhereTo
My Problem is the Fritz-Repeater. Sometimes he disables and enables connection to FritzBox for approx. 10 seconds. In this time Thing KEBA shows Connection_Error and does not work anymore. After disabeling and enabeling again all is fine till next break of Fritz-connection

@ m4rk and 5iver
Thanks for your try to help, but i don´t understand what you want to tell me, - i am just a stupid user and have really no idea about programming!

@ jwiseman
Also thanks for help, i took your idea and tried to create a rule to disable and enable my KEBA-Thing:
rule “TEST”
when
Item PowerLadung received command ON
then
createTimer(now.plusSeconds(10), [ |
sendHttpPutRequest(“http://192.168.1.36:8080/rest/things/keba:kecontact:095e5da8/enable”, “application/json”, ‘false’)])
createTimer(now.plusSeconds(30), [ |
sendHttpPutRequest(“http://192.168.1.36:8080/rest/things/keba:kecontact:095e5da8/enable”, “application/json”, ‘true’)])

end

As trigger i use a switch, i had in my items, and with this switch it works. Now i would like to trigger the rule with the Event:

[hingStatusInfoChangedEvent] - ‘keba:kecontact:095e5da8’ changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): An exception occurred while while polling the charging station

and i have no idea how to realise this.

Example rule here

Problem solved
Many thanks to all helpers, specially to jwiseman and rosko57!

Great !!!

    Many thanks for help

    It works and i am happy!

    Elmar (Schmitt)
1 Like