Comecei a utilizar node-red à um mês, desde aí que senti liberdade total para reformular todo o sistema que tinha em yaml para node-red, o sistema em yaml estava muito desenvolvido mas não acabado.
Funcionalidades:
- Ordena automaticamente os tempos dos ciclos (input_select)
- Até 3 ciclos por dia (pode ser alterado para os quantos quiserem)
- Possibilidade de definir tempos diferentes por sector
- Possibilidade de iniciar a rega manualmente
- Monitorização dos tempos de rega ao final do dia, por válvula
- Registo da última vez que foi regada
- Aviso de notificações de: Se os tempos dos ciclos estiverem mal colocados e/ou a rega acabou
- Entre cada mudança de sector o sistema faz uma pausa para deixar as válvulas fecharam completamente.
Códigos:
lovelace:
- badges: []
icon: 'mdi:water-pump'
title: Rega
cards:
- cards:
- cards:
- entity: sensor.irrigation_zone1_status
name: Sector 1
size: 30%
type: 'custom:button-card'
- entity: sensor.irrigation_zone2_status
name: Sector 2
size: 30%
type: 'custom:button-card'
- entity: sensor.irrigation_zone3_status
name: Sector 3
size: 30%
type: 'custom:button-card'
- entity: sensor.irrigation_zone4_status
name: Sector 4
size: 30%
type: 'custom:button-card'
type: horizontal-stack
- entities:
- entity: input_boolean.irrigation_enable
- entity: input_select.irrigation_cycle1_schedule_time
- entity: input_select.irrigation_cycle2_schedule_time
- entity: input_select.irrigation_cycle3_schedule_time
- head:
label: Configurações
type: section
items:
- input_boolean.irrigation_manual_run
- label: Tempos de Rega (min)
type: section
- input_number.irrigation_zone1_duration
- input_number.irrigation_zone2_duration
- input_number.irrigation_zone3_duration
- input_number.irrigation_zone4_duration
type: 'custom:fold-entity-row'
show_header_toggle: false
title: Rega
type: entities
type: 'custom:vertical-stack-in-card'
- entities:
- entity: binary_sensor.irrigation_running
- entity: sensor.irrigation_status
- entity: timer.irrigation_cycle_zone_duration
- entity: sensor.irrigation_next_run_time
- entity: sensor.irrigation_last_time_irrigated
- entity: sensor.irrigation_zone1_time_today
- entity: sensor.irrigation_zone2_time_today
- entity: sensor.irrigation_zone3_time_today
- entity: sensor.irrigation_zone4_time_today
show_header_toggle: false
title: Informação da Rega
type: entities
- entities:
- entity: sensor.irrigation_zone1_status
- entity: sensor.irrigation_zone2_status
- entity: sensor.irrigation_zone3_status
- entity: sensor.irrigation_zone4_status
show_header_toggle: false
title: Estado das válvulas
type: entities
yaml
#===========
#=== Groups
#===========
group:
irrigation_valves:
control: hidden
name: 'Válvulas'
entities:
- switch.irrigation_zone1_valve
- switch.irrigation_zone2_valve
- switch.irrigation_zone3_valve
- switch.irrigation_zone4_valve
#================
#=== Input_Texts
#================
input_text:
irrigation_status:
name: 'Estado atual da Rega'
#==================
#=== Input_Selects
#==================
input_select:
irrigation_cycle1_schedule_time:
name: "Horas de começo do ciclo 1"
options:
- 'Desativado'
- '00:00'
- '00:30'
- '01:00'
- '01:30'
- '02:00'
- '02:30'
- '03:00'
- '03:30'
- '04:00'
- '04:30'
- '05:00'
- '05:30'
- '06:00'
- '06:30'
- '07:00'
- '07:30'
- '08:00'
- '08:30'
- '09:00'
- '09:30'
- '10:00'
- '10:30'
- '11:00'
- '11:30'
- '12:00'
- '12:30'
- '13:00'
- '13:30'
- '14:00'
- '14:30'
- '15:00'
- '15:30'
- '16:00'
- '16:30'
- '17:00'
- '17:30'
- '18:00'
- '18:30'
- '19:00'
- '19:30'
- '20:00'
- '20:30'
- '21:00'
- '21:30'
- '22:00'
- '22:30'
- '23:00'
- '23:30'
icon: mdi:alarm
irrigation_cycle2_schedule_time:
name: "Horas de começo do ciclo 2"
options:
- 'Desativado'
- '00:00'
- '00:30'
- '01:00'
- '01:30'
- '02:00'
- '02:30'
- '03:00'
- '03:30'
- '04:00'
- '04:30'
- '05:00'
- '05:30'
- '06:00'
- '06:30'
- '07:00'
- '07:30'
- '08:00'
- '08:30'
- '09:00'
- '09:30'
- '10:00'
- '10:30'
- '11:00'
- '11:30'
- '12:00'
- '12:30'
- '13:00'
- '13:30'
- '14:00'
- '14:30'
- '15:00'
- '15:30'
- '16:00'
- '16:30'
- '17:00'
- '17:30'
- '18:00'
- '18:30'
- '19:00'
- '19:30'
- '20:00'
- '20:30'
- '21:00'
- '21:30'
- '22:00'
- '22:30'
- '23:00'
- '23:30'
icon: mdi:alarm
irrigation_cycle3_schedule_time:
name: "Horas de começo do ciclo 3"
options:
- 'Desativado'
- '00:00'
- '00:30'
- '01:00'
- '01:30'
- '02:00'
- '02:30'
- '03:00'
- '03:30'
- '04:00'
- '04:30'
- '05:00'
- '05:30'
- '06:00'
- '06:30'
- '07:00'
- '07:30'
- '08:00'
- '08:30'
- '09:00'
- '09:30'
- '10:00'
- '10:30'
- '11:00'
- '11:30'
- '12:00'
- '12:30'
- '13:00'
- '13:30'
- '14:00'
- '14:30'
- '15:00'
- '15:30'
- '16:00'
- '16:30'
- '17:00'
- '17:30'
- '18:00'
- '18:30'
- '19:00'
- '19:30'
- '20:00'
- '20:30'
- '21:00'
- '21:30'
- '22:00'
- '22:30'
- '23:00'
- '23:30'
icon: mdi:alarm
#==================
#=== Input_Numbers
#==================
input_number:
# CYCLE
irrigation_zone1_duration:
name: "Sector 1"
min: 0
max: 10
step: 1
icon: mdi:timer
irrigation_zone2_duration:
name: "Sector 2"
min: 0
max: 10
step: 1
icon: mdi:timer
irrigation_zone3_duration:
name: "Sector 3"
min: 0
max: 10
step: 1
icon: mdi:timer
irrigation_zone4_duration:
name: "Sector 4"
min: 0
max: 10
step: 1
icon: mdi:timer
#===================
#=== Input_Booleans
#===================
input_boolean:
irrigation_enable:
name: "Ativar Rega"
icon: mdi:water-pump
irrigation_cancel:
irrigation_manual_run:
name: "Ativar ciclo manualmente"
icon: mdi:arrow-right-drop-circle
irrigation_running:
name: "Rega em curso"
#====================
#=== Input_Datetimes
#====================
input_datetime:
irrigation_next_run_time:
has_date: true
has_time: true
irrigation_last_time_irrigated:
has_date: true
has_time: true
#===========
#=== timers
#===========
timer:
irrigation_cycle_zone_duration:
name: "Tempo restante"
#============
#=== Sensors
#============
sensor:
- platform: template
sensors:
irrigation_next_run_time:
friendly_name: "Próxima rega agendada"
value_template: >
{% if is_state('input_boolean.irrigation_enable', 'on') and
(states('input_select.irrigation_cycle1_schedule_time') != 'Desativado' or
states('input_select.irrigation_cycle2_schedule_time') != 'Desativado' or
states('input_select.irrigation_cycle3_schedule_time') != 'Desativado') %}
{{ states.input_datetime.irrigation_next_run_time.attributes.timestamp | timestamp_custom("%a %d %h às %H:%M") }}
{% else %}
Nenhuma
{% endif %}
icon_template: mdi:clock-start
irrigation_status:
friendly_name: "Estado atual da Rega"
value_template: >
{% if states.input_text.irrigation_status.state == 'unkown' %}
Desligado
{% else %}
{{ states.input_text.irrigation_status.state }}
{% endif %}
irrigation_zone1_status:
friendly_name: "Válvula Sector 1"
value_template: >
{% if is_state('switch.irrigation_zone1_valve', 'on') %}
Aberta
{% else %}
Fechada
{% endif %}
icon_template: >
{% if is_state('switch.irrigation_zone1_valve', 'on') %}
mdi:pipe
{% else %}
mdi:pipe-disconnected
{% endif %}
irrigation_zone2_status:
friendly_name: "Válvula Sector 2"
value_template: >
{% if is_state('switch.irrigation_zone2_valve', 'on') %}
Aberta
{% else %}
Fechada
{% endif %}
icon_template: >
{% if is_state('switch.irrigation_zone2_valve', 'on') %}
mdi:pipe
{% else %}
mdi:pipe-disconnected
{% endif %}
irrigation_zone3_status:
friendly_name: "Válvula Sector 3"
value_template: >
{% if is_state('switch.irrigation_zone3_valve', 'on') %}
Aberta
{% else %}
Fechada
{% endif %}
icon_template: >
{% if is_state('switch.irrigation_zone3_valve', 'on') %}
mdi:pipe
{% else %}
mdi:pipe-disconnected
{% endif %}
irrigation_zone4_status:
friendly_name: "Válvula Sector 4"
value_template: >
{% if is_state('switch.irrigation_zone4_valve', 'on') %}
Aberta
{% else %}
Fechada
{% endif %}
icon_template: >
{% if is_state('switch.irrigation_zone4_valve', 'on') %}
mdi:pipe
{% else %}
mdi:pipe-disconnected
{% endif %}
irrigation_last_time_irrigated:
friendly_name: "Último ciclo de rega acabado"
value_template: >
{{ (as_timestamp(states.input_datetime.irrigation_last_time_irrigated.state)) | timestamp_custom("%a %d %h às %H:%M") }}
icon_template: mdi:update
# Zone Times - templated on history_stats sensors
irrigation_zone1_time_today:
friendly_name: "Sector 1 tempo total de rega hoje"
value_template: >
{% set duration = states('sensor.zone1_time') %}
{{ (float(duration) * 60) | round }}
unit_of_measurement: minutes
icon_template: mdi:water
irrigation_zone2_time_today:
friendly_name: "Sector 2 tempo total de rega hoje"
value_template: >
{% set duration = states('sensor.zone2_time') %}
{{ (float(duration) * 60) | round }}
unit_of_measurement: minutes
icon_template: mdi:water
irrigation_zone3_time_today:
friendly_name: "Sector 3 tempo total de rega hoje"
value_template: >
{% set duration = states('sensor.zone3_time') %}
{{ (float(duration) * 60) | round }}
unit_of_measurement: minutes
icon_template: mdi:water
irrigation_zone4_time_today:
friendly_name: "Sector 4 tempo total de rega hoje"
value_template: >
{% set duration = states('sensor.zone4_time') %}
{{ (float(duration) * 60) | round }}
unit_of_measurement: minutes
icon_template: mdi:water
# History sensors
# Zone Times
- platform: history_stats
name: "zone1_time"
entity_id: switch.irrigation_zone1_valve
state: 'on'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
- platform: history_stats
name: "zone2_time"
entity_id: switch.irrigation_zone2_valve
state: 'on'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
- platform: history_stats
name: "zone3_time"
entity_id: switch.irrigation_zone3_valve
state: 'on'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
- platform: history_stats
name: "zone4_time"
entity_id: switch.irrigation_zone4_valve
state: 'on'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
binary_sensor:
- platform: template
sensors:
irrigation_running:
friendly_name: "Rega"
device_class: power
value_template: >
{% if is_state('input_boolean.irrigation_running', 'on') %}
True
{% else %}
False
{% endif %}
icon_template: >
{% if is_state('input_boolean.irrigation_running', 'on') %}
mdi:run
{% else %}
mdi:human-handsdown
{% endif %}
#=============
#=== Switches
#=============
switch:
# Tasmota Commands
# interlock 1
# poweronstate<x> 0
# pulsetime<x> 700
# Zone 1
- platform: mqtt
name: "irrigation_zone1_valve"
command_topic: "rega_frente/cmnd/POWER1"
payload_on: "ON"
payload_off: "OFF"
availability_topic: "rega_frente/tele/LWT"
payload_available: "Online"
payload_not_available: "Offline"
state_topic: "rega_frente/stat/POWER1"
# Zone 2
- platform: mqtt
name: "irrigation_zone2_valve"
command_topic: "rega_frente/cmnd/POWER2"
payload_on: "ON"
payload_off: "OFF"
availability_topic: "rega_frente/tele/LWT"
payload_available: "Online"
payload_not_available: "Offline"
state_topic: "rega_frente/stat/POWER2"
# Zone 3
- platform: mqtt
name: "irrigation_zone3_valve"
command_topic: "rega_frente/cmnd/POWER3"
payload_on: "ON"
payload_off: "OFF"
availability_topic: "rega_frente/tele/LWT"
payload_available: "Online"
payload_not_available: "Offline"
state_topic: "rega_frente/stat/POWER3"
# Zone 4
- platform: mqtt
name: "irrigation_zone4_valve"
command_topic: "rega_frente/cmnd/POWER4"
payload_on: "ON"
payload_off: "OFF"
availability_topic: "rega_frente/tele/LWT"
payload_available: "Online"
payload_not_available: "Offline"
state_topic: "rega_frente/stat/POWER4"