Forum Francophone Home Assistant

Partage de fichier sensor.yaml

voici mon fichier sensor.yaml

#############################
######### dates #############
#############################
- platform: time_date
  display_options:
  - 'time'
  - 'date'
  - 'date_time'
  - 'date_time_utc'
  - 'date_time_iso'
  - 'time_date'
  - 'time_utc'
  - 'beat'  
  
- platform: template
  sensors:
    template_jm:
      friendly_name: jours dans le mois
      value_template: >-
         {% if now().month in [1,3,5,7,8,10,12] %}
            31
         {% elif now().month in [4,6,9,11] %}
            30
         {% elif now().month == 2 and ((now().year-2000) % 4 > 0) %}
            28
         {% elif now().month == 2 and ((now().year-2000) % 4 == 0) %}
            29
         {% endif %}
         
- platform: template
  sensors:
    jm:
      friendly_name: jours du mois
      value_template: >-
         {{ now().day }}        

#############################
#### vacances et férié ######
#############################
- platform: template
  sensors:
    template_fd:
      friendly_name: ferié demain
      value_template: >-  
       {% set demain = (as_timestamp(now()) + (48*3600)) | timestamp_custom('%Y-%m-%d', True) %}
      {% if demain <  states.calendar.jours_feries_en_france.attributes.start_time or demain > states.calendar.jours_feries_en_france.attributes.end_time %} 
      non
      {% else %} 
      toui
      {% endif %}   

- platform: template
  sensors:
    template_vd:
      friendly_name: vacances demain
      value_template: >-  
           {% set demain = (as_timestamp(now()) + (48*3600)) | timestamp_custom('%Y-%m-%d', True) %}
      {% if demain <  states.calendar.calendrier_scolaire_zone_b.attributes.start_time or demain > states.calendar.calendrier_scolaire_zone_b.attributes.end_time %} 
      non
      {% else %} 
      toui
      {% endif %}
        
- platform: template
  sensors:
    template_fca:
      friendly_name: ferier ou congé aujourd'hui
      value_template: >-
        {{ (states('calendar.jours_feries_en_france') == 'on') or (states('calendar.calendrier_scolaire_zone_b') == 'on') }}

- platform: template
  sensors:
    template_fcd:
      friendly_name: ferier ou congé demain
      value_template: >-
        {{ (states('sensor.template_fd') == 'oui') or (states('sensor.template_vd') == 'oui') }}
        
#############################
########     RPI    #########
#############################
# System Monitor raspberry Pi
- platform: systemmonitor
  resources:
    - type: disk_free
      arg: /
    - type: disk_use_percent
      arg: /
    - type: memory_free
    - type: memory_use_percent
    - type: swap_use_percent
    - type: processor_use
    - type: last_boot

# Temperature CPU  
- platform: command_line
  name: "RPi CPU Temperature"
  command: "cat /sys/class/thermal/thermal_zone0/temp"
  value_template: '{{ value | multiply(0.001) | round(2) }}' 
  unit_of_measurement: c°
  
#############################
########   soleil  ##########
############################# 
- platform: template
  sensors:
      nextsunrise:
       # entity_id: sun.sun
        friendly_name: 'Next Sunrise'
        value_template: >
          {{ as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom('%H %M')}}
        icon_template: mdi:weather-sunset-up

- platform: template
  sensors:
      nextsunset:
        #entity_id: sun.sun
        friendly_name: 'Next Sunset'
        value_template: >
          {{ as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom(' %H %M')}}
        icon_template: mdi:weather-sunset-down
        
#############################
########  tranches ##########
#############################
- platform: template
  sensors:
    tranche_1:
      friendly_name: tranche 1
      value_template: >-
        {{ (states('sensor.time') >= states('input_datetime.sejour_start_1')) and  (states('sensor.time') <= states('input_datetime.sejour_stop_1'))}}
      icon_template: >-
        {% if is_state('sensor.tranche_1', 'True') %}
           mdi:lightning-bolt: mdi:radiator
        {% else %}
            mdi:sleep
          {% endif %}
          
- platform: template
  sensors:
    tranche_2:
      friendly_name: tranche 2
      value_template: >-
        {{ (states('sensor.time') >= states('input_datetime.sejour_start_2')) and  (states('sensor.time') <= states('input_datetime.sejour_stop_2'))}}
      icon_template: >-
        {% if is_state('sensor.tranche_2', 'True') %}
           mdi:lightning-bolt: mdi:radiator
        {% else %}
            mdi:sleep
          {% endif %}
          
- platform: template
  sensors:
    tranche_3:
      friendly_name: tranche 3
      value_template: >-
        {{ (states('sensor.time') >= states('input_datetime.sejour_start_3')) and  (states('sensor.time') <= states('input_datetime.sejour_stop_3'))}}
      icon_template: >-
        {% if is_state('sensor.tranche_3', 'True') %}
           mdi:lightning-bolt: mdi:radiator
        {% else %}
            mdi:sleep
          {% endif %}
          
#############################
########  ventil   ##########
#############################

- platform: template
  sensors:
    vitesse_ventil:
      friendly_name: ventil vitesse
      value_template: >-
       {{ states.light.ventilateur.attributes.brightness }}
       
#############################
########  cerboot  ##########
#############################
- platform: cert_expiry
  host: XXXXXXXXX.freeboxos.fr
  
- platform: template
  sensors:
    jours_avant_expiration:
      friendly_name: jours avant expiration
      value_template: >-
       {{((as_timestamp(states('sensor.cert_expiry_timestamp_XXXXXXX_freeboxos_fr')) - as_timestamp(states.sensor.date.last_updated)) / 86400) | int }}
       
#############################
########  chauffage  ########
#############################
- platform: template
  sensors:
    consigne_generale:
      friendly_name: "consigne générale"
      value_template: >-
          {% if is_state('input_select.chauffage','eco')  %} {{states('input_number.consigne_eco')}}
          {% elif is_state('input_select.chauffage', 'normal') %} {{states('input_number.consigne_normal')}}
          {% elif is_state('input_select.chauffage', 'confort') %} {{states('input_number.consigne_confort')}}
          {% else %}
            nul
          {% endif %}
          
#############################
########  conso elec ########
#############################         
- platform: template 
  sensors:
    energy_total_daily:
      friendly_name: 'Energie journalière consommée'
      value_template: "{{ (states('sensor.energy_total_usage_daily_hp')|float + states('sensor.energy_total_usage_daily_hc')|float)|round(2) }}"
      unit_of_measurement: "kWh"
      
- platform: template 
  sensors:
    energy_total_weekly:
      friendly_name: 'Energie hebdo consommée'
      value_template: "{{ (states('sensor.energy_total_usage_weekly_hp')|float + states('sensor.energy_total_usage_weekly_hc')|float)|round(2) }}"
      unit_of_measurement: "kWh"    
      
- platform: template 
  sensors:
    energy_total_montly:
      friendly_name: 'Energie mensuel consommée'
      value_template: "{{ (states('sensor.energy_total_usage_monthly_hp')|float + states('sensor.energy_total_usage_monthly_hc')|float)|round(2) }}"
      unit_of_measurement: "kWh"
      
- platform: template 
  sensors:
    energy_total_yearly:
      friendly_name: 'Energie annuel consommée'
      value_template: "{{ (states('sensor.energy_total_usage_yearly_hp')|float + states('sensor.energy_total_usage_yearly_hc')|float)|round(2) }}"
      unit_of_measurement: "kWh"
      
- platform: template 
  sensors:
    hp_hc:
      friendly_name: 'Energie mensuel € hp+hc'
      value_template: "{{ ((((states('sensor.energy_total_usage_monthly_hp')|float)*states('input_number.prix_hp')|float) + ((states('sensor.energy_total_usage_monthly_hc')|float)*states('input_number.prix_hc')|float)) + states('input_number.abo_hchp')|float )|round (3)}}"
      unit_of_measurement: "€"
      
- platform: template 
  sensors:
    base:
      friendly_name: 'Energie mensuel € base'
      value_template: "{{ ((((states('sensor.energy_total_usage_monthly_hp')|float)*states('input_number.prix_base')|float) + ((states('sensor.energy_total_usage_monthly_hc')|float)*states('input_number.prix_base')|float)) + states('input_number.abo_base')|float)|round(3)}}"
      unit_of_measurement: "€"