On an RPi with an RPi Camera, I am running the Motion software that detects motion.
On a computer in the same local network, I can use a browser to turn off saving detection images with this:
http://192.168.1.104:8080/0/config/set?output_pictures=off
I can use a browser to turn on saving detection images with this:
http://192.168.1.104:8080/0/config/set?output_pictures=on
I need the OpenHAB entries to achieve these changes in a Motion configuration , but I’m having trouble getting the correct ones.
I would prefer an item (switch?) perhaps using the HTTP Binding.
A rule or rules would also be helpful. Thanks
1 Like
You dont need a rule. Just create an item and configure that item for the HTTP Binding. It will be a single line in your .item file. Everything you need is here:
https://docs.openhab.org/addons/bindings/http1/readme.html
Thanks for replying, Lucky. I am aware of the official OpenHAB docs on http binding, esp about item configuration & am trying to model my item on that.
In my motion.conf, webcontrol passworth authorization is OFF. Again in a computer’s browser in the same local network, this turns on output_pictures in the Motion Software:
http://192.168.1.104:8080/0/config/set?output_pictures=on
& …=off turns it off.
I've tried these versions of the item:
Switch GarageCamOutput { http=">[ON:POST:http://192.168.1.104:8080/0/config/set?output_pictures=on] >[OFF:POST:http://192.168.1.104:8080/0/config/set?output_pictures=off]" }
Switch GarageCamOutput { http=">[ON:POST:http://192.168.1.104:8080/0/config/set?output_pictures=on&type=text] >[OFF:POST:http://192.168.1.104:8080/0/config/set?output_pictures=off&type=text]" }
Switch GarageCamOutput { http=">[ON:POST:http://192.168.1.104:8080/0/config/set?output_pictures=on&type=text/plain] >[OFF:POST:http://192.168.1.104:8080/0/config/set?output_pictures=off&type=text/plain]" }
Switch GarageCamOutput { http=">[ON:POST:http://192.168.1.104:8080/0/config/set?output_pictures=on&type=html] >[OFF:POST:http://192.168.1.104:8080/0/config/set?output_pictures=off&type=html]" }
Switch GarageCamOutput { http=">[ON:POST:http://192.168.1.104:8080/0/config/set?output_pictures=on&type=text/html] >[OFF:POST:http://192.168.1.104:8080/0/config/set?output_pictures=off&type=text/html]" }
As a result, in the openhab logs, no errors show for the item.
When I click the User Interface switch to the on position, the logs show:
Item 'GarageCamOutput' received command ON
GarageCamOutput changed from OFF to ON
But the output_pictures setting in the Pi’s Motion software does not change to on.
Can someone see what I need to get this to work?
Flole
(Flole)
March 3, 2018, 3:06pm
4
You need to distinguish between GET and POST requests
Thanks much, Flole, that works. The GET request did not seem logical for a command to change a state.
Changing POST to GET like the following works great.
Switch GarageCamOutput { http=">[ON:GET:http://192.168.1.104:8080/0/config/set?output_pictures=on] >[OFF:GET:http://192.168.1.104:8080/0/config/set?output_pictures=off]" }
That really depends on how the other end (receiving end) is processing the rest calls