Note de ce sujet :
  • Moyenne : 0 (0 vote(s))
  • 1
  • 2
  • 3
  • 4
  • 5
Comment changer d'icone en fonction de l'état
#1
J'ai essayé toutes les aides que j'ai trouvées simples mais refus de configuration:

Changer d'icone en fonction de l'état

Changer en fonction d'un capteur

J'ai pour la porte dans le fichier homeassistant/knxfiles/binary_sensor.yaml tous mes binary_sensors knx.

Code :
knx:  

###########################
# BINARY_SENSOR
###########################

..........
     
 # GARAGE
 # Etat Porte Garage
   - name: "Porte Garage"
     state_address: "3/1/21"

etc....

et donc voir image jointe.


Si je veux implémenter ceci:

Code :
templates:
    icon: if (entities['binary_sensor.porte_garage'].state === 'off') return 'mdi:garage';
      if (entities['binary_sensor.porte_garage'].state === 'on') return 'mdi:garage-open';
      return 'mdi:home';

Où dois-je placer ce code qui me semble très simple?
Dans le configuration.yaml où ?

Voici mon fichier:

Code :
homeassistant:

# KNX IP Interface ABB IP Router IPR/S
 packages: !include_dir_named knxfiles
 
# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
 themes: !include_dir_merge_named themes

automation: !include automations.yaml
#script: !include scripts.yaml
#scene: !include scenes.yaml
#template: !include templates.yaml

# Special variables
input_select:
 choucroute:
   name: Choucroute
   options:
     - false
     - true
   initial: false
 noel:
   name: Noël
   options:
     - false
     - true
   initial: false    
   
# History_stats
sensor:
 - platform: history_stats
   name: PAC_on_today
   unique_id: pac_on_today
   entity_id: binary_sensor.pac_tourne
   state: "on"
   type: count
   start: "{{ now().replace(hour=0, minute=0, second=0) }}"
   end: "{{ now() }}"  
 - platform: history_stats  
   name: PAC time today
   unique_id: pac_time_today
   entity_id: binary_sensor.pac_tourne
   state: "on"
   type: time
   start: "{{ now().replace(hour=0, minute=0, second=0) }}"
   end: "{{ now() }}"
 - platform: history_stats  
   name: PAC time month
   unique_id: pac_time_month
   entity_id: binary_sensor.pac_tourne
   state: "on"
   type: time  
   start: "{{ now().replace(day=1, hour=0, minute=0, second=0, microsecond=0 ) }}"    
   end: "{{ now() }}"

# Min/Max    
 - platform: statistics
   name: "Moyenne SAM"
   unique_id: moyenne_sam
   entity_id: sensor.sam
   state_characteristic: mean
   max_age:
     hours: 24


#EOF


Merci pour votre aide.


Pièces jointes Miniature(s)
   
KNX aficionado

Répondre


Messages dans ce sujet
Comment changer d'icone en fonction de l'état - par NicNac - 28/08/2024, 15:57:29

Atteindre :


Utilisateur(s) parcourant ce sujet : 2 visiteur(s)