otaviojr / node-red-contrib-smartthings

Allows you to control your devices and get their status using NodeRed
MIT License
32 stars 16 forks source link

Simulated Contact Sensor #2

Closed Tokter closed 4 years ago

Tokter commented 4 years ago

Hey Otávio,

I was also able to get it installed and working, great work!

I have a question though: My Node-Red runs on a raspberry pi, that monitors various hard wired door contacts via it's GPIO ports. I would like to push the open/close states of those contacts to my Smartthings hub, to a "Simulated Contact Sensor", so that I can run automations based on that Contact.

I tried to do it the same way as with a switch, by sending: { topic: "switch", payload: { value: (1|0) } }

But that doesn't seem to work. So I looked at: smartthings-openclose.js

It seems, based on:

 this.on('input', msg => {
                console.debug("Input Message Received");
                console.log(msg);

                if(msg && msg.topic !== undefined){
                    switch(msg.topic){
                        case "update":
                            this.reportStatus(msg);
                            break;
                    }
                }
            });

That this type of node only supports "update" but does not allows you change the state. Is this a limitation of Smartthings, or could this logic also be added to smartthings-openclose.js?

I hope my explanation make sense.

Thanks!

otaviojr commented 4 years ago

Hi Tokter,

OpenClose sensors doesn' t have a command to change their state. This is a SmartThings limitation. Yes

But, you can create a virtual switch at smartthings and change it' s state.

You can do that at SmartThings mobile App.

Go to Automation -> SmartApps -> Add SmartApp -> More -> Virtual Device Creator

At NodeRed use the OnOff node.

regards

Tokter commented 4 years ago

That's what I'm doing now, found this "Universal Virtual Device Type Translator" https://community.smartthings.com/t/release-universal-virtual-device-type-and-translator/47836/168

That seems to work, but the device is not selectable in the smartthings home monitor. Maybe because it shows up as a cloud device and not a local device.

I'm new to this and still have a lot to read and learn...

Thanks for the quick reply, I sent you some coffee money :)

otaviojr commented 4 years ago

Tokter,

get a look at this:

https://community.smartthings.com/t/simulated-contact-sensor/81392/6

Someone did a Garage Sensor which implements a switch and a contact sensor.

You can use the OnOff node to change it's state and it will report as a contact sensor.

As a contact sensor it will appears at Home Monitor.

that is more or less what you need.

regards

Tokter commented 4 years ago

Thanks, I got it working now. I learned that you need to use the classic app to do certain things. Starting to feel like smartthings ecosystem is a bit of a mess :(