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

Different value for status and sensor #75

Closed sdalu closed 2 years ago

sdalu commented 2 years ago

For example

The status node report:

payload.status.components.main.contactSensor.contact.value : "closed'

The contact node report:

payload.value: 1

Shouldn't the same be reported ?

otaviojr commented 2 years ago

It should report

payload.value: 0

Regards

sdalu commented 2 years ago

Sorry, my mistake, it is payload.value: 0. I wanted to say 0 (integer) vs closed (string). I was expected to have exactly the same value.

otaviojr commented 2 years ago

@sdalu I make this conversion internally. It's easy to remember when using the nodes. There are many values active/inactive, open/closed, on/off, and you need to remember them when using those nodes. So, they are all converted to 1/0.

I was thinking about those people who don't know all smartthings internals.

Regards

sdalu commented 2 years ago

Shouldn't this conversion also be made on the status node ?

otaviojr commented 2 years ago

@sdalu The status node was a contribution, was not written by me, and yes, it should. I will correct that.

Regards

otaviojr commented 2 years ago

@sdalu I think that the status device should not exist at all, I will remove it. It is the same as the openclose sensor...

Please, use the open/close sensor...

Regards

sdalu commented 2 years ago

For me it is not the same as the open/close (doc is wrong) but an aggregation of all the sensors available on a device. As a full report is for example:

{
    "topic": "device",
    "payload": {
        "deviceId": "85272aa2-78db-4e80-8585-849469710190",
        "name": "Door watcher",
        "status": {
            "components": {
                "main": {
                    "contactSensor": {
                        "contact": {
                            "value": "closed",
                            "timestamp": "2022-06-08T19:08:23.196Z"
                        }
                    },
                    "threeAxis": {
                        "threeAxis": {
                            "value": [
                                -1010,
                                31,
                                13
                            ],
                            "unit": "mG",
                            "timestamp": "2022-06-08T22:01:56.533Z"
                        }
                    },
                    "configuration": {},
                    "healthCheck": {
                        "checkInterval": {
                            "value": 720,
                            "unit": "s",
                            "data": {
                                "protocol": "zigbee",
                                "hubHardwareId": "0036",
                                "offlinePingable": "1",
                                "deviceScheme": "TRACKED"
                            },
                            "timestamp": "2022-03-31T21:10:23.252Z"
                        },
                        "healthStatus": {
                            "value": null
                        },
                        "DeviceWatch-Enroll": {
                            "value": null
                        },
                        "DeviceWatch-DeviceStatus": {
                            "value": null
                        }
                    },
                    "temperatureMeasurement": {
                        "temperature": {
                            "value": 27.1,
                            "unit": "C",
                            "timestamp": "2022-06-08T22:05:26.978Z"
                        }
                    },
                    "refresh": {},
                    "sensor": {},
                    "battery": {
                        "battery": {
                            "value": 100,
                            "unit": "%",
                            "timestamp": "2022-03-31T21:10:06.836Z"
                        }
                    },
                    "accelerationSensor": {
                        "acceleration": {
                            "value": "inactive",
                            "timestamp": "2022-06-08T22:02:06.623Z"
                        }
                    }
                }
            }
        }
    },
    "_msgid": "3853a0c3d871ff26"
}

I find it useful to have all the sensors value aggregated in one message (even if I wouldn't have necessarily formatted it this way)

otaviojr commented 2 years ago

@sdalu The problem is that you can only select contact sensors devices. Since it query by the contactSensor capability.

sdalu commented 2 years ago

Argh, I thought/hoped it was a generic one :(

otaviojr commented 2 years ago

@sdalu I will try to change it to allow a more global selection, all devices, not only contact sensors. But this node will have no treatment, and they will output the raw value. No 1/0, but the original value. They will be an exception.

otaviojr commented 2 years ago

@sdalu I update the module, version 0.0.39, with this change. Now, the status node allows you to select any device, and it will output the raw json sent by SmartThings API without any further treatment.

I think this node could be useful as a debug node and to allow people to receive status from some device/sensor that this module does not contemplate yet. And, as in your case, to receive more than one value on the same node.

The downside is that some knowledge of SmartThings internals will be required.

Regards