I’,m using a python script to monitor all my devices state via the REST api. I would like to know if it’s possible to add a (multiple) button(s) for instance in a sitemap to allow me to get the status of this button (software, not hardware) allowing me to question the rest api and do some actions in my python script depending of the state of the button. The button is not linked to any item, it’s only a “software” button…
I don’t know if I was clear enough, but if so, how can I do that ? Do I have to create an item in the “item” folder ?
But will I be able to get the status of this button via the REST API ? because I don’t want to do any action in OH2, just to update this state and get it from the REST API. Do you have any documentation to know how to write the example you gave ? (what goes where )
The Item that you will define will have a State (ON or OFF for a Switch Item type)
You will be able to obtain that state from the REST API.
Keep in mind that if you use the example above, the Switch Item will always have the State: ON (since when you press it on your sitemap, it will send only the ON command to the Switch.
This item does not have to be bound to any binding. It can be a software only “button” in OH2 without any connection to any external system.
A simpler example (for a Switch without any binding used) is:
Example Item:
Switch Robo500 "Robo 500"
Example Sitemap:
Switch item=Robo500 mappings=[ON="GO!"]
The Sitemap entry will make the Switch appear as a “Button”
Keep in mind that it’s basically a Switch with a state (there is no “Button” Item Type in OH2)
Since you provided a premium support, I need your help for something similar : is it possible to have a SetPoint not linked to an item. I would like to have one to use it in my python script to set a level threshold to send me a push notification on my mobile if the temperature on one of my devices drop below a certain amount…
I tried to set an Item like this : Setpoint TempAlert “Temperature Threshold”
Then in the sitemap, lilke this : Setpoint label=“Temperature threshold [%.1f °C]” item=Temp minValue=4.5 maxValue=30 step=0.5
The problem is that since it’s not linked to an item, I don’t get any value saved in the variable read by %.1f… Is there a workaround this ?
Thanks in advance
Edit : I tried to find info in the documentation but I was not able to find anything helpful
You cannot have ANYTHING on your sitemap not mapped to an Item except for a Frame. You have to create an Item to receive the value. As with the above, you don’t have to have this Item bound to anything.
It keeps the Item State internally in some OSGi tables (or something similar I don’t remember now)
Additional note: The State does not survive a restart of the OH2 service. To bring back the State after a OH2 service restart, you need to use a Persistence Service with a restoreOnStartup strategy. Read more on Persistence here: http://docs.openhab.org/configuration/persistence.html