Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 103058

Template to script or automation help/ heating schedule

$
0
0

Hi could some one help with the below automation which is currently in use and working, i have this automation running for each room of the house. The final goal is to shorten the code using a template within the automation. At the bottom i have added the template which works in the template editor. I think i have the template correct put i do not know how i can add this to the automation.

Current automation:
alias: MasterBedroomSchedule
description: ‘’
trigger:

  • platform: time_pattern
    minutes: /1
  • platform: state
    entity_id: input_boolean.en_trv_masterbedroom
    condition:
  • condition: state
    entity_id: input_boolean.boost_masterbedroom
    state: ‘off’
    for:
    hours: 0
    minutes: 0
    seconds: 10
  • condition: state
    entity_id: input_boolean.en_trv_masterbedroom
    state: ‘on’
    action:
  • choose:
    • conditions:
      • condition: state
        entity_id: input_boolean.en_trv_masterbedroom1
        state: ‘on’
      • condition: time
        after: input_datetime.onwkday1
        before: input_datetime.offwkday1
        weekday:
        • mon
        • tue
        • wed
        • thu
        • fri
          sequence:
      • service: climate.set_temperature
        data:
        hvac_mode: auto
        temperature: ‘{{ states(’‘input_number.ontemp1’’) }}’
        target:
        entity_id: climate.trv_masterbedroom
        default:
    • condition: not
      conditions:
      • condition: state
        entity_id: input_boolean.en_trv_masterbedroom1
        state: ‘on’
    • condition: time
      after: input_datetime.onwkday1
      before: input_datetime.offwkday1
      weekday:
      • mon
      • tue
      • wed
      • thu
      • fri
    • service: climate.set_temperature
      target:
      entity_id: climate.trv_masterbedroom
      data:
      hvac_mode: ‘off’
      temperature: ‘{{ states(’‘input_number.offtemp1’’) }}’
  • choose:
    • conditions:
      • condition: state
        entity_id: input_boolean.en_trv_masterbedroom2
        state: ‘on’
      • condition: time
        after: input_datetime.onwkday2
        before: input_datetime.offwkday2
        weekday:
        • mon
        • tue
        • wed
        • thu
        • fri
          sequence:
      • service: climate.set_temperature
        data:
        hvac_mode: auto
        temperature: ‘{{ states(’‘input_number.ontemp2’’) }}’
        target:
        entity_id: climate.trv_masterbedroom
        default:
    • condition: time
      after: input_datetime.onwkday2
      before: input_datetime.offwkday2
      weekday:
      • mon
      • tue
      • wed
      • thu
      • fri
    • service: climate.set_temperature
      target:
      entity_id: climate.trv_masterbedroom
      data:
      hvac_mode: ‘off’
      temperature: ‘{{ states(’‘input_number.offtemp2’’) }}’
  • choose:
    • conditions:
      • condition: state
        entity_id: input_boolean.en_trv_masterbedroom3
        state: ‘on’
      • condition: time
        after: input_datetime.onwkday3
        before: input_datetime.offwkday3
        weekday:
        • mon
        • tue
        • wed
        • thu
        • fri
          sequence:
      • service: climate.set_temperature
        data:
        hvac_mode: auto
        temperature: ‘{{ states(’‘input_number.ontemp3’’) }}’
        target:
        entity_id: climate.trv_masterbedroom
        default:
    • condition: time
      after: input_datetime.onwkday3
      before: input_datetime.offwkday3
      weekday:
      • mon
      • tue
      • wed
      • thu
      • fri
    • service: climate.set_temperature
      target:
      entity_id: climate.trv_masterbedroom
      data:
      hvac_mode: ‘off’
      temperature: ‘{{ states(’‘input_number.offtemp3’’) }}’
  • choose:
    • conditions:
      • condition: state
        entity_id: input_boolean.en_trv_masterbedroom4
        state: ‘on’
      • condition: time
        after: input_datetime.onwkend1
        before: input_datetime.offwkend1
        weekday:
        • sat
        • sun
          sequence:
      • service: climate.set_temperature
        data:
        hvac_mode: auto
        temperature: ‘{{ states(’‘input_number.ontemp4’’) }}’
        target:
        entity_id: climate.trv_masterbedroom
        default:
    • condition: time
      after: input_datetime.onwkend1
      before: input_datetime.offwkend1
      weekday:
      • sat
      • sun
    • service: climate.set_temperature
      target:
      entity_id: climate.trv_masterbedroom
      data:
      hvac_mode: ‘off’
      temperature: ‘{{ states(’‘input_number.offtemp4’’) }}’
  • choose:
    • conditions:
      • condition: state
        entity_id: input_boolean.en_trv_masterbedroom5
        state: ‘on’
      • condition: time
        after: input_datetime.onwkend2
        before: input_datetime.offwkend2
        weekday:
        • sat
        • sun
          sequence:
      • service: climate.set_temperature
        data:
        hvac_mode: auto
        temperature: ‘{{ states(’‘input_number.ontemp5’’) }}’
        target:
        entity_id: climate.trv_masterbedroom
        default:
    • condition: time
      after: input_datetime.onwkend2
      before: input_datetime.offwkend2
      weekday:
      • sat
      • sun
    • service: climate.set_temperature
      target:
      entity_id: climate.trv_masterbedroom
      data:
      hvac_mode: ‘off’
      temperature: ‘{{ states(’‘input_number.offtemp5’’) }}’
  • choose:
    • conditions:
      • condition: state
        entity_id: input_boolean.en_trv_masterbedroom6
        state: ‘on’
      • condition: time
        after: input_datetime.onwkend3
        before: input_datetime.offwkend3
        weekday:
        • sat
        • sun
          sequence:
      • service: climate.set_temperature
        data:
        hvac_mode: auto
        temperature: ‘{{ states(’‘input_number.ontemp6’’) }}’
        target:
        entity_id: climate.trv_masterbedroom
        default:
    • condition: time
      after: input_datetime.onwkend3
      before: input_datetime.offwkend3
      weekday:
      • sat
      • sun
    • service: climate.set_temperature
      target:
      entity_id: climate.trv_masterbedroom
      data:
      hvac_mode: ‘off’
      temperature: ‘{{ states(’‘input_number.offtemp6’’) }}’
  • choose:
    • conditions:
      • condition: time
        after: input_datetime.offwkday1
        before: input_datetime.onwkday2
        weekday:
        • mon
        • tue
        • wed
        • thu
        • fri
          sequence:
      • service: climate.set_temperature
        data:
        hvac_mode: ‘off’
        temperature: ‘{{ states(’‘input_number.offtemp1’’) }}’
        target:
        entity_id: climate.trv_masterbedroom
        default: []
  • choose:
    • conditions:
      • condition: time
        after: input_datetime.offwkday2
        before: input_datetime.onwkday3
        weekday:
        • mon
        • tue
        • wed
        • thu
        • fri
          sequence:
      • service: climate.set_temperature
        data:
        hvac_mode: ‘off’
        temperature: ‘{{ states(’‘input_number.offtemp2’’) }}’
        target:
        entity_id: climate.trv_masterbedroom
        default: []
  • choose:
    • conditions:
      • condition: time
        after: input_datetime.offwkday3
        before: input_datetime.onwkday1
        weekday:
        • mon
        • tue
        • wed
        • thu
        • fri
          sequence:
      • service: climate.set_temperature
        data:
        hvac_mode: ‘off’
        temperature: ‘{{ states(’‘input_number.offtemp3’’) }}’
        target:
        entity_id: climate.trv_masterbedroom
        default: []
  • choose:
    • conditions:
      • condition: time
        after: input_datetime.offwkend1
        before: input_datetime.onwkend2
        weekday:
        • sat
        • sun
          sequence:
      • service: climate.set_temperature
        data:
        hvac_mode: ‘off’
        temperature: ‘{{ states(’‘input_number.offtemp4’’) }}’
        target:
        entity_id: climate.trv_masterbedroom
        default: []
  • choose:
    • conditions:
      • condition: time
        after: input_datetime.offwkend2
        before: input_datetime.onwkend3
        weekday:
        • sat
        • sun
          sequence:
      • service: climate.set_temperature
        data:
        hvac_mode: ‘off’
        temperature: ‘{{ states(’‘input_number.offtemp5’’) }}’
        target:
        entity_id: climate.trv_masterbedroom
        default: []
  • choose:
    • conditions:
      • condition: time
        after: input_datetime.offwkend3
        weekday:
        • sat
        • sun
          sequence:
      • service: climate.set_temperature
        data:
        hvac_mode: ‘off’
        temperature: ‘{{ states(’‘input_number.offtemp6’’) }}’
        target:
        entity_id: climate.trv_masterbedroom
        default: []
  • service: climate.set_preset_mode
    data:
    preset_mode: manual
    target:
    entity_id: climate.trv_masterbedroom
    mode: single

The template was a test but worked as as expected.

My template below :
{% set dev =
(state_attr(“climate.trv_masterbedroom”,“local_temperature”)|float -
state_attr(“climate.trv_masterbedroom”,“temperature”)|float)|round(2)%}
{{dev}}
{%for times in range(1,11)%}

{% if now().weekday() < 5 |int %}
{% set ontime = today_at(states(“input_datetime.onwkday” ~ times)) %}
{% set offtime = today_at(states(“input_datetime.offwkday” ~ times)) %}

{% else %}
{% set ontime = today_at(states(“input_datetime.onwkend” ~ times)) %}
{% set offtime = today_at(states(“input_datetime.offwkend” ~ times)) %}

{%endif%}

{%if now() >= ontime and now() < offtime %}
{{" Heating on"}}
{%else%}
{{" Heating Off"}}
{%endif%}
{%endfor%}

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 103058

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>