dresden-elektronik / deconz-rest-plugin

deCONZ REST-API plugin to control ZigBee devices
BSD 3-Clause "New" or "Revised" License
1.89k stars 496 forks source link

Ikea Badring #7663

Closed Emlben closed 4 months ago

Emlben commented 6 months ago

Is there already an existing issue for this?

Product name

Ikea Badring

Manufacturer

Ikea

Model identifier

BADRING Water Leakage Sensor

Device type to add

Sensor

Node info

image

Endpoints and clusters

image

Basic

image

Further relevant clusters

Power Configuration

image

On/Off

Level Control

Color Control

Thermostat

Simple Metering

Electrical Measurement

Any other cluster of relevance/interest

(My first attempt to provide this information - please bare with me ;) ) image

github-actions[bot] commented 5 months ago

As there has not been any response in 21 days, this issue has been automatically marked as stale. At OP: Please either close this issue or keep it active It will be closed in 7 days if no further activity occurs.

Hector47 commented 5 months ago

I also have the same sensor. How can I help ? Do you have an DDF a can use as base ?

danielchansen commented 5 months ago

Same. Have four of these sensors. Anything I can do to contribute?

Mimiix commented 5 months ago

@Smanar can you take a look?

Smanar commented 5 months ago

Someone have started a DDF here https://forum.phoscon.de/t/ddf-for-ikea-device-badring-water-leakage-senor/4736

RP-Develop commented 5 months ago

This DDF don't run. I get no alarm from the sensor. Only if I read it manually, so I get a changing in 0x0500 / 0x0002.

Bildschirmfoto 2024-04-07 um 15 11 11 Bildschirmfoto 2024-04-07 um 15 11 46

Is it possible to set the sensor so that it sends the alarm?

Smanar commented 5 months ago

Hello can you try this DDF

{
  "schema": "devcap1.schema.json",
  "manufacturername": "$MF_IKEA",
  "modelid": "BADRING Water Leakage Sensor",
  "vendor": "IKEA",
  "product": "BADRING Water Leakage Sensor",
  "sleeper": true,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_WATER_LEAK_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0500"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "config/checkin"
        },
        {
          "name": "attr/productid",
          "refresh.interval": 86400
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/alert",
          "default": "none"
        },
        {
          "name": "config/battery",
          "awake": true,
          "refresh.interval": 86400,
          "read": {
            "at": "0x0021",
            "cl": "0x0001",
            "ep": 1,
            "fn": "zcl:attr"
          },
          "parse": {
            "at": "0x0021",
            "cl": "0x0001",
            "ep": 1,
            "eval": "Item.val = Math.round(Attr.val / 2)",
            "fn": "zcl:attr"
          },
          "default": 0
        },
        {
          "name": "config/group"
        },
        {
          "name": "config/pending"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "config/enrolled",
          "public": true
        },
        {
          "name": "state/water",
          "awake": true
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0500"
    }
  ]
}

You miss the enrollement on previous one.

RP-Develop commented 5 months ago

Hi Smanar,

sorry, but it don't work. I don't get the alarm. The state has no values.

some from the Phoscon Web:

image image
Smanar commented 5 months ago

"enrolled" : null.

The enrollement have failed. Have you tried to re-include it ?

RP-Develop commented 5 months ago

maybe helpful:

When I read out the IAS manually, I get these messages in the debug view of the IAS::

19:13:26:010 Force binding of attribute reporting for node BADRING Water Leakage Sensor 2 19:13:56:091 [IAS ZONE] - Address 0xB0C7DEFFFE67151B, Payload 0000003000010000312a00020000190000100000f00000000000000000, Command 0x01 19:13:56:093 [IAS ZONE] - 0xB0C7DEFFFE67151B No IAS sensor found for endpoint: 0x01 19:13:57:100 [IAS ZONE] - Address 0xB0C7DEFFFE67151B, Payload 11000020ff, Command 0x01 19:13:57:101 [IAS ZONE] - 0xB0C7DEFFFE67151B No IAS sensor found for endpoint: 0x01

RP-Develop commented 5 months ago

"enrolled" : null.

The enrollement have failed. Have you tried to re-include it ?

yes:

image

I started with your DDF.

Smanar commented 5 months ago

Ha my bad, I forget the fingerprint

{
  "schema": "devcap1.schema.json",
  "manufacturername": "$MF_IKEA",
  "modelid": "BADRING Water Leakage Sensor",
  "vendor": "IKEA",
  "product": "BADRING Water Leakage Sensor",
  "sleeper": true,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_WATER_LEAK_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0500"
      ],
      "fingerprint": {
        "profile": "0x0104",
        "device": "0x0402",
        "endpoint": "0x01",
        "in": [
          "0x0000",
          "0x0001",
          "0x0500"
        ]
      },
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "config/checkin"
        },
        {
          "name": "attr/productid",
          "refresh.interval": 86400
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/alert",
          "default": "none"
        },
        {
          "name": "config/battery",
          "awake": true,
          "refresh.interval": 86400,
          "read": {
            "at": "0x0021",
            "cl": "0x0001",
            "ep": 1,
            "fn": "zcl:attr"
          },
          "parse": {
            "at": "0x0021",
            "cl": "0x0001",
            "ep": 1,
            "eval": "Item.val = Math.round(Attr.val / 2)",
            "fn": "zcl:attr"
          },
          "default": 0
        },
        {
          "name": "config/group"
        },
        {
          "name": "config/pending"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "config/enrolled",
          "public": true
        },
        {
          "name": "state/water",
          "awake": true
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0500"
    }
  ]
}
RP-Develop commented 5 months ago

sorry, but no changing.

maybe helpful: this is the preview of DDF editor from the same file. I don't understand, why is it different.

{ "schema": "devcap1.schema.json", "manufacturername": "$MF_IKEA", "modelid": "BADRING Water Leakage Sensor", "vendor": "IKEA", "product": "BADRING Water Leakage Sensor", "sleeper": true, "status": "Gold", "path": "/devices/badring_water_leakage_sensor.json", "subdevices": [ { "type": "$TYPE_WATER_LEAK_SENSOR", "restapi": "/sensors", "uuid": [ "$address.ext", "0x01", "0x0500" ], "fingerprint": { "profile": "0x0104", "device": "0x0402", "endpoint": "0x01", "in": [ "0x0000", "0x0001", "0x0500" ] }, "items": [ { "name": "attr/id" }, { "name": "attr/lastannounced" }, { "name": "attr/lastseen" }, { "name": "attr/manufacturername" }, { "name": "attr/modelid" }, { "name": "attr/name" }, { "name": "attr/productid", "refresh.interval": 86400 }, { "name": "attr/swversion" }, { "name": "attr/type" }, { "name": "attr/uniqueid" }, { "name": "config/alert", "default": "none" }, { "name": "config/battery", "awake": true, "refresh.interval": 86400, "read": { "at": "0x0021", "cl": "0x0001", "ep": 1, "fn": "zcl:attr" }, "parse": { "at": "0x0021", "cl": "0x0001", "ep": 1, "eval": "Item.val = Math.round(Attr.val / 2)", "fn": "zcl:attr" }, "default": 0 }, { "name": "config/checkin", "public": false, "refresh.interval": 3600, "default": 14400 }, { "name": "config/enrolled" }, { "name": "config/group" }, { "name": "config/on" }, { "name": "config/pending" }, { "name": "config/reachable" }, { "name": "state/lastupdated" }, { "name": "state/water", "awake": true } ] } ], "bindings": [ { "bind": "unicast", "src.ep": 1, "cl": "0x0500" } ] }

RP-Develop commented 5 months ago
image image
RP-Develop commented 5 months ago
image
RP-Develop commented 5 months ago
image

Running on MAC mini M2 Sonoma 14.4.1

SwoopX commented 5 months ago

The device presumably needs to be poked on the IAS Zone cluster to start the enrollment process, like the Parasoll (and the battery binding was missing). This one should do the trick:

{
  "schema": "devcap1.schema.json",
  "manufacturername": "$MF_IKEA",
  "modelid": "BADRING Water Leakage Sensor",
  "vendor": "IKEA",
  "product": "BADRING Water Leakage Sensor",
  "sleeper": true,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_WATER_LEAK_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0500"
      ],
      "fingerprint": {
        "profile": "0x0104",
        "device": "0x0402",
        "endpoint": "0x01",
        "in": [
          "0x0000",
          "0x0001",
          "0x0500"
        ]
      },
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/productid",
          "refresh.interval": 86400
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/battery",
          "awake": true,
          "refresh.interval": 86400,
          "read": {
            "at": "0x0021",
            "cl": "0x0001",
            "ep": 1,
            "fn": "zcl:attr"
          },
          "parse": {
            "at": "0x0021",
            "cl": "0x0001",
            "ep": 1,
            "eval": "Item.val = Math.round(Attr.val / 2)",
            "fn": "zcl:attr"
          }
        },
        {
          "name": "config/checkin"
        },
        {
          "name": "config/pending"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "config/enrolled",
          "public": true
        },
        {
          "name": "state/water",
          "parse": {
            "fn": "ias:zonestatus",
            "mask": "alarm1,alarm2"
          },
          "read": {
            "fn": "zcl:attr",
            "ep": 1,
            "cl": "0x0500",
            "at": "0x0000"
          },
          "awake": true,
          "refresh.interval": 84600
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0500"
    },
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0001",
      "report": [
        {
          "at": "0x0021",
          "dt": "0x20",
          "min": 3600,
          "max": 43200,
          "change": "0x00000002"
        }
      ]
    }
  ]
}
RP-Develop commented 5 months ago

I have also tried this DDF, but unfortunately without success. I have also used the complete DDF from Parsoll Sensor, adapted accordingly of course, but unfortunately without success. I can't get a status change for "state/water". Only when I use "read" in 0x0500 in deConz do I see a status change in at 0x0002 and also an event in Phoscon.

After the "read" is also the at 0x0000 changed to Enrolled.

image

Can I log some more?

The IAS log in moment when I let beep the sensor and use the read button:

21:03:18:977 [IAS ZONE] - Address 0xB0C7DEFFFE62A297, Payload 0000003001010000312a00020000190100100000f0ff4305ffff2e2100, Command 0x01 21:03:18:978 [IAS ZONE] - 0xB0C7DEFFFE62A297 Read attributes response: 21:03:18:979 [IAS ZONE] - 0xB0C7DEFFFE62A297 -> IAS Zone State: enrolled. 21:03:18:980 [IAS ZONE] - 0xB0C7DEFFFE62A297 -> IAS CIE address = 0x00212EFFFF0543FF: already written. 21:03:18:980 [IAS ZONE] - 0xB0C7DEFFFE62A297 Sensor (ZHAWater) is enrolled. 21:03:19:931 [IAS ZONE] - Address 0xB0C7DEFFFE62A297, Payload 1100002064, Command 0x01 21:03:19:932 [IAS ZONE] - 0xB0C7DEFFFE62A297 Read attributes response: 21:03:19:933 [IAS ZONE] - 0xB0C7DEFFFE62A297 Sensor (ZHAWater) is enrolled.

...and the same without beep:

21:05:26:913 [IAS ZONE] - Address 0xB0C7DEFFFE62A297, Payload 0000003001010000312a00020000190000100000f0ff4305ffff2e2100, Command 0x01 21:05:26:914 [IAS ZONE] - 0xB0C7DEFFFE62A297 Read attributes response: 21:05:26:915 [IAS ZONE] - 0xB0C7DEFFFE62A297 -> IAS Zone State: enrolled. 21:05:26:916 [IAS ZONE] - 0xB0C7DEFFFE62A297 -> IAS CIE address = 0x00212EFFFF0543FF: already written. 21:05:26:916 [IAS ZONE] - 0xB0C7DEFFFE62A297 Sensor (ZHAWater) is enrolled. 21:05:27:885 [IAS ZONE] - Address 0xB0C7DEFFFE62A297, Payload 1100002064, Command 0x01 21:05:27:887 [IAS ZONE] - 0xB0C7DEFFFE62A297 Read attributes response: 21:05:27:887 [IAS ZONE] - 0xB0C7DEFFFE62A297 Sensor (ZHAWater) is enrolled. 21:05:27:933 [IAS ZONE] - Address 0xB0C7DEFFFE62A297, Payload 1100002064, Command 0x01 21:05:27:934 [IAS ZONE] - 0xB0C7DEFFFE62A297 Read attributes response: 21:05:27:934 [IAS ZONE] - 0xB0C7DEFFFE62A297 Sensor (ZHAWater) is enrolled.

many thanks

Smanar commented 5 months ago

Nothing to see but why this part on both DDF (this one and the praraoll)


          "read": {
            "fn": "zcl:attr",
            "ep": 2,
            "cl": "0x0500",
            "at": "0x0000"
          },

There is no endpoint 0x02, and we are not using this attribute (the 0x0000) Not a problem as we don't use poll, but useless for me.

For your issue, all seem fine for me, the enrollement is done, you haven't log if the device detect water, without using the "read" button ?

SwoopX commented 5 months ago

and we are not using this attribute (the 0x0000) Not a problem as we don't use poll, but useless for me.

In fact, attribute 0x0000 is imperative for any IAS Zone device correctly implementing the standard and deconz always uses it to determine the current state and if there's any to do.

I, personally, would put my bet on a missed device reset on every DDF update. This would explain everything what has been described here and also why things didn't work out as expected.

RP-Develop commented 5 months ago

For your issue, all seem fine for me, the enrollement is done, you haven't log if the device detect water, without using the "read" button ?

No, nothing. I have two devices installed at the moment. I have the feeling that the battery event is also not like from other devices.

RP-Develop commented 5 months ago

would put my bet on a missed device reset on every DDF update

Can I influence this?

openKimchi commented 5 months ago

I installed the sensor with this DDF. Then restarted the entire Deconz server. When triggered manually, the alarm jumps to true (state in ioBroker) and stays that way. When triggered again manually, it jumps to false and stays that way. And the battery indicator doesn't work at all.

Edit: After manually triggering the sensor several times, it now seems to be working somewhat, including the battery indicator.

RP-Develop commented 5 months ago

It looks as if the sensor is going into sleep mode. So if you have it read manually, do not wake it up. The first reaction after waking up is to hit the sensor with water and hear the beep. You can then see in the IAS log that all read commands have been processed.

openKimchi commented 5 months ago

By manual triggering I mean wetting it with water...almost embarrassing but where can I find this IAS log?

RP-Develop commented 5 months ago

(macOS) under Help - Debug view - select IAS

image
openKimchi commented 5 months ago

ok, thx. After wetting it I got;

14:23:39:026 [IAS ZONE] - Address 0x38398FFFFE0AE1FD, Payload 000000640000, Command 0x00 14:23:39:027 [IAS ZONE] - 0x38398FFFFE0AE1FD Status Change, status: 0x0000, zoneId: 100, delay: 0 14:23:39:027 [IAS ZONE] - 0x38398FFFFE0AE1FD Sensor (ZHAWater) is enrolled. 14:26:08:335 [IAS ZONE] - Address 0x000D6F000E0593A8, Payload 0200192400, Command 0x0A 14:26:08:335 [IAS ZONE] - 0x000D6F000E0593A8 Sensor (ZHAPresence) is enrolled.

RP-Develop commented 5 months ago

14:23:39:026 [IAS ZONE] - Address 0x38398FFFFE0AE1FD, Payload 000000640000, Command 0x00 14:23:39:027 [IAS ZONE] - 0x38398FFFFE0AE1FD Status Change, status: 0x0000, zoneId: 100, delay: 0 14:23:39:027 [IAS ZONE] - 0x38398FFFFE0AE1FD Sensor (ZHAWater) is enrolled.

I don't get it after wetting.

On which system is running your deConz?

RP-Develop commented 5 months ago

One question: Why do I get a different view between the preview of the DDF editor and the file that I have edited with an external editor?

image
openKimchi commented 5 months ago

On which system is running your deConz?

it's a Ubuntu 22.04.4 LTS Server as a VM on a Proxmox System.

openKimchi commented 5 months ago

One question: Why do I get a different view between the preview of the DDF editor and the file that I have edited with an external editor?

Don't know. Same for me

Smanar commented 5 months ago

One question: Why do I get a different view between the preview of the DDF editor and the file that I have edited with an external editor?

Honnestly there is so much "strange" thing that happen in the editor (sometime it add stuff, sometime it remove, ect ...) , don't take care of them. Just look at the file name on the window title and remember deconz check DDF only at start.

Mimiix commented 5 months ago

One question: Why do I get a different view between the preview of the DDF editor and the file that I have edited with an external editor?

image

It probably didn't load or the file is in the wrong location.

RP-Develop commented 5 months ago

the file should be loaded correctly, because I see the file name at the top line of editor frame.

image

The real path on my MAC is: /Users/home/Library/Application Support/dresden-elektronik/deCONZ/devices/badring_water_leakage_sensor.json

RP-Develop commented 5 months ago

I haven't touched anything for more than 24 hours now. I didn't get anything back. No battery status and no alarm - nothing

openKimchi commented 5 months ago

I just tried it again and everything still works. So it can't be the DDF file. But it only worked after I completely restarted the server. This is done quickly with Proxmox.

RP-Develop commented 5 months ago

Can you tell me the version of deConz? My version is v2.25.3.

openKimchi commented 5 months ago

2.26.3, the latest

RP-Develop commented 5 months ago

2.26.x don't work on my MAC - [https://github.com/dresden-elektronik/deconz-rest-plugin/issues/7698]

Smanar commented 5 months ago

ok, thx. After wetting it I got;

14:23:39:027 [IAS ZONE] - 0x38398FFFFE0AE1FD Status Change, status: 0x0000, zoneId: 100, delay: 0

So your device react to water, the enrollment seem good, but you need to have other value than 0x0000 for status. And 100 for ZoneID is the defaut value, so nothing strange here.

DanielHabenicht commented 5 months ago

The DDF (from the PR) also does not work for me (on homeassistant with deCONZ 2.25.3): battery is always 0 IAS Log: image

Nothing shows up in HA either, batter at 0 at no events registered (although I don't know if this needs additional programming?).

Smanar commented 5 months ago

But on your logs all is fine, we can see the status go from 0x0000 to 0x0001. Can you make the same log but with the flag "DDF" too ?

Can you try with using just

        {
          "name": "state/water"
        }

on the DDF

DanielHabenicht commented 5 months ago

I looked it up again today and it now reports the battery (8 hours after initially enrolling it). But I do not receive any events in Homeassistant (is that a part that still must be programmed in the Homeassistant add on or should this work out of the box?)

Smanar commented 5 months ago

is that a part that still must be programmed in the Homeassistant add on or should this work out of the box

For me it's out of the box, can check direclty in the API to be sure, phoscon/help/API Information/sensors.

DanielHabenicht commented 5 months ago

ok, yes whatever the system had... It's working now. Maybe it just had to do with all the manual stuff involved to add the DDF. Works now: badring

poelzi commented 4 months ago

I also had quite some trouble getting this sensor to work. After deleteing and pairing again with the latest DDF and triggering the sensor, everything works.