Can you make sure you use code blocks and syntax highlighting when pasting your code?
From what you posted I can’t figure out how many automations and how you built them
no worries.
Your automation isn’t built in the right order.
automations need to be structured into:
Trigger: what you need to monitor
Conditions (optional)
action: what you want done.
example:
automation:
- alias: Check sensor value and show notification
trigger:
platform: numeric_state
entity_id: sensor.random_sensor
above: 10
action:
service: persistent_notification.create
data:
message: "Sensor value greater than 10"
in your example try something like that:
automation_check_if_pi2_unavailable_and_reboot:
trigger:
platform: state
entity_id: device_tracker.pi2
# unless you want to track multiple states, you don't need both from and to, one should suffice
from: home
to: not_home
action:
service: switch.turn_off
entity_id: switch.wemo_switch
delay: 00:00:10
service: switch.turn_off
entity_id: switch.wemo_switch
I’m not sure how you set your tracker for your Pi2, but I personally use the ping command. My device is listed as a binary sensor like this:
Below is what worked for me in the end. As soon as I moved that action block to the bottom it stopped working. Had to ssh to HA and delete the code out of automation.yaml.
I tried your block and it gave me this:
2017-09-08 20:29:28 ERROR (SyncWorker_0) [homeassistant.util.yaml] while parsing a block mapping
in “/config/automations.yaml”, line 3, column 5
expected , but found ‘-’
in “/config/automations.yaml”, line 4, column 5
- action:
- service: switch.turn_off
entity_id: switch.wemo_switch
- delay: 00:00:10
- service: switch.turn_on
entity_id: switch.wemo_switch
alias: Pi2 dead turn Wemo Off and On
condition: []
id: '1504685086753'
trigger:
- entity_id: device_tracker.pi2
from: home
platform: state
to: not_home
It’s probably your copy and paste here but action comes after trigger. Cut an paste the code you have into the text box here and then highlight it with </>. It’s hard to tell you what’s wrong the way it’s pasted here.
try this. Also check wether you want it to turn on or off first
- alias: automation_check_if_pi2_unavailable_and_reboot:
trigger:
platform: state
entity_id: device_tracker.pi2
# unless you want to track multiple states, you don't need both from and to, one should suffice
from: 'home'
to: 'not_home'
action:
- service: switch.turn_off
entity_id: switch.wemo_switch
- delay: '00:00:10'
- service: switch.turn_on
entity_id: switch.wemo_switch
core-ssh:/config# hassio homeassistant check
Success homeassistant/check
core-ssh:/config# cp automations.yaml automations.yaml.working
core-ssh:/config# vim automations.yaml
core-ssh:/config# hassio homeassistant check
Error on homeassistant/check: starting version 3.2.2
Testing configuration at /config
2017-09-09 11:36:24 ERROR (MainThread) [homeassistant.bootstrap] Unable to setup error log /config/home-assistant.log (access denied)
2017-09-09 11:36:24 ERROR (SyncWorker_0) [homeassistant.util.yaml] mapping values are not allowed here
in "/config/automations.yaml", line 1, column 56
2017-09-09 11:36:24 ERROR (MainThread) [homeassistant.bootstrap] Error loading /config/configuration.yaml: mapping values are not allowed here
in "/config/automations.yaml", line 1, column 56
core-ssh:/config# cat automations.yaml
- alias: automation_check_if_pi2_unavailable_and_reboot:
trigger:
platform: state
entity_id: device_tracker.pi2
# unless you want to track multiple states, you don't need both from and to, one should suffice
from: 'home'
to: 'not_home'
action:
- service: switch.turn_off
entity_id: switch.wemo_switch
- delay: '00:00:10'
- service: switch.turn_on
entity_id: switch.wemo_switch
core-ssh:/config# cat automations.yaml.working
- action:
- service: switch.turn_off
entity_id: switch.wemo_switch
- delay: 00:00:10
- service: switch.turn_on
entity_id: switch.wemo_switch
alias: Pi2 dead turn Wemo Off and On
condition: []
id: '1504685086753'
trigger:
- entity_id: device_tracker.pi2
from: home
platform: state
to: not_home
core-ssh:/config#
Do you have any other automations? I haven’t used the automations editor or VIM+SSH. I edit my YAML files with notepad++ and winscp. This should be quite a simple automation so I have no idea why it’s not working for you. If you don’t have any other automations could try trouble shoot with a simple automation like this as a test
#turn on wemo insight if turned off
- alias: 'Turn on wemo insight'
initial_state: 'on'
trigger:
platform: state
entity_id: switch.wemo_switch
from: 'on'
to: 'off'
action:
- service: switch.turn_on
entity_id: switch.wemo_switch
This should turn your switch on when you turn it off (it’s pretty much a copy and paste from automation I use)