Sorry, forgot to write
I am using Nmap
I have 3 known devices and Nmap is checking for their IP (they are static)
So, here is it for now
- id: '1530900095838'
alias: Living light off
trigger:
- entity_id: binary_sensor.door_window_sensor_158d0001dcb0e3
from: 'off'
platform: state
to: 'on'
condition:
- condition: state
entity_id: binary_sensor.fibaro_system_fgms001_motion_sensor_sensor
state: 'on'
action:
- data:
entity_id: switch.a12_key
service: switch.turn_off
Should I try this?
- id: '1530900095838'
alias: Living light off
trigger:
- entity_id: binary_sensor.door_window_sensor_158d0001dcb0e3
from: 'off'
platform: state
to: 'on'
condition:
- condition: state
entity_id: binary_sensor.fibaro_system_fgms001_motion_sensor_sensor
state: 'on'
wait_template: {{ states.device_tracker|selectattr('state','eq','home')|list|count }}
action:
- data:
entity_id: switch.a12_key
service: switch.turn_off
UPD:
no,
Error loading /config/configuration.yaml: while parsing a flow mapping
in "/config/automations.yaml", line 137, column 21
expected ',' or '}', but got '<scalar>'
Wow, I’ve been having very bad luck getting at this site in the last hour or so. Here is a reply I typed up a while ago:
Close…
- id: '1530900095838'
alias: Living light off
trigger:
- entity_id: binary_sensor.door_window_sensor_158d0001dcb0e3
from: 'off'
platform: state
to: 'on'
condition:
- condition: state
entity_id: binary_sensor.fibaro_system_fgms001_motion_sensor_sensor
state: 'on'
- condition: template
value_template: "{{ states.device_tracker|selectattr('state','eq','home')|list|count }}"
action:
- data:
entity_id: switch.a12_key
service: switch.turn_off
A few comments. First, for a binary_sensor state trigger, you don’t have to specify both from: and to:. Once you specify one, there’s only one possibility for the other, so the second option is redundant. For an action like you specified, you don’t really need to use data: - you can use entity_id: at the same level as service: as a shortcut. So:
- id: '1530900095838'
alias: Living light off
trigger:
- entity_id: binary_sensor.door_window_sensor_158d0001dcb0e3
platform: state
to: 'on'
condition:
- condition: state
entity_id: binary_sensor.fibaro_system_fgms001_motion_sensor_sensor
state: 'on'
- condition: template
value_template: "{{ states.device_tracker|selectattr('state','eq','home')|list|count }}"
action:
- entity_id: switch.a12_key
service: switch.turn_off
I’m confused by your overall goal. Is it just to turn off switch.a12_key when the last person leaves?
No need to use door or motion for that if you have nmap for people. Just use a group for all device trackers (NMAP), when group goes to off, then turn off the light.
No need to count either. The group will stay ON as long as at least one person is home.
I would love to use nmap in automation more, but it is not working really good. When iphones are “asleep” - they are not visible for nmap, so I had to use home_interval: 15 so the light will turn off only after 15 minutes after group living home
Understood. I had issues with presence in the beginning. Never used NMAP for the reason you described. What about using the HA phone app along with NMAP?
I do like the automation you’ve done, it will probably work well, but getting a good reliable presence detection can really be very useful for future automations too.
Could you share a link where I can read more about ios app detection, because when I was reading this I did not find that. Should I just turn on locations for HA app?
Pretty basic. Load the app enable iOS in configuraton and you should be good to go.
There is some smarts that combine multiple trackers with the same MAC into one device in HA.
I recommend playing around and seeing what works best for you. I use ASUSWRT, the HA app, and I have an apple TV which I also use to turn on and off a input Boolean switch which I use for presence.