I’ve been using lovelace gen to generate multiple card sets for my irrigation zones
gen https://github.com/thomasloven/homeassistant-lovelace-gen
like so. Works great!!!
# lovelace_gen
title: Irrigation
cards:
- type: markdown
content: >
# 238 McHaley
{% set zones = {
'1':'Front Yard North',
'2':'Front Yard South',
'3':'Fr. Beds/Back E. Spigot',
'4':'Back Garage Spigot',
'5':'Garden North/West',
'6':'Garden South',
'7':'Back West Spigot'
}
%}
{% for zone,name in zones.items() %}
- type: vertical-stack
cards:
- type: markdown
content: >
## Schedule - Zone {{ zone }}: {{ name }}
- type: entities
entities:
- type: section
label: '{{name}}'
- entity: input_boolean.irrigation_zone_{{ zone }}_manual
- entity: input_number.irrigation_zone_{{ zone }}_duration
- type: entities
entities:
- type: custom:fold-entity-row
head: input_boolean.irrigation_zone_{{ zone }}_schedule_enable
entities:
- type: section
label: 'Base Time of Day'
- entity: input_number.irrigation_zone_{{ zone }}_schedule_base_hour
- entity: input_number.irrigation_zone_{{ zone }}_schedule_base_minute
- type: divider
- entity: input_select.irrigation_zone_{{ zone }}_schedule_delta
- type: divider
{# - entity: variable.irrigation_zone_{{ zone }}_schedule_nextTS #}
- entity: variable.irrigation_zone_{{ zone }}_schedule_next_dt
- entity: variable.irrigation_zone_{{ zone }}_schedule_countdown
{% endfor %}
{# - type: horizontal-stack
cards:
- type: entity-button
entity: input_boolean.irrigation_zone_{{ zone }}_manual
entity: switch.irrigation_zone_{{ zone }}
icon: mdi:water
name: ON/OFF (Manual Overrride)
tap_action:
action: toggle #}
but in the backend configuration I have to create all those corresponding entities. So far (using packages) I copy the yaml (in a separate file) for each zone and then search and replace the zone number. That works but it seems totally not DRY and if I make one change I have to do it to 7 files. I’d like a programmatic/template solution like lovelace gen
e.g. zone1.yaml
homeassistant:
customize:
variable.irrigation_zone_1_schedule_countdown:
friendly_name: "Countdown to Next Scheduled Run"
icon: mdi:timer-sand
variable.irrigation_zone_1_schedule_next_dt:
friendly_name: "Time of Next Scheduled Run"
input_boolean.irrigation_zone_1_schedule_enable:
friendly_name: "Schedule (enabled/disabled)"
input_boolean.irrigation_zone_1_manual:
friendly_name: "Zone State (manual override)"
variable:
irrigation_zone_1_schedule_countdown:
value: 'disabled'
attributes:
icon: mdi:clock
irrigation_zone_1_schedule_next_dt:
value: 'disabled'
input_boolean:
irrigation_zone_1_schedule_enable:
irrigation_zone_1_manual:
input_number:
irrigation_zone_1_duration:
name: "Duration in minutes"
min: 1
max: 30
step: 1
icon: mdi:timer-sand
irrigation_zone_1_schedule_base_hour:
name: "Hour of Day"
# unit_of_measurement: hours
initial: 6
min: 0
max: 24
step: 1
icon: mdi:clock
irrigation_zone_1_schedule_base_minute:
name: "Minute of Day"
# unit_of_measurement: minutes
initial: 0
min: 0
max: 45
step: 15
icon: mdi:clock
input_select:
irrigation_zone_1_schedule_delta:
name: Repeat Every
icon: mdi:repeat
# options are set from the websocket client
options:
- 12 Hours
What if any script/tool is available to feed in some configuration yaml using I assume some kind of template engine (like jinja2)? I’m just not that familiar with HA core and am not a python coder so kinda cluless. Can this be done with a python script? sure it can with jinga even?? I just gotta believe that this has come up for others and a tool like lovelace gen exists already.