I’m slowly trying to replace my hodgepodge of deivces controlling aspects of my home with Homeassistant and I’ve quite enjoyed getting to know my Raspberry Pi, Raspbian and Homeassistant.
One aspect that eludes me so far is presence-based automation using NMap to detect my smartphone. I have succesfully gotten the device tracker component working and presence detection is accurate to within 15 minutes which meets my needs.
What I’d like to automate is the start of the motion service when my device is detected as not_home, and stop motion when home.
Unfortunately my attempts at simply enabling the automation component all result in: homeassistant.bootstrap: component automation failed to initialize
I would greatly appreciate if anyone has any advice to help me understand how this should work.
My attempts:
automation:
alias: turn on camera if presence not detected
trigger:
platform: device_tracker.Nexus6P
state: 'not_home'
action:
shell_command:
start_motion: motion
and
automation:
alias: turn on camera if presence not detected
trigger:
platform: state
entity_id: device_tracker.Nexus6P
state: 'not_home'
action:
shell_command:
start_motion: motion
automation:
alias: turn on camera if presence not detected
trigger:
platform: state
entity_id: device_tracker.Nexus6P
from: 'home'
to: 'not_home'
action:
service: shell_command.start_motion.motion
Should work for the trigger. Not sure about the action as I normally call services with my automations but think it might be something like that
I’m afraid that whilst the automation component is loading, it’s not controlling the motion service as I’d expect it to.
The desired outcome can be achieved by issuing the following commands manually:
Camera on: sudo motion
Camera off: sudo /etc/init.d/motion stop
However with these commands configured in shell_commands they are not producing the same results, either via automation rules or by calling the service in the homeassistant GUI.
Just to check it wasn’t the /hass/ account having insufficient permissions I added it to sudoers, but same result. Removed from sudoers shortly after because I know that’s a bad idea.