Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Samsung SmartThings Arrival Sensor support #459

Closed
pixeye33 opened this issue Oct 8, 2018 · 22 comments
Closed

Add Samsung SmartThings Arrival Sensor support #459

pixeye33 opened this issue Oct 8, 2018 · 22 comments

Comments

@pixeye33
Copy link

pixeye33 commented Oct 8, 2018

Hello,

I just received a Samsung SmartThings Arrival Sensor and i've tried to add support for it without success...
I've followed the "How to support new devices" page and the issue is not related to me not being able to read :)

This device is kind of special : it doen't have any input/output i can interact with (except a reset button witch sends a "devLeaving"). And that's probably the reason why i can't follow the standard procedure.

As soon as the device is first paired i've got this :
zigbee2mqtt:debug 2018-10-8 17:38:56 Recieved zigbee message of type 'devInterview' with data '"0x24xxxxxxxxxxxxxx"' zigbee2mqtt:debug 2018-10-8 17:38:57 Recieved zigbee message of type 'devInterview' with data '"0x24xxxxxxxxxxxxxx"' zigbee2mqtt:debug 2018-10-8 17:39:01 Recieved zigbee message of type 'devInterview' with data '"0x24xxxxxxxxxxxxxx"' zigbee2mqtt:debug 2018-10-8 17:39:02 Recieved zigbee message of type 'devInterview' with data '"0x24xxxxxxxxxxxxxx"' zigbee2mqtt:debug 2018-10-8 17:39:02 Recieved zigbee message of type 'devInterview' with data '"0x24xxxxxxxxxxxxxx"' zigbee2mqtt:debug 2018-10-8 17:39:03 Recieved zigbee message of type 'devInterview' with data '"0x24xxxxxxxxxxxxxx"' zigbee2mqtt:debug 2018-10-8 17:39:03 Recieved zigbee message of type 'devIncoming' with data '"0x24xxxxxxxxxxxxxx"' of device 'tagv4' (0x24xxxxxxxxxxxxxx) zigbee2mqtt:debug 2018-10-8 17:39:03 Recieved zigbee message of type 'devStatus' with data '"online"' of device 'tagv4' (0x24xxxxxxxxxxxxxx)

and the device is paired fine :
zigbee2mqtt:info 2018-10-8 16:54:04 MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"device_connected","message":"0x24xxxxxxxxxxxxxx"}'

I can also remove it via the reset button :
zigbee2mqtt:debug 2018-10-8 17:38:14 Recieved zigbee message of type 'devLeaving' with data '"0x24xxxxxxxxxxxxxx"'

following that and the modification of devices.js to add tagv4 i've got no new message (even in debug mode)

My guess is that the devices only sends message of type devStatus (or something else) witch zigbee2mqtt chooses to ignore since the device is already paired.

I'm available to help debugging this if anyone wants to give it a try :)

@pixeye33
Copy link
Author

I discovered the existence of the networkmap feature : it keeps saying that my device is online, even though i pulled it's battery out.

I guess i'm gonna have to return this sensor to Amazon soon unless i get some help figuring this out ? :)

@Koenkk can you have a look ?

@Koenkk
Copy link
Owner

Koenkk commented Oct 16, 2018

@pixeye33 the sensors is probably working fine, my first guess is that it requires extra configuration to work.

Could you share your data/database.db file?

@pixeye33
Copy link
Author

@Koenkk i've created a clean docker instance only adding my sensor to make it easier to debug.

here is the database.db file (with my unique ID edited)
database.db.txt

Device was on and did not move during the whole time (at least 5 min). For info it's supposed to send a packet every 30s.

@Koenkk
Copy link
Owner

Koenkk commented Oct 17, 2018

Can you try with the following added to devices.js.

    {
        zigbeeModel: ['tagv4'],
        model: 'tagv4',
        vendor: 'Samsung',
        description: 'SmartThings arrival sensor',
        supports: 'TODO',
        fromZigbee: [],
        toZigbee: [],
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const device = shepherd.find(ieeeAddr, 1);
            const actions = [
                (cb) => device.report('genBinaryInput', 'presentValue', 10, 30, 1, cb),
            ];

            execute(device, actions, callback);
        },
    },

@pixeye33
Copy link
Author

Looks like we're making progress 👍

exactly every 30sec (as this device is supposed to do !) i got a log saying
No converter available for 'tagv4' with cid 'genBinaryInput', type 'attReport' and data '{"cid":"genBinaryInput","data":{"presentValue":0}}'

i've seen no new input in database.db

Koenkk added a commit to Koenkk/zigbee-herdsman-converters that referenced this issue Oct 19, 2018
@Koenkk
Copy link
Owner

Koenkk commented Oct 19, 2018

Could you try with:

cd node_modules
rm -rf zigbee-shepherd-converters
git clone https://github.com/Koenkk/zigbee-shepherd-converters.git -b  F-ARR-US-2
cd zigbee-shepherd-converters
npm install

-> Start zigbee2mqtt

@pixeye33
Copy link
Author

pixeye33 commented Oct 20, 2018

We are almost there 👍

i've got the presence mqtt messages (one each 30sec) :
zigbee2mqtt:info 2018-10-20 09:03:17 MQTT publish, topic: 'zigbee2mqtt/0x24xxxxxxxxxxxxxx', payload: '{"presence":true,"linkquality":31}'
i finnaly got the presence false message after way more than 100 sec. last true was at 11:03:20 false was recevied at 11:20:00.

The logic to detect the device not being there is gonna be in Node-red for me (so i can change the delay for example).
I'm not sure this should be implemented on your side (in my opinion any mqtt message sent should only be the consequence of a zigbee message recevied).

Some additional observations :
in your code vendor is Samsung, but you also got SmartThings vendor for other devices.
my device model is F-ARR-UK-2 but i'm pretty sure it's the same as F-ARR-US-2 (docs should mention both references ?).
the case of the device mentions : M/N STS-PRS-251 and this looks like another model number... :)

@pixeye33
Copy link
Author

btw, looks like the device sends battery info + can beep when reeving something.
https://community.smartthings.com/t/presence-activate-decativate/113706

but i'm fine with partial support instead of none at all 👍

@Koenkk
Copy link
Owner

Koenkk commented Oct 21, 2018

We also mock the occupancy: false for motion sensors; this can be turned of by setting occupancy_timeout: 0 or changed to e.g. 120 seconds by occupancy_timeout: 120. I think we should also do that for this sensor, what do you think?

Koenkk added a commit to Koenkk/zigbee-herdsman-converters that referenced this issue Oct 21, 2018
@Koenkk
Copy link
Owner

Koenkk commented Oct 21, 2018

Can you update and check if the battery is reported now (a warning no known converter should be displayed now); this can take up to one hour.

@pixeye33
Copy link
Author

i agree on the comment about the occupancy false for motion sensors. It makes sense to do this implementation the same way.

about the battery : here is the output i got
zigbee2mqtt:warn 2018-10-22 22:09:19 No converter available for 'STS-PRS-251' with cid 'genPowerCfg', type 'attReport' and data '{"cid":"genPowerCfg","data":{"batteryVoltage":24}}' zigbee2mqtt:warn 2018-10-22 22:09:19 Please see: https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-support-new-devices.
looks like we're on the right path !

about the beeping feature if you wanna try something :
https://github.com/SmartThingsCommunity/SmartThingsPublic/blob/master/devicetypes/smartthings/arrival-sensor-ha.src/arrival-sensor-ha.groovy#L77
dresden-elektronik/deconz-rest-plugin#427 (comment)
dresden-elektronik/deconz-rest-plugin#427 (comment)

@Koenkk
Copy link
Owner

Koenkk commented Oct 23, 2018

Let's first focus on the battery, what kind of battery does this device contain?

@tb-killa
Copy link
Contributor

Its a CR2032 Coin with 3V.

I use the same reporting for 4x EU-Lightyfy with
xx.report('genPowerCfg', 'batteryVoltage', 1800, 3600, 0, cb),
because 30min MIN and 1H MAX is battery Comfortable :)

My Voltage Converter:

generic_power_battvolt: {
        cid: 'genPowerCfg',
        type: 'attReport',
        convert: (model, msg, publish, options) => {
                return {voltage: msg.data.data['batteryVoltage']/10};
		},
	},

Koenkk added a commit to Koenkk/zigbee-herdsman-converters that referenced this issue Oct 25, 2018
@Koenkk
Copy link
Owner

Koenkk commented Oct 25, 2018

I've made some updates, can you verify this:

@pixeye33
Copy link
Author

pixeye33 commented Oct 25, 2018

Well i'm impressed : it mostly works 👍
there is some errors left though :

  • first start of zigbee2mqtt with battery out
zigbee2mqtt:info 2018-10-25 22:16:34 MQTT publish, topic: 'zigbee2mqtt/0x24xxxxxxxxxxxxxx', payload: '{"presence":false,"linkquality":63}'

battery inserted

zigbee2mqtt:info 2018-10-25 22:17:03 MQTT publish, topic: 'zigbee2mqtt/0x24xxxxxxxxxxxxxx', payload: '{"presence":false,"linkquality":63,"battery":"9.00","voltage":2800}'
zigbee2mqtt:warn 2018-10-25 22:17:03 No converter available for 'STS-PRS-251' with cid 'genPowerCfg', type 'devChange' and data '{"cid":"genPowerCfg","data":{"batteryVoltage":28}}'
zigbee2mqtt:warn 2018-10-25 22:17:03 Please see: https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-support-new-devices.

notice how battery voltage is provided, but presence is still false (it does that every time battery is inserted), maybe presence should be set as true not matter what message is received ? (but it's also fine as it is)

zigbee2mqtt:info 2018-10-25 22:17:33 MQTT publish, topic: 'zigbee2mqtt/0x24xxxxxxxxxxxxxx', payload: '{"presence":true,"linkquality":94,"battery":"9.00","voltage":2800}'
  • about the beeping feature, it works well !
    notes : it makes a series of slow beeps, not a continuous one.
    a duration of 1 second is not enough to have a beep emited.
    if i send 0 it stops the beeping

when i pushed "{"beep": 5}"

zigbee2mqtt:info 2018-10-25 22:31:59 Zigbee publish to '0x24xxxxxxxxxxxxxx', genIdentify - identify - {"identifytime":5} - {"manufSpec":0,"disDefaultRsp":0} - null
zigbee2mqtt:warn 2018-10-25 22:32:05 No converter available for 'STS-PRS-251' with cid 'genIdentify', type 'devChange' and data '{"cid":"genIdentify","data":{"identifyTime":5}}'
zigbee2mqtt:warn 2018-10-25 22:32:05 Please see: https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-support-new-devices.
zigbee2mqtt:info 2018-10-25 22:32:06 MQTT publish, topic: 'zigbee2mqtt/0x24xxxxxxxxxxxxxx', payload: '{"presence":true,"linkquality":81,"battery":"9.00","voltage":2800}'
zigbee2mqtt:warn 2018-10-25 22:32:06 No converter available for 'STS-PRS-251' with cid 'genIdentify', type 'devChange' and data '{"cid":"genIdentify","data":{"identifyTime":4}}'
zigbee2mqtt:warn 2018-10-25 22:32:06 Please see: https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-support-new-devices.

when i pushed "{"beep": 20}"

zigbee2mqtt:info 2018-10-25 22:33:13 Zigbee publish to '0x24xxxxxxxxxxxxxx', genIdentify - identify - {"identifytime":20} - {"manufSpec":0,"disDefaultRsp":0} - null
zigbee2mqtt:warn 2018-10-25 22:33:14 No converter available for 'STS-PRS-251' with cid 'genIdentify', type 'devChange' and data '{"cid":"genIdentify","data":{"identifyTime":20}}'
zigbee2mqtt:warn 2018-10-25 22:33:14 Please see: https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-support-new-devices.
zigbee2mqtt:warn 2018-10-25 22:33:15 No converter available for 'STS-PRS-251' with cid 'genIdentify', type 'devChange' and data '{"cid":"genIdentify","data":{"identifyTime":19}}'
zigbee2mqtt:warn 2018-10-25 22:33:15 Please see: https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-support-new-devices.

funny how device seems to respond duration asked then duration-1 (it does not countdown more than this) : you could just respond with "beeping":true and ignore this second message ?

  • about the presence_timeout (i did not set this value, as default is fine with me)
zigbee2mqtt:info 2018-10-25 22:39:06 MQTT publish, topic: 'zigbee2mqtt/0x24xxxxxxxxxxxxxx', payload: '{"presence":true,"linkquality":52,"battery":"9.00","voltage":2800}'

battery pulled out at 22:39:07

zigbee2mqtt:info 2018-10-25 22:40:46 MQTT publish, topic: 'zigbee2mqtt/0x24xxxxxxxxxxxxxx', payload: '{"presence":false,"linkquality":52,"battery":"9.00","voltage":2800}'

works perfectly ! 100 sec is a good default (a little above 3 messages not sent), occupancy_timeout default is 90 sec, that confused me at first.

  • bonus, with a brand new battery inserted :
zigbee2mqtt:info 2018-10-25 22:45:20 MQTT publish, topic: 'zigbee2mqtt/0x24xxxxxxxxxxxxxx', payload: '{"presence":true,"linkquality":39,"battery":"66.00","voltage":3000}'

3000 = 66%
2800 = 9%
seems weird ? :D

thanks for your awesome project, and for your time to integrate this device :)

@ryanbeaton
Copy link

Re: "battery inserted" results
That is how Zigbee2MQTT functions with Home Assistant. The new values (battery) are combined with cached values to create one 'full' message. Zigbee2MQTT must have had false as the last result for the device and combined it with the battery values.

Weird how you still get the "No converter available" message though.

Re: battery percentage
It is probably using the lookup table for the Maxwell Battery - which I personally don't like ;)
https://github.com/Koenkk/zigbee-shepherd-converters/pull/77/files

@tb-killa
Copy link
Contributor

For the converter message just Insert fz.ignore_power_change to the fromzigbee Part.
The battery table isnt good for Devices who only provide 3v battery coin or Block who is maximum. I think this need a rework.

Koenkk added a commit to Koenkk/zigbee-herdsman-converters that referenced this issue Oct 29, 2018
@Koenkk
Copy link
Owner

Koenkk commented Oct 29, 2018

  • WARNING: No converter..... message will not appear now anymore
  • Let's not publish presence: true when battery is reported (keep it to the genIdentify which is meant for that).
  • Beeping will be reported to mqtt now
  • Calibrated battery on 100% = 3000, 0% = 2500

Can you test? If everything is OK I can merge it.

@pixeye33
Copy link
Author

Hello,
just tested your modifications (after fixing the lint errors mentioned by Travis !)
works great, and all problems are now fixed :)

just noticed one last thing : when i started zigbee2mqtt i got a presence true mqtt message. Battery was pulled out.
Probably is the last state known being pushed at startup, what bothers me the most is that i have no way to differentiate this message from a real one.
Is there a way to not have this pushed at boot ? (retain is already at false)

After that it should be OK to merge 👍

@Koenkk
Copy link
Owner

Koenkk commented Oct 30, 2018

@pixeye33 currently there is no way to disable this.

But it's hard to end up in this state right? Happens when the presence: false countdown is still ticking and you stop zigbee2mqtt. The same issue will currently also occur with presence sensors.

@pixeye33
Copy link
Author

You're right this should not happen that often.

presence: true should really be sent only if the device did as its kind a security device.
push your code like this i'll look if i can make a PR solving this :)

Koenkk added a commit to Koenkk/zigbee-herdsman-converters that referenced this issue Oct 30, 2018
* Support F-ARR-US-2. Koenkk/zigbee2mqtt#459

* STS-PRS-251 report battery. Koenkk/zigbee2mqtt#459

* Update STS_PRS_251. Koenkk/zigbee2mqtt#459

* Update. Koenkk/zigbee2mqtt#459

* Update fromZigbee.js

* Update fromZigbee.js
@Koenkk
Copy link
Owner

Koenkk commented Oct 30, 2018

merged thanks!

@Koenkk Koenkk closed this as completed Oct 30, 2018
qosmio pushed a commit to qosmio/zigbee-herdsman-converters that referenced this issue Dec 25, 2019
* Support F-ARR-US-2. Koenkk/zigbee2mqtt#459

* STS-PRS-251 report battery. Koenkk/zigbee2mqtt#459

* Update STS_PRS_251. Koenkk/zigbee2mqtt#459

* Update. Koenkk/zigbee2mqtt#459

* Update fromZigbee.js

* Update fromZigbee.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants