Thank you so much
Edit:
I got home and put it in my configuration file as follows (changing level to 50%):
- alias: 'Someone At The Front Door Nighttime'
trigger:
platform: template
value_template: '{{states.switch.front_door_15.attributes.device_tripped}}'
# The Condition Syntax from https://www.home-assistant.io/docs/scripts/conditions/
condition:
- condition: time
# At least one of the following is required.
after: '20:00:00'
before: '08:00:00'
# Text to Speech
action:
- service: media_player.volume_set
data_template:
entity_id: media_player.nighttime_doorbell
volume_level: 0.5
- service: tts.google_say
entity_id: media_player.nighttime_doorbell
data:
message: 'Motion Detected At The Front Door'
# Bedroom Light On - Red at Full Brightness
- service: light.turn_on
# entity_id: light.yeelight_bedside_7811dc9201bd
entity_id: light.yeelight_bslamp1_7811dc9201bd
data:
brightness: 200
color_name: Red
When I look at the config checker, it says:
Invalid config for [automation]: expected a dictionary for dictionary value @ data['action'][0]['data_template']. Got None
extra keys not allowed @ data['action'][0]['volume_level']. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 253). Please check the docs at https://home-assistant.io/components/automation/
Line 253 in my Notepad++ is where the word “Automation” starts. The whole “automation” section reads:
automation:
- alias: 'Someone At The Front Door Daytime'
trigger:
platform: template
value_template: '{{states.switch.front_door_15.attributes.device_tripped}}'
# The Condition Syntax from https://www.home-assistant.io/docs/scripts/conditions/
condition:
- condition: time
# At least one of the following is required.
after: '08:00:00'
before: '20:00:00'
# Text to Speech
action:
service: tts.google_say
entity_id: media_player.whole_house_doorbell
data:
message: 'Motion Detected At The Front Door'
# Bedroom Light On - Red at Full Brightness
# - service: light.turn_on
# entity_id: light.yeelight_bedside_7811dc9201bd
# data:
# brightness: 254
# color_name: Red
- alias: 'Someone At The Front Door Nighttime'
trigger:
platform: template
value_template: '{{states.switch.front_door_15.attributes.device_tripped}}'
# The Condition Syntax from https://www.home-assistant.io/docs/scripts/conditions/
condition:
- condition: time
# At least one of the following is required.
after: '20:00:00'
before: '08:00:00'
# Text to Speech
action:
- service: media_player.volume_set
data_template:
entity_id: media_player.nighttime_doorbell
volume_level: 0.5
- service: tts.google_say
entity_id: media_player.nighttime_doorbell
data:
message: 'Motion Detected At The Front Door'
# Bedroom Light On - Red at Full Brightness
- service: light.turn_on
# entity_id: light.yeelight_bedside_7811dc9201bd
entity_id: light.yeelight_bslamp1_7811dc9201bd
data:
brightness: 200
color_name: Red
- alias: 'Auto Renew SSL Cert'
trigger:
platform: numeric_state
entity_id: sensor.ssl_cert_expiry
below: 29
action:
service: shell_command.renew_ssl
# !include automations.yaml
With the 4 lines hashed the config checker comes back as:
Configuration valid!
I finally figured out where my issue was. I actually needed to start those 4 lines with a line saying “Action:”, so the whole nighttime section now reads:
- alias: 'Someone At The Front Door Nighttime'
trigger:
platform: template
value_template: '{{states.switch.front_door_15.attributes.device_tripped}}'
# The Condition Syntax from https://www.home-assistant.io/docs/scripts/conditions/
condition:
- condition: time
# At least one of the following is required.
after: '20:00:00'
before: '08:00:00'
# Text to Speech
action:
- service: media_player.volume_set
data_template:
entity_id: media_player.nighttime_doorbell
volume_level: 0.5
action:
- service: tts.google_say
entity_id: media_player.nighttime_doorbell
data:
message: 'Motion Detected At The Front Door'
# Bedroom Light On - Red at Full Brightness
- service: light.turn_on
# entity_id: light.yeelight_bedside_7811dc9201bd
entity_id: light.yeelight_bslamp1_7811dc9201bd
data:
brightness: 200
color_name: Red
I thought I might mention it in case someone else was wanting to adjust the volume, came here and added the 4 lines and got config errors like me.
TBH, I’m quite chuffed I figured out what the issue was. Pity it took me over an hour
EDIT: I spoke too soon. I just went and manually triggered it after setting my GH minis to 10% and the sound stays at 10% when it plays the message.
I’ll see if I can get it to work tomorrow. It’s time for bed
EDIT - 23rd June 2019
Okay, I got it changing the volume. What I needed was a “data” line, rather than “data_template”. - see Volume_set not working
The only issue is that because media_player.nighttime_doorbell is a group of 2 Google Home Mini’s, the volume isn’t being set to 50% on each. It seems to be 100% divided between the 2. Using my phone to trigger the automation, my experiment shows the following:
Bedroom Mini . . . . . . . . Loungeroom Mini
10% . . . . . . . . . . . . . . … . . . . . 10% (starting volume)
55% . . . . . . . . . . . . . . … . . . . . 45% (after 1st trigger)
55% . . . . . . . . . . . . . . … . . . . . 45% (after 2nd trigger)
Set loungeroom Mini to 10% (left bedroom to 55%)
73% . . . . . . . . . . . . . . … . . . . . 27% (after 3rd trigger)
Set Bedroom Mini to 10% (left loungeroom at 27%)
41% . . . . . . . . . . . . . . … . . . . . 59% (after 4th trigger)
It looks like I’m going to have to use the individual entity ID’s for the 2 GH mini’s. The following now works as it sets the volume level on the 2 minis individually and then plays the message to the group:
- alias: 'Someone At The Front Door Nighttime'
trigger:
platform: template
value_template: '{{states.switch.front_door_15.attributes.device_tripped}}'
# The Condition Syntax from https://www.home-assistant.io/docs/scripts/conditions/
condition:
- condition: time
# At least one of the following is required.
after: '20:00:00'
before: '08:00:00'
# Text to Speech
action:
- service: media_player.volume_set
data:
entity_id: media_player.master_bedroom_speaker
volume_level: 0.5
- service: media_player.volume_set
data:
entity_id: media_player.living_room_mini
volume_level: 0.5
- service: tts.google_say
entity_id: media_player.nighttime_doorbell
data:
message: 'Motion Detected At The Front Door'
# Bedroom Light On - Red at Full Brightness
- service: light.turn_on
entity_id: light.yeelight_bslamp1_7811dc9201bd
data:
brightness: 200
color_name: Red
Thanks for everyone’s help. Greatly appreciated.