andrew-codechimp / HA-Battery-Notes

A Home Assistant integration to provide battery notes of devices
MIT License
505 stars 87 forks source link

Device: Bosch - Door_window_contact_II_BSEN_C2 #1795

Closed github-actions[bot] closed 3 months ago

github-actions[bot] commented 3 months ago

This pull request adds the device information for Door_window_contact_II_BSEN_C2 by Bosch with 1x CR123 It closes issue #1794

rmi1974 commented 3 months ago

For reference, following links:

Bosch vendor product link: https://www.bosch-smarthome.com/uk/en/products/devices/doorwindow-contact/ Zigbee2mqtt device link: https://www.zigbee2mqtt.io/devices/BSEN-C2.html

Model   BSEN-C2
Vendor  Bosch
Description Door/window contact II

It lists model as "BSEN-C2" but HA showed it as concatenated with description "Door/window contact II (BSEN-C2)".

Could you shorten it to BSEN-C2 or cancel the PR and I will re-create device entry.

andrew-codechimp commented 3 months ago

For reference, following links:

Bosch vendor product link: https://www.bosch-smarthome.com/uk/en/products/devices/doorwindow-contact/ Zigbee2mqtt device link: https://www.zigbee2mqtt.io/devices/BSEN-C2.html

Model BSEN-C2
Vendor    Bosch
Description   Door/window contact II

It lists model as "BSEN-C2" but HA showed it as concatenated with description "Door/window contact II (BSEN-C2)".

Could you shorten it to BSEN-C2 or cancel the PR and I will re-create device entry.

I've shortened this so should be good next time your HA updated the library (every 24 hours or restart)

rmi1974 commented 3 months ago

Hello again,

I've tested the change on my HA instance but it doesn't recognize it.

zigbee2mqtt exposes the device as:

{
    "ac_status": false,
    "battery": 100,
    "battery_defect": false,
    "battery_low": false,
    "contact": true,
    "last_seen": 1719485057638,
    "linkquality": 58,
    "restore_reports": true,
    "supervision_reports": true,
    "tamper": false,
    "test": false,
    "trouble": false,
    "vibration": false,
    "action": null,
    "device": {
        "applicationVersion": 1,
        "dateCode": "20220602",
        "friendlyName": "Badezimmer Tür Türkontakt",
        "hardwareVersion": 1,
        "ieeeAddr": "0x18fc260000002f3f",
        "manufacturerID": 4617,
        "manufacturerName": "BOSCH",
        "model": "BSEN-C2",
        "networkAddress": 58851,
        "powerSource": "Battery",
        "softwareBuildID": "1.18.01",
        "stackVersion": 5,
        "type": "EndDevice",
        "zclVersion": 3
    },
    "elapsed": 2898
}

->

       "model": "BSEN-C2",

But HA lists the device under Model as:

Door/window contact II (BSEN-C2)

Looking at the MQTT info from HA it says:

availability:
  - topic: zigbee2mqtt/bridge/state
  - topic: zigbee2mqtt/Badezimmer Tür Türkontakt/availability
availability_mode: all
device:
  identifiers:
    - zigbee2mqtt_0x18fc260000002f3f
  manufacturer: Bosch
  model: Door/window contact II (BSEN-C2)
  sw_version: 1.18.01
  via_device: zigbee2mqtt_bridge_0x00124b0026b699be
  name: Badezimmer Tür Türkontakt
device_class: door
json_attributes_topic: zigbee2mqtt/Badezimmer Tür Türkontakt
object_id: badezimmer_tür_türkontakt_contact
origin:
  sw_version: 1.38.0
  name: Zigbee2MQTT
  support_url: https://www.zigbee2mqtt.io
payload_off: true
payload_on: false
state_topic: zigbee2mqtt/Badezimmer Tür Türkontakt
unique_id: 0x18fc260000002f3f_contact_zigbee2mqtt
value_template: '{{ value_json.contact }}'
platform: mqtt

I don't understand this behaviour, that is who concatenates the device model and description into "model" that HA sees. I guess your integration looks for the HA/concatenated "model" name, hence it doesn't appear in my HA after restart. Yes, I've validated that this integration is up-to-date with this PR merged.

So my correction request to shorten the model was wrong. I also found earlier PRs for some devices which also have this concatenated model name thingy. Example:

https://github.com/andrew-codechimp/HA-Battery-Notes/issues/1770

Should a create a new issue, copying my recent finding to fix this PR? Sorry for the inconvenience caused.

Regards

andrew-codechimp commented 3 months ago

Hi, this is never easy or consistent though I usually find Z2M honours the model in the docs. I've changed this to Door/window contact II (BSEN-C2) so a HA restart will put the new library.

rmi1974 commented 3 months ago

Hi again!

It works now. All devices of this type are recognized.

image

Thank you. Great support. :+1:

This project is super useful. I was looking for this for years and previously had a poor man's solution with device templating + date/time helpers. Your project should be really baked into HA (core) as many devices are battery operated. Tracking battery life-cycle is super important.

andrew-codechimp commented 3 months ago

Glad we got that sorted and thanks for the kind feedback, it's been great to see how many people have embraced this component and helped to make it better. I doubt this will ever get into core as the battery library maintenance is a bit of a commitment they'd not want to take on. Still, it seems many have found it via HACS and you'll get much quicker fixes via this method when there are any issues.