HTTP binding how to handle a problem

Hi, im using the http binding to get json data from a Raspberry which
collects data like ( Temp, and so on) from my pool. This works perfect.
BUT the power cord to the pool is switched off for the night so i get hundreds
of messages in the openhab logfile. It would be great if their is a possibility to switch
off the http polling for a defined time period.
My question : Is this possible ???

Yes, I think it would be possible using a rule
Perhaps post your setup and we can try to get you going. Shows items, things and rules

Hello Andrew, thanks for your fast response. Im using openhab since many year and it controls my complete house, garden, garage, car and pool. So i have hundreds of items and rules. I will show u only the area with problems.

http.cfg from services


# configuration of the first cache item
kostal.url=http://WR-SolPik/api/dxs.json?dxsEntries=33555203&dxsEntries=33555459&dxsEntries=33556229&dxsEntries=33556238&dxsEntries=33556227&dxsEntries=33556230&dxsEntries=83886336&dxsEntries=83886592&dxsEntries=83886848&dxsEntries=83887106&dxsEntries=83887362&dxsEntries=83887618&dxsEntries=67109120&dxsEntries=16780032
kostal.updateInterval=60000
info.url=http://WR-PI-Info/json.dat
info.updateInterval=10000
regen.url=http://WR-PI-Regen/json.dat
regen.updateInterval=60000
senK.url=http://WR-PI-Sensor/json.dat
senK.updateInterval=60000
pool.url=http://WR-PI-Pool/json.dat
pool.updateInterval=60000
Bae.url=http://WR-PI-Baertram/json.dat
Bae.updateInterval=60000
Gar.url=http://WR-PI-Garage/json.dat
Gar.updateInterval=60000

as u can see their are a lot of pi-systems i collect data from. Some of them like Pool and Baertram loose
the power support during the night.

items:

Switch	WPumpe				"Wärmepumpe Pool"			<switch>		(Suntrol)		{channel="innogysmarthome:PSSO:SMARTHOME08:d72da58bdca343c6be326acd5950768d:switch"}
Switch	PPumpe				"Poolpumpe"				<switch>		(Suntrol)		{channel="innogysmarthome:PSS:SMARTHOME08:502d655f21704d5db2ce7e23d8484f7d:switch"}
DateTime Sauf				"Sonnenaufgang [%1$tH:%1$tM]"		<sun>			(Suntrol)		{channel="astro:sun:065a484f:rise#start"}
DateTime Sunt				"Sonnenuntergang [%1$tH:%1$tM]"		<sun>			(Suntrol)		{channel="astro:sun:065a484f:set#end"}
Number  PTemp				"Pooltemperatur [%.1f°C]"		<heating>		(Suntrol)		{http="<[pool:10000:JS(getTemp.js)]" }
Switch	Scha				"Bärtram"				<switch>		(Suntrol) ["Switchable"]{channel="tplinksmarthome:hs110:15D608:switch"}
Number  SchaW				"Ladestrom [%.2f W]"			<energy>		(Suntrol)		{channel="tplinksmarthome:hs110:15D608:power"}
Number  BaeTemp                         "Temperatur [%.1f °C]"                 <temperature>           (Heizung)               {http="<[Bae:60000:JS(getTe1.js)]" }
Number  BaeFeucht                       "Luftfeuchtigkeit [%.1f %%]"            <humidity>              (Heizung)               {http="<[Bae:60000:JS(getFe1.js)]" }
Number  BaeVolt1                        "KFZ-Batterie [%.1f V]"                 <energy>                (Heizung)               {http="<[Bae:60000:JS(getVo1.js)]" }
Number  BaeVolt2                        "Zusatzbatterie [%.1f V]"               <energy>                (Heizung)               {http="<[Bae:60000:JS(getVo2.js)]" }

So for ex the item PTemp gets the pool temperature during the day from wr-pi-pool. during the night i only get hundreds of log So my idea is to switch the polling off or set during runtime the updateinterval to 0 but i dont know if this is possible

Andrew is on the right track. Move to a Rule and:

  • trigger the rule using a cron expression
  • use the sendHttpGetRequest to make the requests

You will probably want to apply the transforms inside the Rule as well and then update the Items.

There are two ways you can handle skipping the requests when the RPi is offline. You can configure your cron to not run the Rule at night when it’s off, or you can use the Network binding to watch the RPi’s network status (i.e. does it respond to a ping) and only run the HTTP request when it’s listed as online.

I use this latter approach for my garage door openers to issue an alert when someone tries to open the garage door through openHAB but the garage door controller is offline for some reason.

NOTE: I hope you cleanly shutdown those RPis before switching them off or have some other mitigation in place. When any computer using flash based memory loses power while it is writing something, you can lose not only that file being written to but also any other files that happen to share that sector of storage. The way wear leveling works that means you can lose just about anything, such as part of the kernel for example, resulting in an unbootable or otherwise broken OS.

1 Like

Didn’t know that thanks

Thanks a lot, so i have a little work to do but cause i have my system running since years i know about the power off problem but in all the years i never had any problems by switching off the power.
Thanks again, maybe u have a little hint how i can combine the transform with the sendHttpGetRequest?

I have the same problem. I get json data from my automower and some of the values are not always available because they depend on the automower’s weather binding. So if I want to get them, json answers “successful”, but some of the data is missing. Any suggestion how to handle that because it happens every now and then and I cannot control it. Is the only way a rule that asks via sendhttpgetrequest? What if I don’t do anything. Are there any cons except the logged errors?

Yes

No consequences, just extra errors in your logs.

Thank you very much rlkoshak!

There is the middle way, by having the binding fetch raw data into an Item.
You can process updates to that Item in a rule, where you can add the intelligence to do things like “if this element doesn’t exist, don’t do that”.