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 support for Linptech motion sensor version 2 #821

Merged
merged 2 commits into from
Sep 25, 2022

Conversation

micturkey
Copy link
Contributor

@micturkey micturkey commented Sep 10, 2022

Help solve issue #816 and #809
Users need to upgrade the firmware of Linptech motion sensor which makes the product name become Linptech motion sensor 2 (not motion sensor with firmware 2.0.0).

@Snakesms
Copy link

Snakesms commented Sep 12, 2022

Help solve issue #816 and #809 Users need to upgrade the firmware of Linptech motion sensor to version 2.

Any insights how to, please?
I would be happy to, but it's not properly supported by Mi Home + GW3 in European regions (might be support in the main china thought but didn't test as gateway is not in that region and lots of hassle to migrate)

@Snakesms
Copy link

Meanwhile I managed to check firmware on mine and it says that its already 2.0.0_0004 which is the latest

@micturkey
Copy link
Contributor Author

micturkey commented Sep 13, 2022

Meanwhile I managed to check firmware on mine and it says that its already 2.0.0_0004 which is the latest

Linptech has upgraded the firmwire and now it is called Linptech Motion Sensor 2 image

The yellow one is the old one (motion sensor 1) and the red one is the neweset one.
Your 2.0.0 means motion sensor 1 with firmware 2.0.0 but not motion sensor 2.
Linptech says they will release the new firmwire update soon which will update all sensor 1 to sensor 2 and users need to re-pair the sensor and reboot gateways.
If you want to use sensor 1 now, maybe you can change the ble parser to the port sensor 1 is used now.
BTW, now I can upgrade to sensor 2 because I asked a KOL(【接入米家的领普人体传感器2。其实和1代硬件一样,改动太大单独的sku了。新增5个状态条件。有人移动且光照高于xx。20分钟无人移动替换为1分钟无人移动-哔哩哔哩】 https://b23.tv/TzvUrTc) to let linptech add my MI id to the whitelist, to anyone else, it should not be a long time to get the firmware update.

@Snakesms
Copy link

Thanks a lot for the explanation. It will be great if you can explain how to change the ble parser and/or share the code of the parser itself. For me in the UK currently sensor is totally useless, as it's not available in the Mi App and also Alex's integration doesn't support it yet.
Thanks in advance

@micturkey
Copy link
Contributor Author

micturkey commented Sep 13, 2022

Thanks a lot for the explanation. It will be great if you can explain how to change the ble parser and/or share the code of the parser itself. For me in the UK currently sensor is totally useless, as it's not available in the Mi App and also Alex's integration doesn't support it yet. Thanks in advance

In mibeacon.py, changes should be like:

        elif eid == 0x4A09:  # 18953
            # Linptech motion sensor
            value = struct.unpack('<f', data)[0]
            payload['idle_time'] = value * 60 # it seems that it reports the minutes in float, so it should be times 60 to get the seconds which is used in xiaomigateway3

        elif eid == 0x4A08:  # 18952
            # Linptech motion sensor
            value = struct.unpack('<f', data)[0]
            payload.update({'motion': True, 'illuminance': value})

I cannot figure out the battery data's port, maybe you can just try:

        elif eid == 0x4C03:  # 19459
            # Linptech motion sensor version 2
            payload['battery'] = data[0]

And in devices.py:
Simply change 10987 to 6284.
Just try it, maybe it will work.

@micturkey
Copy link
Contributor Author

And..

it's not available in the Mi App

I think to use this sensor you need to first pair it in Mi App...

@Snakesms
Copy link

And..

it's not available in the Mi App

I think to use this sensor you need to first pair it in Mi App...

I mean its not supported in EU region (in Mi App) however I've managed to add it to the account so Alex's integration can see it

@Snakesms
Copy link

Thanks a lot for the explanation. It will be great if you can explain how to change the ble parser and/or share the code of the parser itself. For me in the UK currently sensor is totally useless, as it's not available in the Mi App and also Alex's integration doesn't support it yet. Thanks in advance

In mibeacon.py, changes should be like:

        elif eid == 0x4A09:  # 18953
            # Linptech motion sensor
            value = struct.unpack('<f', data)[0]
            payload['idle_time'] = value * 60 # it seems that it reports the minutes in float, so it should be times 60 to get the seconds which is used in xiaomigateway3

        elif eid == 0x4A08:  # 18952
            # Linptech motion sensor
            value = struct.unpack('<f', data)[0]
            payload.update({'motion': True, 'illuminance': value})

I cannot figure out the battery data's port, maybe you can just try:

        elif eid == 0x4C03:  # 19459
            # Linptech motion sensor version 2
            payload['battery'] = data[0]

And in devices.py: Simply change 10987 to 6284. Just try it, maybe it will work.

Thanks a lot for the provided info.
I did apply mentioned changes and it works fine for me (without battery details, but it doesn't matter much).

Quick question pls, as it seems you have some access to the manufactury/firmware developers :
Current idle time for the sensor is about 35 seconds. Can you ask them if there is a plan to make it adjustable or decrease it to something smaller? 35 sec seems to be quite a long period for places like corridors where people just pass by and don't move continuously in front of the sensor
Thanks

@micturkey
Copy link
Contributor Author

micturkey commented Sep 16, 2022 via email

@rezmus
Copy link

rezmus commented Sep 19, 2022

so you upgraded old sensor to new firmware and it became version 2? what is fw version now after whitelist update? 2.1.0_0022?

@micturkey
Copy link
Contributor Author

so you upgraded old sensor to new firmware and it became version 2? what is fw version now after whitelist update? 2.1.0_0022?

Yes.
Sorry I am not at home now so I cannot see the version.

@AlexxIT AlexxIT added this to the v2.2.0 milestone Sep 25, 2022
@AlexxIT AlexxIT merged commit 60b9017 into AlexxIT:master Sep 25, 2022
@AlexxIT
Copy link
Owner

AlexxIT commented Sep 25, 2022

Thanks!

@alex7hacs
Copy link

Linptech has upgraded the firmwire and now it is called Linptech Motion Sensor 2
BTW, now I can upgrade to sensor 2 because I asked a KOL

Hi @micturkey , I have Linptech Motion Sensor 1 and Linptech still hasn't released an update. So I cannot use the motion sensor in Home Assistant. Could you please could share a KOL that can add a device to the whitelist?

@micturkey
Copy link
Contributor Author

Linptech has upgraded the firmwire and now it is called Linptech Motion Sensor 2

BTW, now I can upgrade to sensor 2 because I asked a KOL

Hi @micturkey , I have Linptech Motion Sensor 1 and Linptech still hasn't released an update. So I cannot use the motion sensor in Home Assistant. Could you please could share a KOL that can add a device to the whitelist?

Check my replay before, there is a link to Bilibili.
And if you cannot receive update, try a new account of China region?

@alex7hacs
Copy link

alex7hacs commented Jul 6, 2024

And if you cannot receive update, try a new account of China region?

No success :(

Check my replay before, there is a link to Bilibili.
https://b23.tv/TzvUrTc

404, maybe because I don't have a Chinese IP. It seems linptech anymore don't support this device at all.

@micturkey
Copy link
Contributor Author

And if you cannot receive update, try a new account of China region?

No success :(

Check my replay before, there is a link to Bilibili.
https://b23.tv/TzvUrTc

404, maybe because I don't have a Chinese IP. It seems linptech anymore don't support this device at all.

Sorry, the link is invalid now. I checked and the new link is : https://www.bilibili.com/video/BV1KG4y1674j/
However, maybe I think it is more efficient to contact linptech via there email or skype: Email: [jiaoyun@linptech.com](mailto:jiaoyun@linptech.com?subject=Message from the website (www.linptech.org)&body=[Please let us know your name, phone number, company name, product requirements, and other information. Thank you!])
Skype: Linptech

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

Successfully merging this pull request may close these issues.

5 participants