Carte pour thermostat Netatmo suite

Bonjour,
Ce post fait suite à mon 1er post qui a été archivé, vous trouverez ici les dernières évolutions et tout ce dont vous avez besoin pour réaliser cette carte.

Je me suis amusé à faire cette carte pour mon thermostat Netatmo et j’avais envie qu’elle ressemble à ce que l’on peut voir sur l’espace personnel du site Netatmo.
Je me suis appuyé sur l’intégration Netatmo ainsi que sur la carte « Éléments d’image » qui me semblait la plus adaptée à mon projet.
Je ne suis pas développeur et c’est pour cela que cette carte n’est surement pas la plus optimisée niveau code, mais chacun pourra apporter les modifications nécessaires afin de corriger mes erreurs.
Voici donc comment cela se présente :

L’indicateur de batterie affiche le niveau en % grâce au sensor disponible dans l’intégration netatmo, pour moi c’est : sensor.thermostat_entree_batterie

Vous pouvez mettre le nom de votre fournisseur en changeant l’image « Engie » par la votre.
Les boutons « + » et « - » servent à monter ou baisser la température de consigne par pas de 0.5°.

Afin de mettre à jour immédiatement les indicateurs de mode de fonctionnement et de température de consigne sans attendre le retour par netatmo, j’utilise le service python_script pour les nouveaux scripts. ces indicateurs seront ensuite actualisés lors du retour d’info par l’api netatmo.
Le bouton actualiser, force l’actualisation du planning, sinon vous devez attendre le retour d’info de l’api Netatmo.

Procédure d’installation du service python_script:
• Ajouter cette ligne dans le fichier configuration.yaml.
python_script:
• Créer un dossier nommé python_scripts dans le répertoire config
• Créer un fichier dans le répertoire python_scripts avec le code ci-dessous et le nommer set_state.py(ne rien changer dans ce fichier)

set_state.py
#==================================================================================================
#  python_scripts/set_state.py 
#==================================================================================================

# https://community.home-assistant.io/t/how-to-manually-set-state-value-of-sensor/43975/8
# voici un script mis à jour qui a été généralisé pour pouvoir définir n'importe quel attribut

#--------------------------------------------------------------------------------------------------
# Set the state or other attributes for the entity specified in the Automation Action
# Définir l'état ou d'autres attributs pour l'entité spécifiée dans l'action d'automatisation
#--------------------------------------------------------------------------------------------------

inputEntity = data.get('entity_id')
if inputEntity is None:
    logger.warning("===== entity_id is required if you want to set something.")
else:    
    inputStateObject = hass.states.get(inputEntity)
    inputState = inputStateObject.state
    inputAttributesObject = inputStateObject.attributes.copy()

    for item in data:
        newAttribute = data.get(item)
        logger.debug("===== item = {0}; value = {1}".format(item,newAttribute))
        if item == 'entity_id':
            continue            # already handled
        elif item == 'state':
            inputState = newAttribute
        else:
            inputAttributesObject[item] = newAttribute
        
    hass.states.set(inputEntity, inputState, inputAttributesObject)
    

    
#--------------------------------------------------------------------------------------------------    
#Avec ce script en place, l'action pourrait être :
#--------------------------------------------------------------------------------------------------


#  action:
#service: python_script.set_state
#data_template:
#  entity_id: Binary_sensor.sensor1
#  state: ON


#    ou bien

#service: python_script.set_state
#data_template:
#  entity_id: sensor.netatmo_temperature_consigne
#  state: '{{(states.sensor.netatmo_temperature_consigne.state | float + 0.5)}}'




#--------------------------------------------------------------------------------------------------
# la bonne façon de passer un argument au script python est la suivante 
# Remarquez que j'ai utilisé service_data : à la place de data_template 
#--------------------------------------------------------------------------------------------------


#type: button
#entity: sensor.irrigation_icon_1
#tap_action:
#  action: call-service
#  service: python_script.hello_world
#  service_data:
#    nombre: jaime

• Redémarrer Hassio

Ensuite il vous faudra…
Les sensors à mettre dans /config/template/netatmo.yaml

netatmo.yaml
#*****************Netatmo Entrée***************************************************


- sensor:
    - name: "netatmo_temperature_consigne"
      unique_id: netatmo_temperature_consigne    
      # Remplacer "Entrée"  par le nom de votre thermostat
      #device_class: temperature
      #unit_of_measurement: '°C'
     # Remplacer "netatmo_entree"  par le nom de votre thermostat
      state: >
        {% set tempcon = state_attr('climate.netatmo_entree', 'temperature') %}
        {% if tempcon == 0 %}
           OFF
        {% else %}
           {{ state_attr('climate.netatmo_entree', 'temperature')| float }}
        {% endif %}

    - name: "netatmo_hvac_action"
      unique_id: netatmo_hvac_action    
      # temoin de chauffe
      # Remplacer "netatmo_entree"  par le nom de votre thermostat
      state: "{{ state_attr('climate.netatmo_entree', 'hvac_action') }}"

    - name: "netatmo_preset_mode"
      unique_id: netatmo_preset_mode    
            # Temoin Mode de fonctionnement
      # Remplacer "Entrée"  par le nom de votre thermostat
      # Remplacer "netatmo_entree"  par le nom de votre thermostat
      state: "{{ state_attr('climate.netatmo_entree', 'preset_mode') }}"
      
    - name: "netatmo_chauffage_on"
      unique_id: netatmo_chauffage_on    
      state: >-
        {{ states('sensor.netatmo_hvac_action') == "heating" }}

    - name: "netatmo_Température_courante"
      unique_id: netatmo_Température_courante    
      #device_class: temperature
      #unit_of_measurement: "°C"
      state: "{{ state_attr('climate.netatmo_entree', 'current_temperature')| float }}"          
      icon: mdi:thermometer

Les scripts, code à copier dans votre fichier scripts.yaml

scripts


netatmo_increment_consigne:
  alias: netatmo_increment_consigne
  sequence:
  - action: climate.set_temperature
    data:
      temperature: '{{(states.sensor.netatmo_temperature_consigne.state | float +
        0.5)}}'
    target:
    # Remplacer "netatmo_entree"  par le nom de votre thermostat
      entity_id: climate.netatmo_entree
  - action: python_script.set_state
    data_template:
      entity_id: sensor.netatmo_temperature_consigne
      state: '{{(states.sensor.netatmo_temperature_consigne.state | float + 0.5)}}'
  mode: single
  
netatmo_decrement_consigne:
  alias: netatmo_decrement_consigne
  sequence:
  - action: climate.set_temperature
    data:
      temperature: '{{(states.sensor.netatmo_temperature_consigne.state | float -
        0.5)}}'
    target:
    # Remplacer "netatmo_entree"  par le nom de votre thermostat
      entity_id: climate.netatmo_entree
  - action: python_script.set_state
    data_template:
      entity_id: sensor.netatmo_temperature_consigne
      state: '{{(states.sensor.netatmo_temperature_consigne.state | float - 0.5)}}'
  mode: single

netatmo_mode_absent:
  alias: netatmo_mode_absent
  sequence:
  - action: climate.set_preset_mode
    target:
    # Remplacer "netatmo_entree"  par le nom de votre thermostat
      entity_id: climate.netatmo_entree
    data:
      preset_mode: away
  - action: python_script.set_state
    data_template:
      entity_id: sensor.netatmo_preset_mode
      state: away
  mode: single
  
netatmo_mode_hors_gel:
  alias: netatmo_mode_hors_gel
  sequence:
  - action: climate.set_preset_mode
    target:
    # Remplacer "netatmo_entree"  par le nom de votre thermostat
      entity_id: climate.netatmo_entree
    data:
      preset_mode: frost_guard
  - action: python_script.set_state
    data_template:
      entity_id: sensor.netatmo_preset_mode
      state: frost_guard
  mode: single
  
netatmo_mode_schedule:
  alias: netatmo_mode_schedule
  sequence:
  - action: climate.set_preset_mode
    target:
    # Remplacer "netatmo_entree"  par le nom de votre thermostat
      entity_id: climate.netatmo_entree
    data:
      preset_mode: schedule
  - action: python_script.set_state
    data_template:
      entity_id: sensor.netatmo_preset_mode
      state: schedule
  mode: single

netatmo_on_off:
  alias: Netatmo on/off
  sequence:
  - choose:
    - conditions:
      - condition: state
    # Remplacer "netatmo_entree"  par le nom de votre thermostat
        entity_id: climate.netatmo_entree
        state: 'off'
      sequence:
      - action: climate.turn_on
        data: {}
        target:
    # Remplacer "netatmo_entree"  par le nom de votre thermostat
          entity_id: climate.netatmo_entree
      - action: python_script.set_state
        data_template:
    # Remplacer "netatmo_entree"  par le nom de votre thermostat
          entity_id: climate.netatmo_entree
          state: auto
    default:
    - action: climate.turn_off
      data: {}
      target:
    # Remplacer "netatmo_entree"  par le nom de votre thermostat
        entity_id: climate.netatmo_entree
    - action: python_script.set_state
      data_template:
    # Remplacer "netatmo_entree"  par le nom de votre thermostat
        entity_id: climate.netatmo_entree
        state: 'off'
        temperature: 0
  mode: single

Les images à déposer dans le dossier « netatmo » qui sera créer dans le dossier « www ».
Pour cela vous faites un clic droit sur l’image puis enregistrer l’image sous…

Absent
Absent.png
Automatique
Automatique.png


bouton_fond-300x98.png
Engie
Engie.png
Hors Gel
Hors Gel.png

Netatmo_background_409x762_2.png
Netatmo_chauffe
Netatmo_chauffe.png
Netatmo_up
Netatmo_up.png
Netatmo_down
Netatmo_down.png
Netatmo_manual
Netatmo_manual.png

netatmo-off.png

netatmo-on.png

Enfin le code de la carte:

Carte
type: picture-elements
image: /local/netatmo/Netatmo_background_409x762_2.png
elements:
  - type: image
# Remplacer "netatmo_entree"  par le nom de votre thermostat  
    entity: climate.netatmo_entree
# Vous pouvez remplacer cette image par celle de votre opérateur    
    image: /local/netatmo/Engie.png
    title: null
    tap_action:
      action: none
    style:
      top: 10%
      left: 90%
      width: 10%
  - type: image
# Remplacer "netatmo_entree"  par le nom de votre thermostat
    entity: climate.netatmo_entree
    title: Up Consigne
    tap_action:
      action: call-service
      service: Script.netatmo_increment_consigne
    hold_action:
      action: more-info
    image: /local/netatmo/Netatmo_up.png
    style:
      top: 52.6%
      left: 76.5%
      width: 6%
  - type: image
# Remplacer "netatmo_entree"  par le nom de votre thermostat
    entity: climate.netatmo_entree
    title: Down Consigne
    tap_action:
      action: call-service
      service: Script.netatmo_decrement_consigne
    hold_action:
      action: more-info
    image: /local/netatmo/Netatmo_down.png
    style:
      top: 52.6%
      left: 56.5%
      width: 6%
  - type: image
    entity: sensor.netatmo_hvac_action
    title: Temoin Chauffe
    tap_action:
      action: none
    image: /local/netatmo/Netatmo_chauffe.png
    style:
      top: 58%
      left: 25.5%
      width: 7%
    state_filter:
      heating: brightness(100%) saturate(1)
      idle: opacity(0%)
  - type: image
    entity: sensor.netatmo_preset_mode
    title: Mode de fonctionnement
    style:
      top: 29.9%
      left: 39%
      width: 11%
    state_image:
      manual: /local/netatmo/Netatmo_manual.png
      schedule: /local/netatmo/Automatique.png
      away: /local/netatmo/Absent.png
      frost_guard: /local/netatmo/Hors Gel.png
    tap_action:
      action: none
  - type: state-label
# Remplacer "netatmo_entree"  par le nom de votre thermostat
    entity: climate.netatmo_entree
    attribute: current_temperature
    unit_of_measurement: .
    title: Température Actuelle
    tap_action:
      action: null
    style:
      top: 48%
      left: 25.5%
      font-size: 1.6em
      color: black
      font-weight: 600
  - type: state-label
    entity: sensor.netatmo_temperature_consigne
    title: Température de consigne
    tap_action:
      action: null
    style:
      top: 25%
      left: 25.5%
      font-size: 1em
      color: white
      font-weight: 600
  - type: state-label
# Remplacer "netatmo_entree"  par le nom de votre thermostat
    entity: climate.netatmo_entree
    attribute: friendly_name
    style:
      top: 25%
      left: 66%
      font-size: 1.4em
      color: black
      font-weight: 400
  - type: state-label
# Remplacer "sensor.thermostat_entree_battery_percent"  par le sensor de votre thermostat
    entity: sensor.thermostat_entree_battery_percent
    title: '% Batterie'
    tap_action:
      action: none
    style:
      top: 79%
      left: 8.3%
      font-size: 0.7em
      color: grey
      font-weight: 600
  - type: state-icon
# Remplacer "sensor.thermostat_entree_battery_percent"  par le sensor de votre thermostat
    entity: sensor.thermostat_entree_battery_percent
    title: Niveau Batterie
    icon: mdi:battery-high
    tap_action:
      action: more-info
    style:
      top: 86%
      left: 8%
      '--paper-item-icon-color': grey
  - type: image
# Remplacer "netatmo_entree"  par le nom de votre thermostat
    entity: climate.netatmo_entree
    title: null
    tap_action:
      action: none
    image: /local/netatmo/bouton_fond-300x98.png
    style:
      top: 83.2%
      left: 71%
      width: 58%
  - type: image
# Remplacer "netatmo_entree"  par le nom de votre thermostat
    entity: climate.netatmo_entree
    title: Passer en Mode Absent
    tap_action:
      action: call-service
      service: Script.netatmo_mode_absent
    image: /local/netatmo/Absent.png
    style:
      top: 83%
      left: 53%
      width: 12%
  - type: image
# Remplacer "netatmo_entree"  par le nom de votre thermostat
    entity: climate.netatmo_entree
    title: Passer en Mode Hors Gel
    tap_action:
      action: call-service
      service: Script.netatmo_mode_hors_gel
    image: /local/netatmo/Hors Gel.png
    style:
      top: 83.2%
      left: 79.5%
      width: 14.5%
  - type: image
# Remplacer "netatmo_entree"  par le nom de votre thermostat
    entity: climate.netatmo_entree
    title: Passer en Mode Automatique
    tap_action:
      action: call-service
      service: Script.netatmo_mode_schedule
    image: /local/netatmo/Automatique.png
    style:
      top: 83.2%
      left: 67%
      width: 10%
  - type: state-label
    entity: select.netatmo_domicile
    title: Planning
    icon: mdi:calendar
    style:
      top: 80%
      left: 27%
      '--paper-item-icon-color': rgb(68,68,68)
  - type: image
# Remplacer "netatmo_entree"  par le nom de votre thermostat
    entity: climate.netatmo_entree
    title: On / Off
    style:
      top: 10%
      left: 8%
      width: 07%
    state_image:
      'off': /local/netatmo/netatmo-off.png
      auto: /local/netatmo/netatmo-on.png
    tap_action:
      action: call-service
      service: Script.netatmo_on_off
  - type: action-button
    style:
      left: 27%
      top: 90%
    action: homeassistant.reload_config_entry
    title: Actualiser
    data: {}
    target:
      entity_id: select.netatmo_domicile


Voici un aperçu de cette carte :


netatmo du 11-03-2025

Lien vers l’ancien sujet archivé:

1 « J'aime »