Hi all,
I’m hoping that someone can kindly assist me with my automation’s:
I have 3 x switch entities which are all Tuya devices, added to HA. These 3 x switches control our water heaters/geysers.
(I have setup a schedule using the scheduler-card but for my current setup, this is not ideal so I’d prefer not to use this).
These entities are:
- switch.kitchen_geyser_switch_1
- switch.mns_geyser_switch_1
- switch.main_geyser_switch_1
I’ve tried to create an automation that sets the on off times as seen in the image below. The idea is that this can be easily changed and set back to default using a scene.
Automation attempt:
alias: geyser_schedule
description: ""
trigger:
- platform: time_pattern
minutes: /1
action:
- service: switch.turn_off
data:
entity_id:
- switch.kitchen_geyser_switch_1
- switch.mns_geyser_switch_1
- switch.main_geyser_switch_1
- service: switch.turn_on
data_template:
entity_id: >
{% if is_state('sensor.time',
states('input_datetime.kitchen_geyser_on_time')) and
is_state('sensor.date', 'mon-fri') %}
switch.kitchen_geyser_switch_1
{% elif is_state('sensor.time',
states('input_datetime.mns_geyser_on_time')) %}
switch.mns_geyser_switch_1
{% elif is_state('sensor.time',
states('input_datetime.main_geyser_on_time')) %}
switch.main_geyser_switch_1
{% endif %}
- service: switch.turn_off
data_template:
entity_id: >
{% if is_state('sensor.time',
states('input_datetime.kitchen_geyser_off_time')) and
is_state('sensor.date', 'mon-fri') %}
switch.kitchen_geyser_switch_1
{% elif is_state('sensor.time',
states('input_datetime.mns_geyser_off_time')) %}
switch.mns_geyser_switch_1
{% elif is_state('sensor.time',
states('input_datetime.mns_geyser_second_off_time')) %}
switch.mns_geyser_switch_1
{% elif is_state('sensor.time',
states('input_datetime.main_geyser_off_time')) %}
switch.main_geyser_switch_1
{% elif is_state('sensor.time',
states('input_datetime.main_geyser_second_off_time')) %}
switch.main_geyser_switch_1
{% elif is_state('sensor.time',
states('input_datetime.main_geyser_third_off_time')) %}
switch.main_geyser_switch_1
{% endif %}
- service: logger.log
data_template:
message: >-
Kitchen Geyser On Time: {{
states('input_datetime.kitchen_geyser_on_time') }}, Current Time: {{
states('sensor.time') }}
This is what’s been added to my configuration.yaml:
input_datetime:
kitchen_geyser_on_time:
name: Kitchen Geyser On Time
has_date: false
has_time: true
initial: "12:00:00"
kitchen_geyser_off_time:
name: Kitchen Geyser Off Time
has_date: false
has_time: true
initial: "13:30:00"
mns_geyser_on_time:
name: MNS Geyser On Time
has_date: false
has_time: true
initial: "09:00:00"
mns_geyser_off_time:
name: MNS Geyser Off Time
has_date: false
has_time: true
initial: "10:30:00"
mns_geyser_second_on_time:
name: MNS Geyser Second On Time
has_date: false
has_time: true
initial: "13:30:00"
mns_geyser_second_off_time:
name: MNS Geyser Second Off Time
has_date: false
has_time: true
initial: "15:00:00"
main_geyser_on_time:
name: Main Geyser On Time
has_date: false
has_time: true
initial: "04:30:00"
main_geyser_off_time:
name: Main Geyser Off Time
has_date: false
has_time: true
initial: "06:00:00"
main_geyser_second_on_time:
name: Main Geyser Second On Time
has_date: false
has_time: true
initial: "10:30:00"
main_geyser_second_off_time:
name: Main Geyser Second Off Time
has_date: false
has_time: true
initial: "12:00:00"
main_geyser_third_on_time:
name: Main Geyser Third On Time
has_date: false
has_time: true
initial: "15:00:00"
main_geyser_third_off_time:
name: Main Geyser Third Off Time
has_date: false
has_time: true
initial: "16:00:00"
I’ve tried running the automation but it doesn’t appear to do anything.
Here are 2 x log errors that I got:
Further log details:
Logger: homeassistant.components.automation.geyser_schedule
Source: components/automation/init.py:676
Integration: Automation (documentation, issues)
First occurred: December 6, 2023 at 22:13:01 (97 occurrences)
Last logged: December 6, 2023 at 23:49:01
Error while executing automation automation.geyser_schedule: not a valid value for dictionary value @ data[‘entity_id’]
and
Logger: homeassistant.components.automation.geyser_schedule
Source: helpers/script.py:1783
Integration: Automation (documentation, issues)
First occurred: December 6, 2023 at 22:13:01 (97 occurrences)
Last logged: December 6, 2023 at 23:49:01
geyser_schedule: Error executing script. Invalid data for call_service at pos 2: not a valid value for dictionary value @ data[‘entity_id’]
Any assistance would really be appreciated!