Bonjour,
j’ai un petit souci de compteur
j’ai suivi le post Obtenir le temps d'utilisation d'un appareil électrique sur une période donnée de Syl20 pour quantifier l’utilisation de la Télé par mes ados « qui la regardent jamais »
templates.yaml
######### For Cumul TV on ######################################################
- sensor:
      - name: temps_tv_today
        device_class: duration
        state: "{% set hours = states('sensor.temps_allumage_tv_today') | float %} 
        {% set minutes = ((hours % 1) * 60) | int %}
        {{ '%02ih %02im'%(hours // 1, minutes) }}"
        #friendly_name: temps_tv_today
        unique_id: "ui_temps_tv_today"
      - name: temps_tv_hier
        device_class: duration
        state: "{% set hours = states('sensor.temps_allumage_tv_hier') | float %} 
        {% set minutes = ((hours % 1) * 60) | int %}
        {{ '%02ih %02im'%(hours // 1, minutes) }}"
        #friendly_name: temps_tv_hier
        unique_id: "ui_temps_tv_hier"
      - name: temps_tv_semaine
        device_class: duration
        state: "{% set hours = states('sensor.temps_allumage_tv_semaine') | float %} 
        {% set minutes = ((hours % 1) * 60) | int %}
        {{ '%02ih %02im'%(hours // 1, minutes) }}"
        #friendly_name: temps_tv_semaine
        unique_id: "ui_temps_tv_semaine"
      - name: temps_tv_mois
        device_class: duration
        state: "{% set hours = states('sensor.temps_allumage_tv_mois') | float %} 
        {% set minutes = ((hours % 1) * 60) | int %}
        {{ '%02ih %02im'%(hours // 1, minutes) }}"
        #friendly_name: temps_tv_mois
        unique_id: "ui_temps_tv_mois"
######### END Cumul TV on ######################################################
sensors.yaml
# For Cumul TV on ------------------------------
- platform: history_stats
  name: temps_allumage_tv_today
  entity_id: media_player.tv_tv_salon
  state: "idle"
  type: time
  start: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
  end: "{{ now() }}"
- platform: history_stats
  name: temps_allumage_tv_hier
  entity_id: media_player.tv_tv_salon
  state: "idle"
  type: time
  end: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
  duration:
    hours: 24
- platform: history_stats
  name: temps_allumage_tv_semaine
  entity_id: media_player.tv_tv_salon
  state: "idle"
  type: time
  start: "{{ as_timestamp( now().replace(hour=0, minute=0, second=0, microsecond=0) ) - now().weekday() * 86400 }}"
  end: "{{ now() }}"
- platform: history_stats
  name: temps_allumage_tv_mois
  entity_id: media_player.tv_tv_salon
  state: "idle"
  type: time
  start: "{{ now().replace(day=1, hour=0, minute=0, second=0, microsecond=0 ) }}"
  end: "{{ now() }}"
# END Cumul TV on ------------------------------
et quand je reboote:
tout est à zéro…
qu’est ce qui va pas ???





