Timer Luci Natalizie

HassioHelp

Timer Luci Natalizie

.

Argomento: Package

Livello: Novizio (Novizio,Esperto, Pro)

Difficoltà: Bassa (Bassa, Media, Alta)

Introduzione

In questo periodo natalizio e non solo siamo alle prese con l’accensione serale e lo spegnimento mattutino delle luminarie che abbiamo sparso per casa. Con questo package realizzato dal nostro admin Mauro è possibile programmare l’accensione e lo spegnimento di quattro diverse entità in modo automatico con l’uso ovviamente di Home Assistant.

Le prerogative di questo package sono:

  • due fasce orarie giornaliere per accensione e spegnimento
  • accensione su alba e tramonto
  • programmazione giornaliera o settimanale sia per la prima e la seconda programmazione ma anche per alba e tramonto 

Questo package ovviamente è adattabile ad ogni tipo di entità e facilmente duplicabile nel caso si volessero più programmazioni (es dal Lun a Ven un orario il Sab e Dom un altro).

Package

Da questo link potete scaricare il package e il codice per Lovelace sia versione grafica che yaml

homeassistant:
customize:
package.node_anchors:
customize: &customize
package: 'natale 2019'
author: 'Mauro Cimino'
reference: 'www.hassiohelp.eu'

expose: &expose
<<: *customize
haaska_hidden: false
homebridge_hidden: false

input_boolean.prima_programmazione_1:
<<: *customize
input_boolean.seconda_programmazione_1:
<<: *customize
input_boolean.programmazione_settimanale_1:
<<: *customize
input_boolean.programmazione_alba_tramonto_1:
<<: *customize
input_boolean.lunedi_1:
<<: *customize
input_boolean.martedi_1:
<<: *customize
input_boolean.mercoledi_1:
<<: *customize
input_boolean.giovedi_1:
<<: *customize
input_boolean.venerdì_1:
<<: *customize
input_boolean.sabato_1:
<<: *customize
input_boolean.domenica_1:
<<: *customize
input_datetime.accensione_uno_1:
<<: *customize
input_datetime.accensione_due_1:
<<: *customize
input_datetime.spegimento_uno_1:
<<: *customize
input_datetime.spegimento_due_1:
<<: *customize
sensor.giorno_della_settimana_1:
<<: *customize

input_boolean:
prima_programmazione_1:
name: Prima Programmazione
icon: mdi:numeric-1-box-outline

seconda_programmazione_1:
name: Seconda Programmazione
icon: mdi:numeric-2-box-outline

programmazione_settimanale_1:
name: Programmazione Settimanale
icon: mdi:calendar-range

programmazione_alba_tramonto_1:
name: Programmazione alba/tramonto
icon: mdi:theme-light-dark

accendi_alba_tramonto:
name: Alba/Tramonto
icon: mdi:theme-light-dark

lunedi_1:
name: Lunedi
icon: mdi:numeric-1-box-multiple-outline

martedi_1:
name: Martedì
icon: mdi:numeric-2-box-multiple-outline

mercoledi_1:
name: Mercoledì
icon: mdi:numeric-3-box-multiple-outline

giovedi_1:
name: Giovedì
icon: mdi:numeric-4-box-multiple-outline

venerdi_1:
name: Venerdì
icon: mdi:numeric-5-box-multiple-outline

sabato_1:
name: Sabato
icon: mdi:numeric-6-box-multiple-outline

domenica_1:
name: Domenica
icon: mdi:numeric-7-box-multiple-outline

input_datetime:
accensione_uno_1:
name: "Prima Accensione"
has_date: false
has_time: true
icon: mdi:power-on

accensione_due_1:
name: "Seconda Accensione"
has_date: false
has_time: true
icon: mdi:power-on

spegimento_uno_1:
name: "Primo Spegnimento"
has_date: false
has_time: true
icon: mdi:power-off

spegimento_due_1:
name: "Secondo Spegnimento"
has_date: false
has_time: true
icon: mdi:power-off

input_text:

luce_uno_1:
name: Luce 1
icon: mdi:numeric-1-box-multiple-outline

luce_due_1:
name: Luce 2
icon: mdi:numeric-2-box-multiple-outline

luce_tre_1:
name: Luce 3
icon: mdi:numeric-3-box-multiple-outline

luce_quattro_1:
name: Luce 4
icon: mdi:numeric-4-box-multiple-outline
input_number:
ritardo_anticipo_alba_1:
name: Numeric Input Box
min: -59
max: 59
step: 1
mode: box
ritardo_anticipo_tramonto_1:
name: Numeric Input Box
min: -59
max: 59
step: 1
mode: box

sensor:
- platform: template
sensors:
giorno_della_settimana_1:
friendly_name: "giorno della settimana"
unit_of_measurement: 'Day'
value_template: >-
{% if now().weekday() in (0,) %} Lunedi
{% elif now().weekday() in (1,) %} Martedì
{% elif now().weekday() in (2,) %} Mercoledì
{% elif now().weekday() in (3,) %} Giovedì
{% elif now().weekday() in (4,) %} Venerdì
{% elif now().weekday() in (5,) %} Sabato
{% elif now().weekday() in (6,) %} Domenica
{% endif %}

automation:

- alias: accensione uno ogni giorno
initial_state: true
trigger:
- platform: template
value_template: >-
{{ states('sensor.time') == (states.input_datetime.accensione_uno_1.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.prima_programmazione_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'off'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'off'
action:
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }},
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: spegniento uno ogni giorno
initial_state: true
trigger:
- platform: template
value_template: >-
{{ states('sensor.time') == (states.input_datetime.spegimento_uno_1.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.prima_programmazione_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'off'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'off'
action:
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }},
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: accensione due ogni giorno
initial_state: true
trigger:
- platform: template
value_template: >-
{{ states('sensor.time') == (states.input_datetime.accensione_due_1.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.seconda_programmazione_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'off'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'off'
action:
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }},
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: spegniento due ogni giorno
initial_state: true
trigger:
- platform: template
value_template: >-
{{ states('sensor.time') == (states.input_datetime.spegimento_due_1.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.prima_programmazione_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'off'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'off'
action:
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: accensione uno giorni settimana
initial_state: true
trigger:
- platform: template
value_template: >-
{{ states('sensor.time') == (states.input_datetime.accensione_uno_1.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.prima_programmazione_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'off'
condition: or
conditions:
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Lunedì' and is_state('input_boolean.lunedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Martedì' and is_state('input_boolean.martedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Mercoledì' and is_state('input_boolean.mercoledi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Giovedì' and is_state('input_boolean.giovedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Venerdì' and is_state('input_boolean.venerdi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Sabato' and is_state('input_boolean.sabato_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Domenica' and is_state('input_boolean.domenica_1' , 'on') }}"
action:
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }},
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: spegnimento uno giorni settimana
initial_state: true
trigger:
- platform: template
value_template: >-
{{ states('sensor.time') == (states.input_datetime.spegimento_uno_1.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.prima_programmazione_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'off'
condition: or
conditions:
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Lunedì' and is_state('input_boolean.lunedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Martedì' and is_state('input_boolean.martedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Mercoledì' and is_state('input_boolean.mercoledi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Giovedì' and is_state('input_boolean.giovedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Venerdì' and is_state('input_boolean.venerdi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Sabato' and is_state('input_boolean.sabato_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Domenica' and is_state('input_boolean.domenica_1' , 'on') }}"
action:
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: accensione due giorni settimana
initial_state: true
trigger:
- platform: template
value_template: >-
{{ states('sensor.time') == (states.input_datetime.accensione_due_1.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.seconda_programmazione_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'off'
condition: or
conditions:
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Lunedì' and is_state('input_boolean.lunedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Martedì' and is_state('input_boolean.martedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Mercoledì' and is_state('input_boolean.mercoledi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Giovedì' and is_state('input_boolean.giovedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Venerdì' and is_state('input_boolean.venerdi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Sabato' and is_state('input_boolean.sabato_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Domenica' and is_state('input_boolean.domenica_1' , 'on') }}"
action:
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: spegnimento due giorni settimana
initial_state: true
trigger:
- platform: template
value_template: >-
{{ states('sensor.time') == (states.input_datetime.spegimento_due_1.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.seconda_programmazione_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'off'
condition: or
conditions:
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Lunedì' and is_state('input_boolean.lunedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Martedì' and is_state('input_boolean.martedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Mercoledì' and is_state('input_boolean.mercoledi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Giovedì' and is_state('input_boolean.giovedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Venerdì' and is_state('input_boolean.venerdi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Sabato' and is_state('input_boolean.sabato_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Domenica' and is_state('input_boolean.domenica_1' , 'on') }}"
action:
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }},
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: accensione alba
trigger:
- platform: sun
event: sunrise
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'off'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'on'
- condition: state
entity_id: input_boolean.accendi_alba_tamonto
state: 'off'
action:
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }},
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: spegnimento tramonto
trigger:
- platform: sun
event: sunset
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'off'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'on'
- condition: state
entity_id: input_boolean.accendi_alba_tamonto
state: 'off'
action:
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: accensione tramonto
trigger:
- platform: sun
event: sunset
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'off'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'on'
- condition: state
entity_id: input_boolean.accendi_alba_tamonto
state: 'on'
action:
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }},
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: spegnimento alba
trigger:
- platform: sun
event: sunrise
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'off'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'on'
- condition: state
entity_id: input_boolean.accendi_alba_tamonto
state: 'on'
action:
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: accensione alba settimanale
trigger:
- platform: sun
event: sunrise
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'on'
- condition: state
entity_id: input_boolean.accendi_alba_tamonto
state: 'off'
condition: or
conditions:
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Lunedì' and is_state('input_boolean.lunedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Martedì' and is_state('input_boolean.martedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Mercoledì' and is_state('input_boolean.mercoledi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Giovedì' and is_state('input_boolean.giovedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Venerdì' and is_state('input_boolean.venerdi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Sabato' and is_state('input_boolean.sabato_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Domenica' and is_state('input_boolean.domenica_1' , 'on') }}"
action:
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: spegnimento tramonto settimanale
trigger:
- platform: sun
event: sunset
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'on'
- condition: state
entity_id: input_boolean.accendi_alba_tamonto
state: 'off'
condition: or
conditions:
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Lunedì' and is_state('input_boolean.lunedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Martedì' and is_state('input_boolean.martedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Mercoledì' and is_state('input_boolean.mercoledi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Giovedì' and is_state('input_boolean.giovedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Venerdì' and is_state('input_boolean.venerdi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Sabato' and is_state('input_boolean.sabato_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Domenica' and is_state('input_boolean.domenica_1' , 'on') }}"
action:
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: accensione tramonto settimanale
trigger:
- platform: sun
event: sunset
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'on'
- condition: state
entity_id: input_boolean.accendi_alba_tamonto
state: 'on'
condition: or
conditions:
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Lunedì' and is_state('input_boolean.lunedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Martedì' and is_state('input_boolean.martedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Mercoledì' and is_state('input_boolean.mercoledi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Giovedì' and is_state('input_boolean.giovedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Venerdì' and is_state('input_boolean.venerdi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Sabato' and is_state('input_boolean.sabato_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Domenica' and is_state('input_boolean.domenica_1' , 'on') }}"
action:
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_on
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

- alias: spegnimento alba settimanale
trigger:
- platform: sun
event: sunrise
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.programmazione_settimanale_1
state: 'on'
- condition: state
entity_id: input_boolean.programmazione_alba_tramonto_1
state: 'on'
- condition: state
entity_id: input_boolean.accendi_alba_tamonto
state: 'on'
condition: or
conditions:
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Lunedì' and is_state('input_boolean.lunedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Martedì' and is_state('input_boolean.martedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Mercoledì' and is_state('input_boolean.mercoledi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Giovedì' and is_state('input_boolean.giovedi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Venerdì' and is_state('input_boolean.venerdi_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Sabato' and is_state('input_boolean.sabato_1' , 'on') }}"
- condition: template
value_template: "{{ states('sensor.giorno_della_settimana_1') == 'Domenica' and is_state('input_boolean.domenica_1' , 'on') }}"
action:
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_uno_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_due_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_tre_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}
- service: homeassistant.turn_off
data_template:
entity_id: >-
{%- for device in states -%}
{%- if device.name|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- elif device.entity_id|lower == states.input_text.luce_quattro_1.state|lower -%}
{{ device.entity_id }}
{%- endif -%}
{%- endfor -%}

Andando a sostituire 1 con 2 utilizzando l’editor a voi più congeniale potete duplicare il package, ovviamente dovrete duplicare e rinominare il file.

Lovelace

cards:
- entities:
- entity: input_boolean.prima_programmazione_1
show_header_toggle: false
type: entities
- card:
entities:
- entity: input_datetime.accensione_uno_1
- entity: input_datetime.spegimento_uno_1
type: entities
conditions:
- entity: input_boolean.prima_programmazione_1
state: 'on'
type: conditional
- entities:
- entity: input_boolean.seconda_programmazione_1
show_header_toggle: false
type: entities
- card:
entities:
- entity: input_datetime.accensione_due_1
- entity: input_datetime.spegimento_due_1
type: entities
conditions:
- entity: input_boolean.seconda_programmazione_1
state: 'on'
type: conditional
- entities:
- entity: input_boolean.programmazione_settimanale_1
- entity: input_boolean.programmazione_alba_tramonto_1
- entity: input_boolean.accendi_alba_tramonto
show_header_toggle: false
type: entities
- card:
columns: 2
entities:
- entity: input_boolean.lunedi_1
tap_action:
action: toggle
- entity: input_boolean.martedi_1
tap_action:
action: toggle
- entity: input_boolean.mercoledi_1
tap_action:
action: toggle
- entity: input_boolean.giovedi_1
tap_action:
action: toggle
- entity: input_boolean.venerdi_1
tap_action:
action: toggle
- entity: input_boolean.sabato_1
tap_action:
action: toggle
- entity: input_boolean.domenica_1
tap_action:
action: toggle
type: glance
conditions:
- entity: input_boolean.programmazione_settimanale_1
state: 'on'
type: conditional
- entities:
- entity: input_text.luce_uno_1
- entity: input_text.luce_due_1
- entity: input_text.luce_tre_1
- entity: input_text.luce_quattro_1
show_header_toggle: false
type: entities
type: vertical-stack
Doppia fascia oraria
Programmazione settimanale
alba/tramonto e entità da controllare

In pratica selezionando Programmazione settimanale si abiliterà o disabiliterà la programmazione settimanale con trigger gli orari impostati sotto prima e seconda programmazione,
selezionando Programmazione alba/tramonto si abilita la programmazione settimanale con trigger alba/tramonto,
se si abilita alba/tramonto le entità verranno azionate giornalmente con trigger alba/tramonto,
premendo sui cari giorni della settimana si abiliterà o disabiliterà l’azionamento su quel gorno,
in luce 1 a 4 si potranno inserire o i friendly_name o le entity_id da azionare.

 

5 risposte

  1. Avatar romans3 ha detto:

    Ottimo lavoro e super completo ? complimenti Mauro ?

  2. Avatar matteo ha detto:

    è possibile inserire una data di inizio ed una di fine per l’attivazione del package?

  3. Avatar matteo ha detto:

    che differenza c’è fra programmazione alba/tramonto e alba tramonto

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *