dresden-elektronik / deconz-rest-plugin

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

IKEA Vallhorn motion sensor device request #7513

Closed noud-github closed 8 months ago

noud-github commented 8 months ago

Created a DDF file with a JS file,

My 9 year-old, bought one so I had to quickly make it work ;-)

see https://github.com/dresden-elektronik/deconz-rest-plugin/issues/7454

noud-github commented 8 months ago

will have a look later today (at home)

Mimiix commented 8 months ago

I am not sure if this is due to other DDF's in your branch.

Nvm, the error is about your DDF.

noud-github commented 8 months ago

no it is in mine, did not know and cannot find documentation on fingerprint and did some tweaking that probbely is giving this "correct " issue

noud-github commented 8 months ago

FYI: I mostly copied from the philips SML003_motion_sensor.json as I own both so this was the easiest way to a working IKEA sensor.

Smanar commented 8 months ago

Just by curiosity the native file for lux is not working ? https://github.com/dresden-elektronik/deconz-rest-plugin/blob/master/devices/generic/illuminance_cluster/lux_to_lightlevel.js

Lot of code is able to work natively, sometime you just need to use

        {
          "name": "state/presence",
        },

But you are in better place than me to say what is working or not ^^

The issue in the validator is here

"device": "0x"

In the fingerprint.

Occupancy Sensor = 0x0107 On/off sensor = 0x850 Light sensor = 0x0106

And on your DDF there is some binds I don't see he utility, not used in the DDF core. For exemple attribute 0x0030 on cluster 0x0406 or attribute 0x0033 and 0x0032 on the Cluster 0x0000

some "name": "attr/swversion", have read disabled, but not all.

I think "name": "state/dark" Can be removed from the presence sensor.

Smanar commented 8 months ago

Nope ^^. You need it, but you miss one. The first one is not complete.

Else don't say it's me that have say that to you, but you can remove all the fingerprint, I never use them.

"device": "0x",

need to be

"device": "0x0107",

And the second one need to be

"device": "0x0106",

noud-github commented 8 months ago

fixed the device items , now are valid (and it think correct.)

while adding the lux, I looked at the values shown in the GUI and they looked the same for the SML003 and the vallhorn I figured lets use the same script, but that might return wrong results. will setup the vallhorn next to the SML003 to see if the lux matches,

as sad this was a quick setup to please my son who bought one and was really disappointed it did not show up in phoscon ;-)

Smanar commented 8 months ago

Ha right, haven't see this js for philips, so you are certently right.

Smanar commented 8 months ago

Missed ^^. You NEED "device" if you use a fingerprint

1 validation error in file devices/ikea/vallhorn_wireless_motion_sensor.json at subdevices/1/fingerprint/device

And this IDK where it's from ...

"name": "config/OUdelay",

noud-github commented 8 months ago

just pushed with I think all your comments addresed, thanx

noud-github commented 8 months ago

you can set two delays, on the pressence this is for the other, I think I tested it yesterday and it work form HA

but might been time to eat as I don't see it in HA so, think this did not work...

removed it for now.

image
Mimiix commented 8 months ago

Looks good :) Thanks

ebaauw commented 8 months ago

Wanted to pick one up today, but the Amsterdam IKEA store doesn't carry it yet; they need to ditch the current stock of Trådfri motion sensors first. Will try another store this weekend.

noud-github commented 8 months ago

@ebaauw hengelo did have them at same price as the on "sale" old once,

Smanar commented 8 months ago

Just to be sure, there is bind/report for the presence attribute (0x0406/0x0000) , but not for the luminance (0x0400/0x0000) Can be native, but be sure it can work without.

and you have

        {
          "name": "attr/productname",
          "static": "Vallhorn light sensor"
        },

On one sensor but not the second one.

noud-github commented 8 months ago

shall I add the bind and the static name to the second one? and create a new PR? FYI: both seem to work in the current setup

Smanar commented 8 months ago

and create a new PR?

No, can just update this one. I mean the 2 sensors in this PR, "name": "attr/productname" is present for the TYPE_LIGHT_LEVEL_SENSOR but not the TYPE_PRESENCE_SENSOR, it's not usefull (all works without it), but not logic to have it on one sensor and not the second one for the same device.

For the bind, like I have said, if it work for you, it mean you don't need it. If you miss value update, it mean you need it.

noud-github commented 8 months ago

^^ with added productname, it works withoud the bind so I left that for now.

jmue commented 8 months ago

Thank you for your work on this. I get no illuminance sensor update within phoscon (shows only value 0lux) without the binding. After manually adding the illuminance binding I can see the sensor value.

noud-github commented 8 months ago

I do have reading without, but looking closer it seems static, that might have been from my testing...

Smanar commented 8 months ago

Ha ? So mean the binding is needed, on your side, you have probably made it with previous removed code, this setting is memorised on the device itself.

    {
      "bind": "unicast",
      "src.ep": 3,
      "cl": "0x0400",
      "report": [
        {
          "at": "0x0000",
          "dt": "0x21",
          "min": 5,
          "max": 300,
          "change": "0x07d0"
        }
      ]
    },

Edit: And BTW we can set the ep=3 here too

    {
      "type": "$TYPE_LIGHT_LEVEL_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x02",
        "0x0400"
      ],
workoutpeter commented 8 months ago

With binding and repairing, lux works for me.

 {
      "bind": "unicast",
      "src.ep": 3,
      "cl": "0x0400",
      "report": [
        {
          "at": "0x0000",
          "dt": "0x21",
          "min": 5,
          "max": 300,
          "change": "0x07d0"
        }
      ]
    },
ArnaudFeld commented 8 months ago

If I am running Gateway Version 2.25.1 I should connect it on the normal way?

noud-github commented 8 months ago

not sure what the normal way is but all lates IKEA stuff all need 4 (not more or less) button presses on the connection button

ebaauw commented 8 months ago

not sure what the normal way is but all lates IKEA stuff all need 4 (not more or less) button presses on the connection button

Afaik, that has always been the case for IKEA sensors and controllers. There is no “normal” way across all manufacturers.

noud-github commented 8 months ago

@Smanar

{ "type": "$TYPE_LIGHT_LEVEL_SENSOR", "restapi": "/sensors", "uuid": [ "$address.ext", "0x03", "0x0400" ],

setting ep to 3, does it also needs the endpoint (below:) need to go to 3? (or is that the enpoint on the "gateway"

"fingerprint": {
    "endpoint": "0x02",
    "profile": "0x0104",
    "device": "0x0106",
    "in": [
      "0x0400"
    ]
  },
ArnaudFeld commented 8 months ago

not sure what the normal way is but all lates IKEA stuff all need 4 (not more or less) button presses on the connection button

I ask because I updated to 2.25.1 and try to connect it but it wasn't recognized. Any Secret hints for this one?

Smanar commented 8 months ago

setting ep to 3, does it also needs the endpoint (below:) need to go to 3? (or is that the enpoint on the "gateway"

Ha yes, right, I have missed this one. It's more cosmetic (so can work with bad one) but it's the device fingerprint, so better to use 0x03 too.

SwoopX commented 8 months ago

not sure what the normal way is but all lates IKEA stuff all need 4 (not more or less) button presses on the connection button

I ask because I updated to 2.25.1 and try to connect it but it wasn't recognized. Any Secret hints for this one?

Not really surprising since deconz release notes do not mention it and this PR adds support for Milestone 2.25.2 🙂 Feel free to use the DDF right away.

ArnaudFeld commented 8 months ago

ok ;) sorry my fault

pawg commented 8 months ago

Thanks for the DDF, I've had some trouble to get it working, but I slowly grasp how to.

However, despite the motion sensing part working perfectly, the luxmeter stays at 0 (and curiously shows 1,0 lx in Home Assistant - running on a raspberry pi). I have copied the two files to /usr/share/hassio/addons/data/core_deconz/.local/share/dresden-elektronik/deCONZ/devices.

Any idea why or how to debug? Thanks

EDIT : I have managed to get it working! Those are the changes I made for reference:

First, I have added this in the first subdevice ( "type": "$TYPE_PRESENCE_SENSOR", ) section:

{
"name": "attr/productname",
          "static": "Vallhorn presence sensor"
        },

in the "items" section after

{
          "name": "attr/name"
        },

Then, in the "type": "$TYPE_LIGHT_LEVEL_SENSOR", section, I modified this:

{
          "name": "state/lightlevel",
          "parse": {
            "fn": "zcl:attr",
            "ep": 3,
            "cl": "0x0400",
            "at": "0x0000",
            "script": "0400_lightlevel.js"
          },
          "refresh.interval": 86400
        },

to include the refresh interval. I have played with different values, it doesn't seem to change the interval, always 5 seconds. Before this change, the reading wasn't refreshing at all. BTW, what is the unit of the refresh intervals? Milliseconds?

Finally, I have added this:

{
      "bind": "unicast",
      "src.ep": 3,
      "cl": "0x0400",
      "report": [
        {
          "at": "0x0000",
          "dt": "0x21",
          "min": 5,
          "max": 300,
          "change": "0x07d0"
        }
      ]
    },

at the beginning of the bindings section, as @Smanar had pointed out.

Restarted the deConz addon and everything is working!

Smanar commented 8 months ago

Ha yes right, still missing this part. The normal "working mode" is using bind/report on the bottom DDF, and if this part is failing deconz can make poll using the "refresh.interval". The value is in seconds, but this device is a sleeper, so not possible to force them to send value, it's more a security, or for device not supporting bind/report.

It's possible the bind was done previously, so even if it's missing in the DDF the device can work for another one, but not out of the box.

noud-github commented 8 months ago

@pawg did I add your changes in the right place: https://github.com/noud-github/deconz-rest-plugin/commit/ce20a400f2d553fa6ffb2f3203b945cdf2abfc0c

Smanar commented 8 months ago

@noud-github now your PR was valided/merged, you can delete your branch, or the complete fork if you can't, to start on a fresh base. The file your are editing ATM is a "desynchronised" version.

This branch is 5 commits ahead of, 9 commits behind dresden-elektronik/deconz-rest-plugin:master.

Your fork is ATM is same time ahead and behind, it can be solved but not easy to do, for only 1 file edited, better to start on a fresh base.

Sorry for all the work it need, but github is a realy nice machine that don't permit mistake ^^.

noud-github commented 8 months ago

merged (current) master into my (forked) branch so should be able to create PR again

ebaauw commented 8 months ago

Finally managed to get hold of one of these. As suggested by the screenshots, it's now a proper motion sensor on endpoint 0x02. It sends "no more motion detected" events, and honours PIR Occupied to Unoccuplied Delay, which should be exposed as config/delay (cf. the Hue motion sensors). As far as I can tell, it detects the next motion immediately after the delay has passed (so no cooldown period).

It still sends On with Timed Off from endpoint 0x01, like the Trådfri motion "sensors" (or rather controllers). It seems to use the configured On Time before resending this command. Haven't yet checked whether it still supports group bindings; if it does, we should expose config/group.

I think we should expose two ZHAPresence resources, one for the controller function on endpoint 0x01 (with state/daylight, config/group, and read-only config/delay, used for deCONZ to reset state/presence, cf the Trådfri motion "sensors") and one for the sensor function on 0x02 (with read/write config/delay, cf. the Hue motion sensors).

hyper2910 commented 8 months ago

when will 2.25.2 released?