zwave-js / zwave-js-ui

Full featured Z-Wave Control Panel UI and MQTT gateway. Built using Nodejs, and Vue/Vuetify
https://zwave-js.github.io/zwave-js-ui
MIT License
965 stars 205 forks source link

[bug] FGMS001 motion detection does not update MQTT sensor state (48-0-Any) #104

Closed katiuskt closed 3 years ago

katiuskt commented 3 years ago

Version

Build/Run method

zwavejs2mqtt version: I'm not sure how to get this. I'm using zwavejs/zwavejs2mqtt:dev pulled on 21st Dec

Describe the bug ZwaveJS2MQTT is not updating the motion information (topic 48-0-Any) for the Fibaro FGMS001 motion sensor.

If I understand properly, for this device ZwaveJS2MQTT idenfity a contact device with topic 48-1-0. It should be a binary_sensor with value True if there is motion and False if there is no motion.

Unfortunately, although the sensor detects a motion event (led is on in the physical device; you can also see it in the screenshots below at topics with CC 113), the state of the 48-0-Any topic remains on the state which it intially has when pairing the device.

No motion: image

Motion: image

To Reproduce Steps to reproduce the behavior: Pair a Fibaro FGMS001 motion sensor Trigger a motion event Check your MQTT broker if the value of the 48-0-Any topic is updated.

Expected behavior Having the topic for this sensor updated in correspondence of the motion events. That way you could have a HASS binary_sensor for presence.

Additional context This seems to be exactly the same issue reported in https://github.com/OpenZWave/Zwave2Mqtt/issues/621 for the Zwave2MQTT project. In that project the root cause pointed out towards an issue at OZW implementation. Apparently to https://github.com/OpenZWave/open-zwave/issues/2300 Just in case the comments on it helps here somehow (I don't understand the final conclusion of that case)

varet80 commented 3 years ago

I fae the issue with the same sensor. and sometimes becomes true. and stays true. Reading debug log of the driver, Notification is the command class they update when motion is detected. and not the binary.

I do not know the reason but seems device is not sending to driver. I use the Notification CC for motion detection.

based on the reply of OZW and my observations from debug log. Device acts as the new specification sais

Fishlando

You should investigate the config options of the device to see if it can be set to send a SENSOR_BINARY (but note - that SENSOR_BINARY is depreciated by the specifications and isn't used on newer devices - So its possible that this device wont support it)
katiuskt commented 3 years ago

Based on the latest comment at the above mentioned OZW case where this very same behavior was discussed:

If you want the "older" sensor reports... Add your controller to the 4th association group. This group is used for "backwards compatibility". The ZW5 by default uses the newer "notification CC".

I'm not sure if I want the "older sensor reports" but I would like to have a binary_sensor with a boolean behavior for HASS so I think "let's try it". So, taking a look at the sensor documentation, it seems like you could set some associations for it as mentioned into the OZW case: image

Unfortunately only the "Tamper" associations are shown as options for configuration into ZwaveJs2MQTT: image

Is it expected?

varet80 commented 3 years ago

Based on the latest comment at the above mentioned OZW case where this very same behavior was discussed:

If you want the "older" sensor reports... Add your controller to the 4th association group. This group is used for "backwards compatibility". The ZW5 by default uses the newer "notification CC".

I'm not sure if I want the "older sensor reports" but I would like to have a binary_sensor with a boolean behavior for HASS so I think "let's try it". So, taking a look at the sensor documentation, it seems like you could set some associations for it as mentioned into the OZW case: image

Unfortunately only the "Tamper" associations are shown as options for configuration into ZwaveJs2MQTT: image

Is it expected?

this morning on dev branch we released a patch, which creates the notification entity. I am also working on introducing human readable payload to HASS which instead of 0/8 shows the state per the Specification of Z-wave

katiuskt commented 3 years ago

this morning on dev branch we released a patch, which creates the notification entity. I am also working on introducing human readable payload to HASS which instead of 0/8 shows the state per the Specification of Z-wave

Oh, great news! Would that mean a tipical binary_sensor in HASS could be used? Or it means those 0/3/8 values will be reported in a more understandable words ("Tampering, product covering removed", "Motion Detection, unknown location")?

Also, does it means the current contact binary_sensor is useless, right?

varet80 commented 3 years ago

you can create your own Binary sensor with custom devices. and Zj2m will create this entity. copy another binary sensor and post it. If you give me a bit of time I can help you on this.

an example would be:

    {
      "type": "binary_sensor",
      "object_id": "Motiont",
      "discovery_payload": {
        "value_template": "{{ value_json.value }}",
        "payload_on": 8,
        "payload_off": 0,
        "device_class": "temperature",
        "state_topic": "67-1-setpoint-1"
      },
      "values": [
        "67-1-setpoint-1"
      ]
    },

this is a sensor, binary supports vlue_on and value_off you need to fix static point with the full name of 113 class, and values! also attach thsi under the list of the Id of the device --

To answer the other question: yes as you will get on your screen a name, now shows numbers like my screenshot: Screenshot 2020-12-21 200341

robertsLando commented 3 years ago

@AlCalzone

AlCalzone commented 3 years ago

Yes? What?

robertsLando commented 3 years ago

Unfortunately, although the sensor detects a motion event (led is on in the physical device; you can also see it in the screenshots below at topics with CC 113), the state of the 48-0-Any topic remains on the state which it intially has when pairing the device.

@AlCalzone this remeber me another issue

katiuskt commented 3 years ago

Thank you @billiaz: I'll try to figure it out to create a boolean device. If not, I guess I could create a binary_sensor in HASS with values taking from template of the autodiscovered from ZwaveJ2MQTT.

Regarding the option mentioned in Sensor documentation (and also into the OZW issue) about the posibility to include the sensor into group 4 for backwards compatibility: In OpenHAB (completely different ZWave stack than OZW and ZwaveJS apparently) is possible to do that image

Is expecting not having those options in ZWaveJS2MQTT?

robertsLando commented 3 years ago

@katiuskt Did you try to do it from groups tab? There you can manage associations

AlCalzone commented 3 years ago

That are the associations. You can add the controller node (usually 1) to the node's group.

this remeber me another issue

@robertsLando I still don't follow...

katiuskt commented 3 years ago

Thank you all

@robertsLando : Thank you, I didn't notice about the "Group" option into the GUI. Still not understanding well how to put the sensor on group 4 (Motion BC) but I'll figure it out.

@billiaz : Thank you for your tip. In first place I wasn't able to create the HASS Device JSON properly in ZwaveJS2MQTT so I created a binary_sensor directly into HASS with templates to map de values (0/8). Finally, I get it and I get the device created directly into ZWaveJS2MQTT:

{ "type": "binary_sensor", "object_id": "motion", "discovery_payload": { "payload_on": 8, "payload_off": 0, "value_template": "{{ value_json.value }}", "device_class": "motion", "state_topic": "zwavejs/HC/MotionSensor/113/0/Home_Security/Motion_sensor_status", "json_attributes_topic": "zwavejs/HC/MotionSensor/113/0/Home_Security/Motion_sensor_status", "device": { "identifiers": [ "zwavejs2mqtt_0xf77d3d75_node10" ], "manufacturer": "Fibargroup", "model": "Motion Sensor (FGMS001)", "name": "HC-MotionSensor", "sw_version": "3.2" }, "name": "HC-MotionSensor_motion", "unique_id": "zwavejs2mqtt_0xf77d3d75_10-113-0-Home Security-Motion" }, "discoveryTopic": "binary_sensor/HC-MotionSensor/notification_home_security_motion_sensor_status/config", "values": [ "113-0-Home Security-Motion sensor status" ], "persistent": false, "ignoreDiscovery": false, "id": "binary_sensor_motion" }

To whom may concern (@robertsLando maybe?) I'm aware of https://github.com/zwave-js/zwavejs2mqtt/issues/94 and https://github.com/zwave-js/zwavejs2mqtt/pull/105 so I think with them ZwaveJS2MQTT is managing Motion Sensor in a better way but I have a suggestion: Is it possible to provide a "binary_sensor" (device_class = motion) mapping the motion to true and the idle status to false? Basically something like the JSON I've defined (with improvements if they are needed).

Without it you still get the binary_sensor_contact (48-0-Any; no real use at least in my case due to its not updating value at all) but not a real binary_sensor for motion. I'm aware you'll get the "Home_Security/Motion_sensor_status" notification device (with descriptive names thanks to @billiaz ) but in the end you will need to do the map in HASS if all you need is the usual motion binary_switch. Wouldn't be great providing that device from zwavejs2mqtt ready to be autodiscovered?

AlCalzone commented 3 years ago

Still not understanding well how to put the sensor on group 4 (Motion BC) but I'll figure it out.

No, you don't put the sensor there. These are the device's groups. You put the controller (node 1) there so it receives the messages from group 4.

katiuskt commented 3 years ago

No, you don't put the sensor there. These are the device's groups. You put the controller (node 1) there so it receives the messages from group 4.

Thank you @AlCalzone! It makes totally sense to me now!

robertsLando commented 3 years ago

Is it possible to provide a "binary_sensor" (device_class = motion) mapping the motion to true and the idle status to false? Basically something like the JSON I've defined (with improvements if they are needed).

Is this always like that? I mean is that value always used for such purposes? If so we can do it

AlCalzone commented 3 years ago

The "any" sensor comes from an older CC version that does not specify the sensor type. I don't think it is correct to always map that to motion.

robertsLando commented 3 years ago

I don't think it is correct to always map that to motion.

That's what I was thinking

katiuskt commented 3 years ago

OK, thanks, understood.

I'll close this issue and I'll create manually the device to map the CC-113 message (notification_home_security_motion_sensor_status) to a boolean binary_sensor (device_class = motion) as suggested by @billiaz

Gis70 commented 3 years ago

Hello guy's i'm facing the same issue, so what did you do exactly in zwave-js2mqtt to make the motion detection work ? could you explain ? thx