2025/11/19

HA 몇가지 짧막한 팁2


shell_command로 설정파일 일부만 백업:
/config 디렉토리에서 tts, image, www, custom_components 폴더등을 제외한 주로 설정 파일들만을 /share/hassbackup폴더에 core_time.tar.gz으로 저장.
용량은 1M 정도인데 1주에 한번 백업하며 hassbackup은 나스에서 마운드된 폴더.

configuration.yaml
automations: !include automations.yaml
shell_command: !include shell_command.yaml

shell_command.yaml
backup_core: tar --exclude='tts' --exclude='image' --exclude='www' --exclude='custom_components' -czf /share/hassbackup/core_{{ now().strftime('%y%m%d') }}.tar.gz -C /config .

automations.yaml
- id: system-backup_core
  alias: system-backup_core
  mode: single
  triggers:
    - trigger: time
      weekday: 'mon'
      at: '04:30:00'
  actions:
    - action: shell_command.backup_core



** Music Assistant의 하단 메뉴아이템 추가 또는 제거:
하단 메뉴의 설정아이콘/우상단 User interface 아이콘/Enabled menu items에서 필요한 아이템 선택 또는 해제



** 섹션뷰에서 좌우여백 조절:
테마에 위아래 여백과 좌우여백 추가후 다시읽어오기
  ha-view-sections-column-gap: 10px
  ha-view-sections-row-gap: 10px 



** Picture element card에서 마우스클릭 액션효과 제거:
사용하고 있는 테마의 divider-color: 항목에 rgba를 사용해 투명도를 0으로.
예: divider-color: 'rgba(200, 200, 200, 0)'

divider-color를 흐린 회색으로 설정하면 weather card의 요일구분이나 playlist의 대기열사이에 흐린 회색선이 나타남.



** conditions이나 choose아래에 들어가는 템플릿이나 상태등의 조건을 나열할 때
  conditions:
    - condition: state
      entity_id: sun.sun
      state: below_horizon
    - condition: numeric_state
      entity_id: sensor.boiler_1_temperature
      below: 24.00
    - condition: numeric_state
      entity_id: sensor.boiler_pvvx_temperature
      below: 24.00
    - condition: template
      value_template: "{{ now().month in [11, 12, 1, 2, 3] }}"

위 표현식을 아래처럼 정리하는게 전체 가독성을 높이고 코드를 줄임
  conditions:
    - "{{ is_state('sun.sun', 'below_horizon') }}"
    - "{{ states('sensor.boiler_1_temperature') | float < 24 }}"
    - "{{ states('sensor.boiler_pvvx_temperature') | float < 24 }}"
    - "{{ now().month in [10, 11, 12, 1, 2, 3] }}"



** 좌측패널 네비게이션 경로
tap_action:
  action: navigate
  navigation_path: /logbook 

이런형식으로 버튼카드나 그림요소카드에 쓰는데 url창 또는 링크주소복사를 해서 url을 들어다보면 서버주소 옆에 경로가 있는데 그게 네비게이션 경로임.
/config : 설정
/config/logs : HA로그
/developer-tools : 개발자 도구
/energy : 에너지
/logbook : 로그북
/xxxxxxxx_esphome : esphome패널

새창으로 url접근하려면
tap_action:
  action: url
  url_path: /config