Control the status of a virtual contact switch


(Carter) #1

I am trying to set the status of a contact sensor using my raspberry pi + sensor and using this framework to send message to a smartapp: I can get the status of the sensor but I am unsure on how to change it so it would appear open/closed.

This is what I am currently doing:

python --type contact --id “myid” --request contact=true

and get this back:

{‘device’: {u’id’: u’myid’,
u’label’: u’Garage Door’,
u’mqtt’: u’tcp://’,
u’type’: u’contact’,
‘url’: u’’,
u’value’: {u’contact’: False, u’timestamp’: None}},
‘request’: {‘contact’: ‘true’}}

Any advice because the status never changes?
Also if there is a easier way or alternative for using an already setup switch connected to a raspberry pi im eager to learn something :smile:

Thank you!

(Tim Slagle) #2

Hey @RetraC

I would recommend setting up and endpoint if you haven’t already. You can see the details on how to do that here:

(Carter) #3


I believe I have the endpoint set up. (It works for reading the status’s of all the devices and can even set a switch value to 1 or 0. I just cant figure out how to set a contact switch to open or closed (1 or 0).
Here is what my endpoint looks like: