Hello fellow Home Assistant enthusiasts!
I’ve been enjoying the flexibility and power of Home Assistant, but there’s one issue that’s been bugging me a bit. I wanted to share my experience and see if anyone else has encountered this or has some advice to offer.
I recently noticed that Home Assistant tends to reformat my automation configurations in a way that makes them less readable. For example, I carefully formatted my automation for the WC light sensor to be clean and organized, but after some time, it changes the indentation and structure, making it harder to find specific values like brightness percentages when I need to tweak them.
Here’s an example of how it starts:
yaml
- id: ‘2’
alias: WC light
TimeBased trigger:
platform: state
entity_id: binary_sensor.shenzhen_neo_electronics_co_ltd_battery_powered_pir_sensor_v2_sensor_2
to: ‘on’
action:
service: light.turn_on
data_template:
entity_id: light.wclicht
brightness_pct: >
{% if now().hour in [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21] %}
100
{% elif now().hour in [22, 23] %}
70
{% elif now().hour in [0, 1, 2, 3, 4, 5, 6, 7, 8] %}
30
{% endif %}
And then it changes to this:
yaml
- id: ‘2’
alias: WC light
TimeBased trigger:
platform: state
entity_id: binary_sensor.shenzhen_neo_electronics_co_ltd_battery_powered_pir_sensor_v2_sensor_2
to: ‘on’
action:
service: light.turn_on
data_template:
entity_id: light.wclicht
brightness_pct: >
{% if now().hour in [9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21] %}
75
{% elif now().hour in [22, 23] %}
50
{% elif now().hour in [0, 1, 2, 3, 4, 5, 6, 7, 8] %}
30
{% endif %}
I understand that this might be a formatting preference on HA’s end, but it’s frustrating when I have to search through the code to find specific values. I’ve tried manually reformatting it back to my preferred style, but it just changes again after a while.
Has anyone else experienced this? Are there any settings or workarounds that can prevent HA from altering the formatting of my automations? Any advice or tips would be greatly appreciated! ![]()
Thanks in advance for your help and insights!