You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.2 KiB
1.2 KiB
Home Assistant YAML DRY Refactor Playbook
Use these patterns after verifier findings.
Repeated Actions or Sequence
- Move common action chains into a reusable script (
script.<name>). - Use script fields/variables instead of duplicating payload variants.
- Keep each automation focused on trigger + routing, not full action implementation.
Repeated Conditions
- Promote shared logic into helper entities (
input_boolean, helper groups) or template sensors. - Replace long repeated
andchains with a single meaningful condition entity when practical. - Keep per-automation overrides small and explicit.
Repeated Triggers
- Merge equivalent triggers into one automation when the resulting behavior stays clear.
- If actions diverge, keep separate automations but centralize shared actions in scripts.
- Avoid copy-paste time/state triggers that only differ by one minor field; parameterize if possible.
Intra-Block Duplicates
- Remove exact duplicate entries inside the same trigger/condition/action list.
- Keep only one canonical copy of each entry.
Validation Loop
- Run verifier.
- Refactor.
- Run verifier again.
- Run Home Assistant config check before reload/restart.