# Configure a default setup of Home Assistant (frontend, api, etc) default_config: # Text to speech tts: - platform: google_translate group: !include groups.yaml automation: !include automations.yaml script: !include scripts.yaml scene: !include scenes.yaml recorder: purge_keep_days: 30 commit_interval: 3 db_url: "postgresql://home-assistant:M1ykv2TSzPD4c7lq4ixyBIl/q9kf4NyVIziQ3Yzansst4kZx@home-assistant_postgresql:5432/home-assistant?client_encoding=utf8" http: use_x_forwarded_for: true trusted_proxies: - 10.255.224.0/20 homeassistant: customize_domain: automation: templates: &state_color # <-- define a yaml anchor here icon_color: > if (state === 'on') return 'green'; return 'steelblue'; # or use a theme variable: # templates: &state_color # icon_color: > # if (state === 'on') return 'var(--primary-color)'; # return 'green'; #'steelblue'; sensor: templates: <<: *state_color # <-- and use it on any other entity in this file binary_sensor: templates: icon_color: > if (state === 'on') return 'firebrick'; return 'steelblue'; # <<: *state_color # <-- and use it on any other entity in this file input_boolean: templates: *state_color # <-- or even shorter like this switch: templates: icon: > if (state === 'on') return 'mdi:toggle-switch'; return 'mdi:toggle-switch-off'; <<: *state_color template: - binary_sensor: - name: Sun state: > {{ is_state("sun.sun", "above_horizon") }} icon: > {% if is_state("binary_sensor.sun_up", "on") %} mdi:weather-sunset-up {% else %} mdi:weather-sunset-down {% endif %} - unique_id: alarm_triggered_gui name: Alarm triggered state: > {{ 'on' if states('sensor.sthome_ut1_alarm_signal')|float > 1.5 else 'off' }} icon: > {%- if this.state == 'on' -%} mdi:alarm-light {%- elif this.state == 'off' -%} mdi:alarm-light-outline {%- else -%} mdi:alarm-light-off-outline {%- endif -%} - unique_id: zone_4_triggered_gui name: Zone 4 triggered state: "{{ states('switch.sthome_ut1_alarm_zone_4') }}" icon: > {%- if this.state == 'on' -%} mdi:alarm-light {%- elif this.state == 'off' -%} mdi:alarm-light-off {%- else -%} mdi:alarm-light-off-outline {%- endif -%} - unique_id: gate_lock_gui name: Gate Lock state: "{{ states('switch.sthome_ut4_relay_5') }}" icon: > {%- if this.state == 'on' -%} mdi:lock-open {%- elif this.state == 'off' -%} mdi:lock {%- else -%} mdi:lock-off {%- endif -%} #notify: # - platform: androidtv # name: Android TV # host: 10.0.0.71 # - sensor: