Hi.
I have some PIRs that are automatically created and updated in HA via RESTful.
The problem I have is that the PIRs only send a movement trigger, there is no Off.
They are configured as binary_sensor’s. I know that auto_off is a template option, but I have not had any luck setting this up at all.
I’ve also tried setting up an automation to do this, but again it doesn’t appear to work.
The automation is being triggered, but the state never changes back to Off.
Here is the automation code that was automatically generated in HA.
- id: '1621096094293'
alias: testing pir
description: ''
trigger:
- platform: state
entity_id: binary_sensor.thorian_pir1
to: 'On'
from: 'Off'
for: 00:00:10
condition: []
action:
- condition: state
entity_id: binary_sensor.thorian_pir1
state: 'Off'
mode: single
Hope someone can help. I’ve played about with this for many hours now.
Thanks.
And you also can’t set the state of a binary sensor in an automation.
if you look at your action code above that isn’t what that piece of code is doing.
What it is doing is checking the condition of the binary sensor as being “Off” (which as noted needs to be lower case) before running the follow-on actions…which there aren’t any.
I’m kind of surprised the config check passed on that since there are no real actions.
But I saw that automations configured thru the UI don’t need triggers either.
So it looks like bug to me but it may be intended.
However, you can use the new “trigger” binary sensors to set the state.
You say that you are using REST to get the values of your PIR, so you would be pulling values?
But then you say that “PIRs only send a movement trigger”, which implies pushing.
Hi koying.
I believe its push.
There is no configuration in HA for this, although I have tried to set it up in customize.yaml so that it would remember a friendly name, but this hasn’t worked.
here’s what’s being sent to HA from the PIR via rest:
Method POST
http://192.168.0.59:8123/api/states/binary_sensor.thorian_temp13
Headers:
authorization: Bearer <my long term token>
content-type: application/json
Body:
{
"state": "on",
"attributes":
{
"icon": "mdi:motion-sensor",
"auto_off": "00:00:10"
}
}
Auto off appears to be ignored.
On starting HA, the sensor in the UI show as ‘Entity not available: binary_sensor.thorian_pir1’
This is until an update ‘on’ has been received from the PIR itself.
I’m clueless as to how to make these time out after 10 seconds, or to give them a permanent friendly name in HA.
If this isn’t possible, maybe if I convert them to switches it would make life easier?
Thanks koying.
Unfortunately there is no webhook. Its generally a one way conversation from pir to host.
I’ve done some testing since my last message and found that I can get everything to work if I configure the pir’s as switches.
I would prefer HA to recognise them as binary movement sensors and will keep trying.
Hi again.
I’ve quickly Googled webhooks. It would seem this is what I’m doing, one way traffic.
I’m still looking at the example code from your 2021.5 link.
Maybe this should work. I’ve pasted in my own take on it below, but its not working.
template:
- trigger:
- platform: event
event_type: netatmo_event
event_data:
type: movement
binary_sensor:
- name: "thorian_pir1"
# We use auto_off, so just set it to true on each trigger
state: "true"
device_class: motion
# Automatically turn off 10 seconds after the last event
auto_off: 10
Oh wow, its working, along with the timeout that I set in the config file.
I have several PIRs, but I’m not sure how to get the others to work. I’ve tried giving the event a different name for a different pir instead of netatmo_event, but I’m not sure how to put this into the template for multiple sensors?
Ignore me, I figured it out with something along the lines of this: