welcome home alexa greeting: Error executing script. Unexpected error for call_service at pos 1: __call__() takes 2 positional arguments but 3 were given
Thanks for correcting the code. While I was testing the code, my motion sensor crapped out. It took me awhile to figure out if it was the code that was the issue the sensor.
@anon43302295
I have fixed the motion sensor issue rather figured out why it wasn’t working. It wasn’t a malfunction of the sensor, but a pairing issue.
I’ve gotten a little fancy with the automation and enhanced the script. Announcement will run between 5-8pm. Lights turn on regardless. Randomize some welcome messages. Tested and it works.
There is one little issue I have that I cannot figure out. The announcement happens between 5-8pm. If I am home that day or have came home and decide to leave between those hours, Alexa will make the announcement which will sound strange.
automations.yaml
## Welcome Home Alexa Greeting
- alias: 'motion genkan light on'
trigger:
platform: state
entity_id: binary_sensor.motion_genkan_occupancy
to: 'on'
condition:
- condition: or
conditions:
- condition: state
entity_id: input_boolean.eri_home
state: 'on'
- condition: state
entity_id: input_boolean.duc_home
state: 'on'
action:
- service: script.welcome_notify
- condition: state
entity_id: light.h_1
state: 'off'
- service: light.turn_on
entity_id: light.h_1
data:
brightness: 200
# Turn off light if no motion after 30 sec
- alias: 'motion genkan light off'
trigger:
- entity_id: binary_sensor.motion_genkan_occupancy
for: 00:00:30
from: 'on'
platform: state
to: 'off'
action:
- service: light.turn_off
data:
entity_id: light.h_1
scripts.yaml
# Welcome Home Announcement
welcome_notify:
alias: Welcome Home Notify
sequence:
- service: notify.alexa_media
data_template:
data:
type: tts
target:
- media_player.ai_2
message: >
{% if now().hour > 16 and now().hour < 20 %}
{% set name = 'Eddie' if is_state('input_boolean.eri_home' , 'on') else 'Duck' %}
Welcome home {{ name }}.
{{ (
'Hope you had a wonderful day today.',
'How was your day?',
'I am glad to see you home.'
)|random }}
{% endif %}