Its winther, blockheater funktion!

Hi, I have made a blockheater function where you kan use several sockets and temperature sensors.
I hope it will be useful to someone.
Feel free to ask if there is something that dont work.
Download the file in the end to get the right format.

Regards Andreas

#################################################################################################################

Car heater package for multi sockets

Source https://github.com/Danielhiversen/home-assistant_config/blob/master/packages/alarm_clock.yaml

And seriksson at Car Heater (winter is coming) need coding help!

Great thank to all involved

#################################################################################################################

################################################## How to Use ###############################################################

I have divided my configuration in a separate file, information about how to do this can be found on www.home-assistant.io.

Number of engine heat outputs you add or remove in group and input_select.

All names and friendly_name are in swedish, change to what you want.

There are 5 different levels that trigger from +5 to -15 °C

You have to add id number to automations and change entity_id in blockheater_group.

My automations and blockheater_val trigger “switch.blockheaterXXX_switch”, where blockheaterXXX comes from blockheater_val.

Any improvements or faults are gladly accepted

Use this as you like

#Automations

  • alias: heater minus 15
    id: ‘XXXXXXXXXXXXXX’
    initial_state: false
    trigger:
    • platform: time
      minutes: ‘/5’
      seconds: ‘2’
      condition:
    • condition: numeric_state
      entity_id: sensor.temp_heater
      below: ‘-15’
    • condition: template
      value_template: ‘{{ ((now().strftime("%s") | int + 7200) | timestamp_custom("%H:%M")) == states(“sensor.departuretime”) }}’
      action:
    • service: script.turn_on
      entity_id: script.heat_on
    • service: notify.xxxxxxxxxx

    change to notify service of your choise

    data_template:
    message: “{{ states(‘input_select.blockheater_val’) }} är på i 2h from {{ now().strftime(’%H:%M’) }} Temp: {{ states(‘sensor.temp_heater’) }}°C”
    • service: homeassistant.turn_off
      entity_id:
      • automation.heater_minus_15
      • automation.heater_minus_10
      • automation.heater_minus_5
      • automation.heater_nollan
      • automation.heater_plus_5
  • alias: heater minus 10
    id: ‘xxxxxxxxxxxxxx’
    initial_state: false
    trigger:
    • platform: time
      minutes: ‘/5’
      seconds: ‘2’
      condition:
    • condition: numeric_state
      entity_id: sensor.temp_heater
      below: ‘-10’
    • condition: template
      value_template: ‘{{ ((now().strftime("%s") | int + 5400) | timestamp_custom("%H:%M")) == states(“sensor.departuretime”) }}’
      action:
    • service: script.turn_on
      entity_id: script.heat_on
    • service: notify.xxxxxxxxxxx

    change to notify service of your choise

    data_template:
    message: “{{ states(‘input_select.blockheater_val’) }} är på i 1,5h from {{ now().strftime(’%H:%M’) }} Temp: {{ states(‘sensor.temp_heater’) }}°C”
    • service: homeassistant.turn_off
      entity_id:
      • automation.heater_minus_15
      • automation.heater_minus_10
      • automation.heater_minus_5
      • automation.heater_nollan
      • automation.heater_plus_5
  • alias: heater minus 5
    id: ‘xxxxxxxxxxxxxx’
    initial_state: false
    trigger:
    • platform: time
      minutes: ‘/5’
      seconds: ‘2’
      condition:
    • condition: numeric_state
      entity_id: sensor.temp_heater
      below: ‘-5’
    • condition: template
      value_template: ‘{{ ((now().strftime("%s") | int + 3600) | timestamp_custom("%H:%M")) == states(“sensor.departuretime”) }}’
      action:
    • service: script.turn_on
      entity_id: script.heat_on
    • service: notify.xxxxxxxx

    change to notify service of your choise

    data_template:
    message: “{{ states(‘input_select.blockheater_val’) }} är på i 1h from {{ now().strftime(’%H:%M’) }} Temp: {{ states(‘sensor.temp_heater’) }}°C”
    • service: homeassistant.turn_off
      entity_id:
      • automation.heater_minus_15
      • automation.heater_minus_10
      • automation.heater_minus_5
      • automation.heater_nollan
      • automation.heater_plus_5
  • alias: heater nollan
    id: ‘xxxxxxxxxxxxxx’
    initial_state: false
    trigger:
    • platform: time
      minutes: ‘/5’
      seconds: ‘2’
      condition:
    • condition: numeric_state
      entity_id: sensor.temp_heater
      below: ‘0’
    • condition: template
      value_template: ‘{{ ((now().strftime("%s") | int + 2700) | timestamp_custom("%H:%M")) == states(“sensor.departuretime”) }}’
      action:
    • service: script.turn_on
      entity_id: script.heat_on
    • service: notify.xxxxxxxx

    change to notify service of your choise

    data_template:
    message: “{{ states(‘input_select.blockheater_val’) }} är på i 45 min from {{ now().strftime(’%H:%M’) }} Temp: {{ states(‘sensor.temp_heater’) }}°C”
    • service: homeassistant.turn_off
      entity_id:
      • automation.heater_minus_15
      • automation.heater_minus_10
      • automation.heater_minus_5
      • automation.heater_nollan
      • automation.heater_plus_5
  • alias: heater plus 5
    id: ‘xxxxxxxxxxxxx’
    initial_state: false
    trigger:
    • platform: time
      minutes: ‘/5’
      seconds: ‘2’
      condition:
    • condition: numeric_state
      entity_id: sensor.temp_heater
      below: ‘5’
    • condition: template
      value_template: ‘{{ ((now().strftime("%s") | int + 1800) | timestamp_custom("%H:%M")) == states(“sensor.departuretime”) }}’
      action:
    • service: script.turn_on
      entity_id: script.heat_on
    • service: notify.xxxxxxxx

    change to notify service of your choise

    data_template:
    message: “{{ states(‘input_select.blockheater_val’) }} är på i 30 min from {{ now().strftime(’%H:%M’) }} Temp: {{ states(‘sensor.temp_heater’) }}°C”
    • service: homeassistant.turn_off
      entity_id:
      • automation.heater_minus_15
      • automation.heater_minus_10
      • automation.heater_minus_5
      • automation.heater_nollan
      • automation.heater_plus_5
  • alias: heater enabled
    id: ‘xxxxxxxxxxxxx’
    trigger:
    platform: state
    entity_id: input_number.heater_hour, input_number.heater_minutes, input_select.blockheater_val
    action:
    • service: homeassistant.turn_on
      entity_id:
      • automation.heater_minus_15
      • automation.heater_minus_10
      • automation.heater_minus_5
      • automation.heater_nollan
      • automation.heater_plus_5
  • alias: heater off
    id: ‘xxxxxxxxxxxxx’
    initial_state: false
    trigger:
    • platform: time
      minutes: ‘/5’
      seconds: ‘2’
      condition:
    • condition: template
      value_template: ‘{{ now().hour == (states.input_number.heater_hour.state | round(0)) and now().minute == (states.input_number.heater_minutes.state | round(0) ) }}’
      action:
    • service: switch.turn_off
      data:
      entity_id: switch.block_heater
    • service: homeassistant.turn_off
      entity_id:
      • automation.heater_off
    • service: notify.kroksta_hass

    change to notify service of your choise

    data_template:
    message: “Motorvärmare stängs nu av {{ now().strftime(’%H:%M’) }} Temp: {{ states.sensor.temp_heater.state }}°C”

    change message to language of your choise

<---->
#Groups
heater_disable:
entities:
- automation.heater_minus_15
- automation.heater_minus_10
- automation.heater_minus_5
- automation.heater_nollan
- automation.heater_plus_5
heater_all:
name: “Motorvärmaren”
entities:
- input_select.blockheater_val
- group.heater_disable
- sensor.departuretime
- input_number.heater_hour
- input_number.heater_minutes
- sensor.temp_heater
- switch.block_heater
blockheater_group:
name: “Motorvärmar grupp”
entities:
- switch.your_switch1
- switch.your_switch2
- switch.your_switch3
#Add or remove to suit your setup
<---->
#Input_select
blockheater_val:
name: Motorvärmaren
options:

  • blockheater_1
  • blockheater_2
  • blockheater_3
    #add or remove to suit your setup
    icon: mdi:engine
    <---->
    #Input_number
    heater_hour:
    name: Timmar
    icon: mdi:timer
    initial: 07
    min: 0
    max: 23
    step: 1

heater_minutes:
name: Minuter
icon: mdi:timer
initial: 30
min: 0
max: 55
step: 5
<---->
#script
heat_on:
alias: heater_on
sequence:

  • service: switch.turn_on
    data:
    entity_id: switch.block_heater
  • service: automation.turn_on
    data:
    entity_id: automation.heater_off
    <---->
    #sensor
    temp_heater:
    friendly_name: “Temperatur”
    value_template: >
    {% if is_state(‘input_select.blockheater_val’, ‘blockheater_3’) %}
    {{ states.sensor.your_temo_sensor1.state }}
    {% else %}
    {{ states.sensor.your_temp_sensor2.state }}
    {% endif %}
    #I have set up one blockheater inside my garage and the other is outside. If you have more or less sockets to control change it here
    <---->
    #switch
    block_heater:
    friendly_name: “Motorvärmaren PÅ/AV”
    value_template: “{{ is_state(‘group.blockheater_group’, ‘on’) }}”
    turn_on:
    service: switch.turn_on
    data_template:
    entity_id: “switch.{{ states(‘input_select.blockheater_val’) }}_switch”
    turn_off:
    service: switch.turn_off
    data_template:
    entity_id: “switch.{{ states(‘input_select.blockheater_val’) }}_switch”
    icon_template: >-
    {% if is_state(‘group.blockheater_group’, ‘off’) %}
    mdi:engine-outline
    {% else %}
    mdi:engine
    {% endif %}
    mv_all:
    value_template: “{{ states.group.heater_disable.state }}”
    turn_on:
    service: homeassistant.turn_on
    data:
    entity_id: group.heater_disable
    turn_off:
    service: homeassistant.turn_off
    data:
    entity_id: group.heater_disable
    icon_template: >-
    {% if is_state(‘group.heater_disable’, ‘off’) %}
    mdi:engine-outline
    {% else %}
    mdi:engine
    {% endif %}

Blockheater multi.yaml (9.6 KB)