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

Manage the status of the motion sensor #5

Open
DivanX10 opened this issue Dec 24, 2020 · 1 comment
Open

Manage the status of the motion sensor #5

DivanX10 opened this issue Dec 24, 2020 · 1 comment

Comments

@DivanX10
Copy link

Hi. I have a motion sensor from xiaomi and a gateway xiaomi 2, the firmware is original. My motion sensors are switched to service mode and they record movement every 5 seconds. I did as you wrote on the forum. The status of the motion sensor is reset after any period of time, even after 5 seconds. But if you walk in front of the motion sensor again, the detected status is not displayed, you need to wait 2 minutes and then it will show the detected status and after 5 seconds (I specified this time) it will reset the detected status to not detected. You can somehow get the home assistant to respond accurately to movement? There is a movement status detected after 5 seconds of no movement - status is not found, then create movement and status must be detected.

I have installed Home Assistant 2020.12.1

Read it here https://community.home-assistant.io/t/how-to-manually-set-state-value-of-sensor/43975/2

  1. In configuration.yaml added python_script:
    config

  2. Created the python_scripts folder
    python_scripts01

  3. Created a file set_state.py
    set_state

  4. I inserted your code into it

  5. The service is available in the developer panel
    service_yes

  6. Created automation

alias: DD in the corridor deactivating the status
description: We check the operation of the creak to deactivate the motion sensor
trigger:

  • type: motion
    platform: device
    device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    entity_id: binary_sensor.motion_sensor_xxxxxxxxxxxxxxxx
    domain: binary_sensor
    for:
    hours: 0
    minutes: 0
    seconds: 5
    condition: []
    action:
  • data_template:
    entity_id: binary_sensor.motion_sensor_xxxxxxxxxxxxxxxxxxx
    state: 'off'
    service: python_script.set_state
    mode: single
@xannor
Copy link
Owner

xannor commented Dec 24, 2020

All set state does is change the attribute values of the specified entity. With non-existent entities, home assistant will create a generic one the will temporarily hold the values, a restart will erase them since the entity never really existed. With entities provided by integrations, the attributes can be changed, but ultimately the integration controls their values and can reset them whenever it decides to. There is no reliable way to use this to override an existing entity.

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

2 participants