sgupta999 / mqtt-bridge-smartthings

MQTT Bridge To SmartThings [MBS]
MIT License
27 stars 15 forks source link

External sensors #11

Open robross0606 opened 4 years ago

robross0606 commented 4 years ago

Most of the instructions and design focus on exposing ST devices to external systems. However, I would like to introduce external sensors (motion, open/close, etc.) into ST. It is unclear to me how I could create a device in SmartThings that equates to a device that originated in HomeAssistant. I've seen some discussion of using virtual switches for simple on/off switches, but how can this be done for sensors?

sgupta999 commented 4 years ago

I think like the contact sensor several other capabilities are also missing action methods - this is the legacy part - these i think like the contact sensor were just meant to change state and not trigger an event. if you are going to specify a command suffix then action method needs to be defined.

I am glad it worked for you - you are our first direct hass integration using legacy code - glad to know i did not break the legacy implementation

robross0606 commented 4 years ago

Once I know this is working, I'll switch over to the new method and break everything again. 😉

sgupta999 commented 4 years ago

no the new method is a lot more easier and error checked - i couldn't check anything with the hass part before.

everything in the new part is assumed to be an active command - if you don;t want anything to happen just dont specify the action method.

sgupta999 commented 4 years ago

i don't know if ADT pulse is using wired or wireless sensor but I had a 25 year old security system in the house just attached the wires from com port in parallel to a wemos d1 and st_anything and instantaneous alerts in ST. if all your wires from the alarm system come to a central box that is the way to go.

robross0606 commented 4 years ago

ADT Pulse is an annoying beast. It is a "smart" system that connects to an older security board so I think it is "in the way" of me connecting to the central box. The Pulse hub is already connected to the serial pins on the central box. This is still a monitored system, so I have to be careful how I muck with it for now. Once my contract is up, I will be looking at all sorts of alternatives because Pulse sucks.

robross0606 commented 4 years ago

WTH, it suddenly stopped working again for contact sensors. I touched nothing but starting to see this in the ST IDE Live Log:

50e3cfa0-8b6a-4760-99c6-e0301448b22b 3:51:44 PM: error java.lang.IllegalArgumentException: Command 'close' is not supported by device a33e3a9b-7500-4526-8ba4-b1056193244a of type 'Virtual Contact Sensor'. Supported commands: [open, closed] @line 719 (actionOpenClosed)
50e3cfa0-8b6a-4760-99c6-e0301448b22b 3:51:44 PM: debug Calling action method actionOpenClosed, for attribute contact, for device Front Door with payload closed
50e3cfa0-8b6a-4760-99c6-e0301448b22b 3:51:44 PM: debug Received device event from bridge: [command:true, name:Front Door, type:contact, value:closed]

How on EARTH is the command attempting to send "close" when the payload in the log file confirms the value is "closed"?

sgupta999 commented 4 years ago

I have done a similar mistake in the past.

the default method in DTH is close even thought attribute value is 'closed'.

Did you overwrite the original method's name from close to closed or are you using a new DTH with a closed method instead of close. just check the device handlers change closed method to close

robross0606 commented 4 years ago

I just figured it out a second ago. The method in the device was close() but the command attribute at the top was "closed". Not sure when or how that changed but it is working now. I'm not touching it again for the rest of the weekend. I swear! 😃

sgupta999 commented 4 years ago

Welcome to quirks of ST :) my logs are very extensive for now just to diagnose these kind of errors