mjwwit / node-red-contrib-ikea-tradfri

Node-RED nodes to get updates from and control devices connected to an IKEA TRADFRI gateway
3 stars 3 forks source link

"sensor" object of motion sensor status has empty/zero values #22

Closed matthiashh closed 2 years ago

matthiashh commented 2 years ago

I just got some trådfri devices to play with and want to use the motion sensor state in node-red to trigger behaviors.

I implemented two ways to retrieve information, "tradfri-monitor" and "tradfri-state". In both cases I get the basic information about my device plus the "sensor" object, but all the values are empty strings or 0s:

{
  "event": "device updated",
  "type": "motionSensor",
  "instanceId": 65551,
  "name": "TRADFRI motion sensor",
  "alive": true,
  "lastSeen": "2021-12-26T01:30:20.000Z",
  "deviceInfo": {
    "isProxy": true,
    "options": {},
    "firmwareVersion": "2.0.022",
    "manufacturer": "IKEA of Sweden",
    "modelNumber": "TRADFRI motion sensor",
    "power": "Battery",
    "otaImageType": 0,
    "serialNumber": "",
    "UNKNOWN1": 0,
    "battery": 74
  },
  "otaUpdateState": 0,
  "sensor": {
    "appType": "",
    "maxMeasuredValue": 0,
    "maxRangeValue": 0,
    "minMeasuredValue": 0,
    "minRangeValue": 0,
    "resetMinMaxMeasureValue": false,
    "sensorType": "",
    "sensorValue": 0,
    "unit": ""
  }
}

Debugging info:

The log does not say anything specific:

26 Dec 13:24:37 - [info] [tradfri-state:Motion Sensor] Retrieving current state of accessories: [65551] and groups: []
26 Dec 13:24:43 - [info] [tradfri-config:My Gateway] Accessory updated: 65551 TRADFRI motion sensor

I paired the sensor with the gateway again and it lives in its group by now, but still gives empty/zero status information. It can interact with other trådfri devices when directly coupled to them.

Other than that things seem to look great and I am looking forward to build a larger system with them. Thanks a lot for writing it. Let me know if I can supply anything else to help debugging this.

mjwwit commented 2 years ago

Sensors are sadly still unsupported by the tradfri library used in this project: https://github.com/AlCalzone/node-tradfri-client#sensor---not-supported. It looks like it may not be trivial to add this either: https://github.com/AlCalzone/node-tradfri-client/issues/495.

As soon as support is added, I'll update the plugin to support it as well.

matthiashh commented 2 years ago

Thanks for the info. I was not aware of that. Since the examples for the monitor and status node in the readme has values:

    "sensor": {
      "sensorType": "sensor type (motionSensor)",
      "minRangeValue": 0,
      "minMeasuredValue": 10,
      "maxMeasuredValue": 90,
      "maxRangeValue": 100,
      "sensorValue": 25
    },

I assumed that they would work. I'll append a commit to #21 to clarify that.

Motion sensor support is crucial for me. Let's hope that it gets added. I also noticed that an (empty) motion sensor event appears at the monitor node when sth is detected - maybe that could work as a workaround. Not yet sure how reliable that trigger is though.

matthiashh commented 2 years ago

This is outside the scope of this project, but I'll leave it here in case somebody is wondering.

When directly pairing the IKEA motion to a coordinator such as CC2531 (not recommended) that uses other Zigbee software such as ZHA with Home Assistant, the motion sensors reports motion directly.