I can get the array to be dynamic in the developers tools
{% set s_wk =
{state_attr('input_datetime.sp1_wk', 'hour'): states('input_number.t1_wk'),
state_attr('input_datetime.sp2_wk', 'hour'): states('input_number.t2_wk'),
state_attr('input_datetime.sp3_wk', 'hour'): states('input_number.t3_wk'),
state_attr('input_datetime.sp4_wk', 'hour'): states('input_number.t4_wk'),
state_attr('input_datetime.sp5_wk', 'hour'): states('input_number.t5_wk')} %}
{% set s_wknd =
{state_attr('input_datetime.sp1_wknd', 'hour'): states('input_number.t1_wknd'),
state_attr('input_datetime.sp2_wknd', 'hour'): states('input_number.t2_wknd'),
state_attr('input_datetime.sp3_wknd', 'hour'): states('input_number.t3_wknd'),
state_attr('input_datetime.sp4_wknd', 'hour'): states('input_number.t4_wknd'),
state_attr('input_datetime.sp5_wknd', 'hour'): states('input_number.t5_wknd')} %}
{% set hour = now().hour %}
{{ hour }}
{{s_wk[19]}}
{{s_wknd[20]}}
And here is screen shot from developer tools
but I can’t get it to work in the automation.
Also when working on an ecobee thermostat it would not set the temperature it you also set the hvac_mode.
alias: Main Floor Thermostat Control Heat Control
description: 'Set the main floor thermostat for Heat'
trigger:
- id: 'schedule'
platform: time
at:
- input_datetime.sp1_wk
- input_datetime.sp2_wk
- input_datetime.sp3_wk
- input_datetime.sp4_wk
- input_datetime.sp5_wk
- input_datetime.sp1_wknd
- input_datetime.sp2_wknd
- input_datetime.sp3_wknd
- input_datetime.sp4_wknd
- input_datetime.sp5_wknd
- id: 'override'
platform: state
entity_id: input_boolean.thermostat_main
to: 'on'
for: '00:00:30'
- id: 'disable'
platform: state
entity_id: input_boolean.thermostat_main
to: 'off'
for: '00:00:30'
condition: []
action:
- choose:
- conditions:
- "{{ trigger.id != 'disable' }}"
- "{{ is_state('input_boolean.thermostat_main', 'on') }}"
sequence:
- variables:
weekday:
1: 61
2: 61
3: 61
4: 61
5: 61
6: 61
7: 61
8: 68
9: 68
10: 68
11: 68
12: 68
13: 68
14: 68
15: 68
16: 68
17: 50
18: 68
19: 68
20: 68
21: 61
22: 61
23: 61
24: 61
weekend:
1: 61
2: 61
3: 61
4: 61
5: 61
6: 61
7: 61
8: 68
9: 68
10: 68
11: 68
12: 68
13: 68
14: 68
15: 68
16: 68
17: 50
18: 68
19: 68
20: 68
21: 61
22: 61
23: 61
24: 61
schedule: "{{ weekday if now().isoweekday() in [1,2,3,4,5] else weekend }}"
- service: climate.set_temperature
target:
entity_id: climate.main_floor
data:
temperature: "{{ schedule[now().hour] }}"
- conditions:
- "{{ trigger.id == 'disable' }}"
sequence:
- service: climate.turn_off
target:
entity_id: climate.main_floor
data:
hvac_mode: 'off'
default: []
mode: single
I have searched and can find nothing that helps.
Also simplified the temperature as the documentation explained that it always took the first match so this limits it to one action per hour but that was limited anyways. You can have it anywhere in the hour to trigger. I was doing the 1-24 so I could test. I have tried
sequence:
- variables:
weekday:
- value_template: >-
{% {state_attr('input_datetime.sp1_wk', 'hour'): states('input_number.t1_wk'),
state_attr('input_datetime.sp2_wk', 'hour'): states('input_number.t2_wk'),
state_attr('input_datetime.sp3_wk', 'hour'): states('input_number.t3_wk'),
state_attr('input_datetime.sp4_wk', 'hour'): states('input_number.t4_wk'),
state_attr('input_datetime.sp5_wk', 'hour'): states('input_number.t5_wk')} %}
and get this error
Error loading /config/configuration.yaml: while scanning for the next token found character ‘%’ that cannot start any token in “/config/automations/main_floor/MainFloorThermostatControl.yaml”, line 38, column 20
I have tried this:
sequence:
- variables:
weekday:
- value_template: >-
{{ {state_attr('input_datetime.sp1_wk', 'hour'): states('input_number.t1_wk'),
state_attr('input_datetime.sp2_wk', 'hour'): states('input_number.t2_wk'),
state_attr('input_datetime.sp3_wk', 'hour'): states('input_number.t3_wk'),
state_attr('input_datetime.sp4_wk', 'hour'): states('input_number.t4_wk'),
state_attr('input_datetime.sp5_wk', 'hour'): states('input_number.t5_wk')} }}
and I get this error:
Error loading /config/configuration.yaml: while scanning a simple key in “/config/automations/main_floor/MainFloorThermostatControl.yaml”, line 38, column 19 could not find expected ‘:’
in “/config/automations/main_floor/MainFloorThermostatControl.yaml”, line 39, column 23
I tried this:
sequence:
- variables:
weekday:
- value_template: >-
"{{ {state_attr('input_datetime.sp1_wk', 'hour'): states('input_number.t1_wk'),
state_attr('input_datetime.sp2_wk', 'hour'): states('input_number.t2_wk'),
state_attr('input_datetime.sp3_wk', 'hour'): states('input_number.t3_wk'),
state_attr('input_datetime.sp4_wk', 'hour'): states('input_number.t4_wk'),
state_attr('input_datetime.sp5_wk', 'hour'): states('input_number.t5_wk')} }}"
and got this error
Error loading /config/configuration.yaml: while scanning a simple key in “/config/automations/main_floor/MainFloorThermostatControl.yaml”, line 38, column 19 could not find expected ‘:’
in “/config/automations/main_floor/MainFloorThermostatControl.yaml”, line 42, column 101
And I have tried this:
sequence:
- variables:
weekday:
- value_template: >-
"{{ {state_attr('input_datetime.sp1_wk', 'hour') ~ ':' ~ states('input_number.t1_wk'),
state_attr('input_datetime.sp2_wk', 'hour') ~ ':' ~ states('input_number.t2_wk'),
state_attr('input_datetime.sp3_wk', 'hour') ~ ':' ~ states('input_number.t3_wk'),
state_attr('input_datetime.sp4_wk', 'hour') ~ ':' ~states('input_number.t4_wk'),
state_attr('input_datetime.sp5_wk', 'hour') ~ ':' ~ states('input_number.t5_wk')} }}"
And I get this error:
Error loading /config/configuration.yaml: while scanning a simple key in “/config/automations/main_floor/MainFloorThermostatControl.yaml”, line 38, column 19 could not find expected ‘:’
in “/config/automations/main_floor/MainFloorThermostatControl.yaml”, line 42, column 108
and lastly I tried this:
sequence:
- variables:
weekday:
- value_template:
{{state_attr('input_datetime.sp1_wk', 'hour') }} : {{states('input_number.t1_wk')}}
{{state_attr('input_datetime.sp2_wk', 'hour') }} : {{states('input_number.t2_wk')}}
{{state_attr('input_datetime.sp3_wk', 'hour') }} : {{states('input_number.t3_wk')}}
{{state_attr('input_datetime.sp4_wk', 'hour') }} : {{states('input_number.t4_wk')}}
{{state_attr('input_datetime.sp5_wk', 'hour') }} : {{states('input_number.t5_wk')}}
Error loading /config/configuration.yaml: while parsing a flow mapping in “/config/automations/main_floor/MainFloorThermostatControl.yaml”, line 38, column 22 expected ‘,’ or ‘}’, but got ‘’
in “/config/automations/main_floor/MainFloorThermostatControl.yaml”, line 38, column 65
and I tried it with quotes and a comma
sequence:
- variables:
weekday:
- value_template:
"{{state_attr('input_datetime.sp1_wk', 'hour') }}" : "{{states('input_number.t1_wk')}}",
"{{state_attr('input_datetime.sp2_wk', 'hour') }}" : "{{states('input_number.t2_wk')}}",
"{{state_attr('input_datetime.sp3_wk', 'hour') }}" : "{{states('input_number.t3_wk')}}",
"{{state_attr('input_datetime.sp4_wk', 'hour') }}" : "{{states('input_number.t4_wk')}}",
"{{state_attr('input_datetime.sp5_wk', 'hour') }}" : "{{states('input_number.t5_wk')}}"
this passed the configuration validation
variables:
weekday:
- value_template: ''
'{{state_attr(''input_datetime.sp1_wk'', ''hour'') }}': '{{states(''input_number.t1_wk'')}}'
'{{state_attr(''input_datetime.sp2_wk'', ''hour'') }}': '{{states(''input_number.t2_wk'')}}'
'{{state_attr(''input_datetime.sp3_wk'', ''hour'') }}': '{{states(''input_number.t3_wk'')}}'
'{{state_attr(''input_datetime.sp4_wk'', ''hour'') }}': '{{states(''input_number.t4_wk'')}}'
'{{state_attr(''input_datetime.sp5_wk'', ''hour'') }}': '{{states(''input_number.t5_wk'')}}'
but when executed got this:
Took the value_template out and same issue . The thermostat never set and when I do it with numbers it works.
Any guidance ???