Hi I have a RPi Zero running Buster, HA 0.106.6. It controls switches, a Yale Smart Alarm and cameras. I wanted to be able to automatically activate the alarm when I left home. It would need to have the enable/disable button so that I could allow others to remain in the the house if necessary.
I have coded a device tracker that uses my router to ping my phone. This works well and the HA app shows the phone home or away. I have tried to create an automation with the automation editer that links this to the services from the Yale Alarm - alarm_arm_home. I have also tried to write automation code directly to my configuration.yaml. No success so far using either platform state or template. Does anyone have some code that works for this? Thanks
What is ‘Sarmt’ ???
EIDT: Tihs is not to be ctnosuerd as aynhntig oehtr tahn a rthcaeroil qoiutsen
Hi I copy/paste my code attempts. Any thoughts appreciated. Maybe this code would have worked but for some mistake on my part.
automation:
- alias: “Alarm: Armed iPhone Away”
trigger:
platform: state
entity_id: alarm_control_panel.yale_smart_alarm
to: ‘armed_home’
condition:
condition: device_tracker.feh_iphone
state: Away
action:
service: scene.apply
entity_id: scene.OnArmedHome
Example configuration.yaml entry
alarm_control_panel:
- platform: template
panels:
safe_alarm_panel:
value_template: “{{ states(‘alarm_control_panel.real_alarm’) }}”
arm_home:
- condition: state
entity_id: device_tracker.feh_iphone
state: ‘away’
- service: alarm_arm_home
data:
entity_id: alarm_control_panel.yale_smart_alarm
code: xxxxx
disarm:
- condition: state
entity_id: device_tracker.feh_iphone
state: ‘home’
- service: alarm_arm_disarm
data:
entity_id: alarm_control_panel.yale_smart_alarm
code: xxxxx
Example automation
automation:
trigger:
platform: state
entity_id: device_tracker.feh_iphone
from: “home”
to: “away”
action:
service: scene.apply
data:
entities:
alarm_control_panel.yale_smart_alarm:
state: armed_home
Example automations.yaml entry
- id: my_unique_id # <-- Required for editor to work, for automations created with the editor the id will be automatically generated.
alias: Yale Alarm Armed Away
trigger:- platform: state
entity_id: device_tracker.feh_iphone
from: home
to: away
action: - service: alarm_arm_home
- platform: state
Hi Yes- sorry I was rushing and I am not sure exactly how to keep the spacing. So I have made an image of the yaml file. Hope this works.
Are you using all the above automations? You do not need to for this simple task.
All you need is a trigger when your phone leaves your “home” zone. Then a action to call the “arm_home”
Did you read the topic I linked???
Copy your code in the forum post, highlight the code, press </> button on top, done.
Hi Thanks. No, I tried these individually - I was just sending all my attempts collected in one file. Just to check trigger: phone away, action: armed_home - I will try it later today. Thanks again
Thanks - I will do this in future.
Hi I have tried to use the automation editor to build this. The trigger - my phone home to away and then the action to call service - arm_home. All this seems to go well as I can select my phone from “states” and “call services” for the Yale armed_home - both from the drop down menus. But the editor will not save this simple automation - it gives me no error message but there seems to be something else I need to add. Any ideas much appreciated. Thanks.
Do you have this in configuration.yaml?
automation: !include automations.yaml
Hi Yes - I paste a section:
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
automation: !include automations.yaml
customize: !include customize.yaml
# Show the introduction message on startup.
But there is something odd because my automations.yaml has other automations I have created but these are not present under the automation section of the UI. I do use WinSCP and notepad++ to look and edit these yaml files separately from the HA editor - does this create a problem? Thanks.
Thanks - I copied my editor produced automations into configuratuion.yaml - now I just need to check if the automatic trigger idea from Dayve67. I will let you know. Your help is much appreciated.
Hi I have not been successful with this. My configuration.yaml has:
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
config:
automation: !include automations.yaml
customize: !include customize.yaml
script: !include scripts.yaml
# Show the introduction message on startup.
#introduction: Hi
I still have problems however using the automation editor in HA - I can create the automation and it is present in automations.yaml but it does not appear as an automation list in HA. There are always errors when I check the configuration. Here is my automations.yaml: the error message is automations.yaml", line 1, column 1
expected , but found ‘’
- id: '1584626326778'
alias: Automatic Yale Alarm
description: ''
trigger:
- entity_id: device_tracker.feh_iphone
from: Home
platform: state
to: Away
condition: []
action:
- data: {}
service: alarm_control_panel.alarm_arm_home
- id: '1001'
- alias: Doorbell_pressed_automation
trigger:
platform: mqtt
topic: dev/test
payload: 'Capture!'
action:
- service: automation.turn_off
entity_id: automation.doorbell_pressed_automation
- service: script.turn_on
entity_id: script.doorbell_pressed_script
- delay: "00:00:5"
- service: automation.turn_on
entity_id: automation.doorbell_pressed_automation
Does anything look wrong? Thanks!
- id: '1001'
- alias: Doorbell_pressed_automation
Well I don’t use the AE but if I did the list item would be the id: so not sure why alias: would have a dash before it as a separate list item
Thanks that’s worked - the configuration is valid with the change. But I expected to create an executable entity - am I mssing something else from the code? I do not think these automations are being activated - how could that happen?
What do you mean with this?
If you go to the sidebar, Developer Tools -> States, do you see your automations there and do they have a state ‘on’?
Hi thanks for the idea - no they are not there.