PLease… let me post what I’ve already done. It’s on the way… but I need to learn more to see if it will work as I want…
Sorry, but interface and names are in Portuguese…
Here are my card config:
type: vertical-stack
title: Ráfis
cards:
- type: horizontal-stack
cards:
- type: button
aspect_ratio: 2/1
color: auto-no-temperature
icon: 'mdi:watering-can'
size: 22%
state:
- color: 'rgb(255, 255, 255)'
icon: 'mdi:water'
value: 'on'
- color: 'rgba(25, 25, 25, 0.3)'
styles:
icon:
- color: 'rgba(255, 255, 255, 0.3)'
name:
- color: 'rgba(255, 255, 255, 0.3)'
value: unavailable
confirmation:
text: Deseja Iniciar a Rega agora ?
tap_action:
action: toggle
hold_action:
action: none
show_icon: true
show_name: false
entity: light.sonoff_1000e1dcb5
name: Status
icon_height: 40px
- type: button
aspect_ratio: 2/1
color: auto-no-temperature
icon: 'mdi:brightness-auto'
confirmation:
text: Deseja Ativar Rega Automática ?
tap_action:
action: toggle
hold_action:
action: none
show_icon: true
show_name: true
entity: automation.irrigacao_rafis
name: Automação
icon_height: 40px
- type: entities
entities:
- entity: input_datetime.ultima_rega_rafis
name: Última rega
show_state: false
tap_action:
action: none
- type: horizontal-stack
title: Programação da Rega
cards:
- type: button
tap_action:
action: toggle
hold_action:
action: none
show_icon: true
show_name: true
entity: input_boolean.rafis_nascer_do_sol
name: Amanhecer
icon_height: 40px
- type: button
tap_action:
action: toggle
hold_action:
action: none
show_icon: true
show_name: true
entity: input_boolean.rafis_por_do_sol
name: Pôr do Sol
icon_height: 40px
- type: entities
entities:
- entity: input_number.intervalo_irriga_rafis
- type: conditional
conditions:
- entity: input_boolean.rafis_nascer_do_sol
state: 'off'
tap_action:
action: input_boolean.rafis_por_do_sol.toggle
- entity: input_boolean.rafis_por_do_sol
tap_action:
action: toggle
state: 'off'
card:
type: entities
entities:
- entity: sensor.hora_irriga_rafis
name: Hora Programada
- entity: input_number.rafis_irrigacao_hora
name: Hora
- entity: input_number.rafis_irrigacao_minutos
name: Minutos
This will the following lovelace interface with the bottom part conditional:
For the sensors I have (for now):
- platform: template
sensors:
hora_irriga_rafis:
friendly_name: 'Hora Irrigacao Rafis'
value_template: "{{'{:02d}:{:02d}'.format(states('input_number.rafis_irrigacao_hora') | int, states('in
nextsunrise:
entity_id: sun.sun
friendly_name: 'Next Sunrise'
value_template: >
{{ as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom(' %I:%M %p') | replace(" 0"
icon_template: mdi:weather-sunset-up
nextsunset:
entity_id: sun.sun
friendly_name: 'Next Sunset'
value_template: >
{{ as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom(' %I:%M %p') | replace("
icon_template: mdi:weather-sunset-down
- platform: time_date
display_options:
- 'time'
Now, I need an automation to use these controls. Specially, to treat the trigger should be : if sunrise or sunset is selected, the manual time chosen will be the active one, and respecting the days interval (condition).
Since I’m pretty new to this, I don’ t know which is the better aproach. I’m thinking in putting as a trigger a template that tests all times, something like:
if sunset or sunrise is activated:
if now() is sunrise and sunrise is activated, return true
else if now() is sunset and sunset is activated, return true
else if now() is manual time return true
And on condition I put the days interval configured, like (ignore the names, need to check):
{{ ((states.sensor.time.last_changed - states.device_rafis.last_changed).total_seconds() / 3600) > states('input_number.interval_days') }}
Please… any help ?
Thanks a lot.