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

Aqara (xiaomi) motion sensor mod support #1671

Closed
sorryusernameisalreadytaken opened this issue Jul 11, 2019 · 37 comments
Closed

Aqara (xiaomi) motion sensor mod support #1671

sorryusernameisalreadytaken opened this issue Jul 11, 2019 · 37 comments

Comments

@sorryusernameisalreadytaken
Copy link

@sorryusernameisalreadytaken sorryusernameisalreadytaken commented Jul 11, 2019

There is a hardware-mod for the Aqara motion sensor to get a shorter check-up time.

I first see this in the smartthings board here.
Later a user from the
homeassistant community create a code-snipped for a custom-component.

There should be no problem to get officialy support for this mod, or?
At the moment we need to modificate the seconds in each motion sensor in deconz with a tool like Postman. We need to send a POST request at http://hassioip:40850/api/apikey/sensors/sensornumber /config ; in body (raw) put: {“duration”: 5} - where 5 is refresh time.

Sadly this does not survive a reboot :/

I think a not alone with the big wish to enhance the 90 seconds timeout to something lower like the 5 seconds.

@00lex
Copy link

@00lex 00lex commented Jul 11, 2019

that's awesome!!
isn't it enough to modify the zll.db from deconz to 5 seconds? I will try it this evening!

Bildschirmfoto 2019-07-11 um 15 27 06

btw. original duration is 60s. don't know why and when deconz change this to 90s

edit:
ok now I understand. even if I mod the database the value change to 90s after a restart of deconz service :(

@00lex
Copy link

@00lex 00lex commented Jul 11, 2019

until someone make changes to deconz I will run a script on every start of deconz for all sensors.

curl -X PUT -d '{"duration":5}' http://127.0.0.1:8009/api/YOURAPIKEY/sensors/33/config

thank you for the hint.

@00lex
Copy link

@00lex 00lex commented Jul 11, 2019

Okay this is my final script.

sensors="25 11 29 16 5 33"

for i in $sensors; do
    curl -X PUT -d '{"duration":5}' http://127.0.0.1:8009/api/YOURAPI/sensors/$i/config
done

while testing I see one strange thing. one of my aqara sensors has a default duration of 122 seconds

I use a pencil (HB) too, to connect both pins and put some nail polish to on it fix the graphen

@Kane610
Copy link

@Kane610 Kane610 commented Jul 11, 2019

You can create an automation in hass that does that with deconz service on every start 👍🏻

@00lex
Copy link

@00lex 00lex commented Jul 11, 2019

I use pimatic. thanks anyway

@sorryusernameisalreadytaken
Copy link
Author

@sorryusernameisalreadytaken sorryusernameisalreadytaken commented Oct 7, 2019

Okay this is my final script.

sensors="25 11 29 16 5 33"

for i in $sensors; do
    curl -X PUT -d '{"duration":5}' http://127.0.0.1:8009/api/YOURAPI/sensors/$i/config
done

while testing I see one strange thing. one of my aqara sensors has a default duration of 122 seconds

I use a pencil (HB) too, to connect both pins and put some nail polish to on it fix the graphen

I had no duration tag under device.
modelid is "lumi.sensor_motion.aq2"

Can I add this duration tag?

I got an error when I try to add your 5 second value.

@hendrikmaus
Copy link

@hendrikmaus hendrikmaus commented Oct 7, 2019

What is your error you get? I have been using the same method successfully with the model ID you mentioned.

@sorryusernameisalreadytaken
Copy link
Author

@sorryusernameisalreadytaken sorryusernameisalreadytaken commented Oct 7, 2019

@hendrikmaus

My error is:

[
    {
        "error": {
            "address": "/sensors/1/config/duration",
            "description": "parameter, duration, not available",
            "type": 6
        }
    }
]

@hendrikmaus
Copy link

@hendrikmaus hendrikmaus commented Oct 14, 2019

I reckon that you added the 'duration' to the URI. Let's review your curl command. It is important to pass the duration using JSON payload to the config resource. An example was posted above.

@ikrowni
Copy link

@ikrowni ikrowni commented Dec 16, 2019

Can someone explain exactly what I need to do to get this 5 second timer working with home assistant? I've already soldering the wire onto a few of my motion sensors but I don't know what to do from here.

@ikrowni
Copy link

@ikrowni ikrowni commented Dec 16, 2019

You can create an automation in hass that does that with deconz service on every start 👍🏻

Could you share this automation please?

@hendrikmaus
Copy link

@hendrikmaus hendrikmaus commented Dec 17, 2019

To sum it up; after applying the hardware modification:

Get API Key

Open Phoscon, navigate to the gateway and allow apps to connect:

# replace '10.0.0.1' with the IP of your deCONZ deployment; port is the default one
$ curl -X POST -s -d '{"devicetype":"curl"}' "http://10.0.0.1:40850/api"
[{"success":{"username":"XXXXXXXXXX"}}]

Note down the username and remember to replace both IP and username in all subsequent examples.

Now use the username as API key to list all your sensors. This is required to get the IDs:

List sensors

curl -s http://10.0.0.1:40850/api/XXXXXXXXXX/sensors

If you found your sensor ID, this is the request to set the duration manually:

Set duration for motion sensor

$ curl -X PUT -d '{"duration":5 }' -s http://10.0.0.1:40850/api/XXXXXXXXXX/sensors/42/config
[
  {
    "success": {
      "/sensors/42/config/duration": 5
    }
  }
]

In home assistant, I wrapped the previous command into a shell_command and use this automation to continuously tell deCONZ to keep this behaviour:

Note: I run this every 5 minutes, which is probably not required.

deconz_set_duration_for_motionsensor: >
  curl -X PUT -d '{"duration":5}' -s "http://10.0.0.1:40850/api/XXXXXXXXXX/sensors/{{ id }}/config"

The automation:

alias: 'xiaomi_motion_sensor_refresh_duration'
trigger:
- platform: time_pattern
  minutes: "/5"
action:
- service: shell_command.deconz_set_duration_for_motionsensor
  data_template:
    id: '42'

@Kane610
Copy link

@Kane610 Kane610 commented Dec 17, 2019

You should use Deconz Configure Service in hass

@ikrowni
Copy link

@ikrowni ikrowni commented Dec 18, 2019

thanks i got it working now.

@Vissertje1980
Copy link

@Vissertje1980 Vissertje1980 commented Dec 20, 2019

I there someone who can tel me how i can make a script in Python to do the PUT requests automatic after reboot? I already installed the requests module on the pi en tried to make a script to set the velue of one sensor to 5 seconds but it did not work.

On my laptop, it works goot with a REST client but i don't no how to doe it automatic on de the pi.

this is the script i treid:

import requests

r = requests.put('http://ip adress:80/api/YOURAPI/sensors/32/config', data = {"duration": 5})

print (r)

i get code 200 back but the value of duration of sensor 32 did not change wen i check it with a GET request on the laptop.

@chbndrhnns
Copy link

@chbndrhnns chbndrhnns commented Dec 26, 2019

You should use Deconz Configure Service in hass

When I try to send data, I receive the message "parameter duration is not available":

entity: binary_sensor.presence_24
data:
  'duration': 5

@Kane610 Would you mind sharing your payload?

edit

I forgot the config key. It works like this:

entity: binary_sensor.presence_24
data:
  config:
    'duration': 5

@jyrki69
Copy link

@jyrki69 jyrki69 commented Jan 11, 2020

You should use Deconz Configure Service in hass

When I try to send data, I receive the message "parameter duration is not available":

entity: binary_sensor.presence_24
data:
  'duration': 5

@Kane610 Would you mind sharing your payload?

edit

I forgot the config key. It works like this:

entity: binary_sensor.presence_24
data:
  config:
    'duration': 5

Are you still getting this to work?
When I try this I get an error, /sensors/config parameter, config, not modifiable.

I read some posts that they had made config read only, but that was from 2017.

Any suggestions?

@ebaauw
Copy link
Collaborator

@ebaauw ebaauw commented Jan 11, 2020

You need to do a PUT to /api/apikey/sensors/id/config with a body of {"duration": 5}.

See http://dresden-elektronik.github.io/deconz-rest-doc/sensors/.

@askanhesse
Copy link

@askanhesse askanhesse commented Mar 27, 2020

Since I am reading the same behaviour as happened for me in this thread, that people getting the error response:
[{"error":{"address":"/sensors/{ID}/config/duration","description":"parameter, duration, not available","type":6}}]
Even when using correct config URL.

Make sure you used the correct device ID since this sensor is creating two devices in deconz. Choose for that one of type ZHAPresence.

@sebastianlorenzen
Copy link

@sebastianlorenzen sebastianlorenzen commented May 8, 2020

Any news on this? The duration is still reset, after you reboot deconz gateway.

@Creatish
Copy link

@Creatish Creatish commented May 23, 2020

any update?

@stale
Copy link

@stale stale bot commented Jun 27, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 27, 2020
@sebastianlorenzen
Copy link

@sebastianlorenzen sebastianlorenzen commented Jun 27, 2020

When will this be implemented?

@stale stale bot removed the stale label Jun 27, 2020
@stale
Copy link

@stale stale bot commented Jul 18, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 18, 2020
@stale stale bot closed this as completed Jul 26, 2020
@GitHubStephan
Copy link

@GitHubStephan GitHubStephan commented Sep 17, 2020

the point is still open. would be fine if you can implement it in deconz

@Smanar
Copy link
Collaborator

@Smanar Smanar commented Sep 17, 2020

It was not corrected by #3176 ?

@GitHubStephan
Copy link

@GitHubStephan GitHubStephan commented Sep 17, 2020

hello, sorry, i miss this point. only read this thread and see that it is closed without comment. i will test it with my new hardware mod.

@oneseventhree
Copy link

@oneseventhree oneseventhree commented Sep 27, 2020

This is still an issue. After the hardware mod it still taking 90 seconds to clear instead of 5 seconds

@Mimiix Mimiix reopened this Sep 28, 2020
@stale stale bot removed the stale label Sep 28, 2020
@Mimiix
Copy link
Collaborator

@Mimiix Mimiix commented Sep 28, 2020

@oneseventhree @GitHubStephan What version of deCONZ are you on?

@oneseventhree
Copy link

@oneseventhree oneseventhree commented Sep 28, 2020

@oneseventhree @GitHubStephan What version of deCONZ are you on?

This is what I am running

Screen Shot 2020-09-28 at 5 21 40 pm

Screen Shot 2020-09-28 at 5 22 31 pm

Screen Shot 2020-09-28 at 5 23 40 pm

@Mimiix
Copy link
Collaborator

@Mimiix Mimiix commented Sep 28, 2020

@oneseventhree
Copy link

@oneseventhree oneseventhree commented Sep 28, 2020

So it should be working @oneseventhree
https://github.com/dresden-elektronik/deconz-rest-plugin/releases/tag/V2_05_81_stable

It should but it still takes 90 seconds in home assistant to show as cleared

@Mimiix
Copy link
Collaborator

@Mimiix Mimiix commented Sep 28, 2020

You still need to configure it yourself using the api.

@oneseventhree
Copy link

@oneseventhree oneseventhree commented Sep 28, 2020

You still need to configure it yourself using the api.

Do you know how I can do this?

@Mimiix
Copy link
Collaborator

@Mimiix Mimiix commented Sep 28, 2020

Please read up a bit ;)
#1671 (comment)

@oneseventhree
Copy link

@oneseventhree oneseventhree commented Sep 28, 2020

For anyone who struggled with this as much as I did, all you need do AFTER you do the hardware modification is to go into the UI of Home Assistant then go to 'Developer Tools > Services' then type this(but change the entity to yours):
Screen Shot 2020-09-28 at 7 05 51 pm

Code is:

entity: binary_sensor.YOUR_ENTITY_NAME_HERE
data:
  config:
    'duration': 5

I've restarted HA and turned off my rasberrypi/deconz and it works. Hope that helps someoen because reading up confused me alot :)

@Mimiix
Copy link
Collaborator

@Mimiix Mimiix commented Sep 28, 2020

As this seems fixed: I'll close the issue ;)

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

No branches or pull requests