Hello everyone,
I just thought of an idea while sitting at work and have no idea on the script or coding to do this but.
Usually my wife and I will walk the dogs after 9pm but lately we haven’t been doing it and need to get back in the habit. I thought it would be cool if the script sees that we haven’t left the house together in the last 2 days between 9p-11a to shout out for us to walk the dogs.
This certainly would be the cheapest/free option besides buying expensive dog collar tracking devices. Would love some help on getting this running
input_boolean:
failed_day_one:
failed_day_two:
binary_sensor:
platform: template
sensors:
both_in:
value_template: "{{ states('device_tracker.YOU') == 'home' and states('device_tracker.WIFE') == 'home' }}"
automation:
- alias: Failed day counter
trigger:
platform: time
at: '21:00:00'
action:
service: homeassistant.turn_on
data_template:
entity_id: >
{% if is_state('input_boolean.failed_day_two' , 'on') %} script.walk_the_dog
{% elif is_state('input_boolean.failed_day_one' , 'on') %} input_boolean.failed_day_two
{% else %} input_boolean.failed_day_one {% endif %}
- alias: Probably walked the dog
trigger:
platform: state
entity_id: binary_sensor.both_in
to: 'off'
condition:
condition: time
after: '21:00:00'
before: '23:00:00'
action:
service: homeassistant.turn_off
entity_id:
- input_boolean.failed_day_one
- input_boolean.failed_day_two
script:
walk_the_dog:
sequence:
- service: light.turn_on
entity_id: light.living_room
data:
color: red
- service: notify.YOU
data:
message: "Walk the dog!"
- service: notify.WIFE
data:
message: "Walk the dog!"
Or something similar.
6 Likes
@anon43302295 you are amazing! Can’t thank you enough for the time that you spent on this.
I can edit code and manipulate it but would never be able to do what you did. Though I do get an error that I need to look through and it seems to do with the automation.yaml file that I have that the configuration file is linked to. The error I get is this.
2018-08-28 20:30:40 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: expected a dictionary for dictionary value @ data['action'][0]['data_template']. Got None. (See /home/christoph/.homeassistant/configuration.yaml, line 163). Please check the docs at https://home-assistant.io/components/automation/
1 Like
I would have never thought of that approach. Brilliant!
1 Like
Ahhh… There’s just a small typo…
data_template: >
Should not have > on the end…
Then add a line under that that says:
entity_id: >
No worries
Hopefully you’ve fixed this now from @swiftlyfalling 's note, but I’ve modified the code in my original post to fix the error.
Hope the dogs enjoy it
1 Like
Throwing up no more errors in my HA. Thanks again to you and @swiftlyfalling
2 Likes