vincentwolsink / home_assistant_micronova_agua_iot

Home Assistant integration controlling heating devices connected via the Agua IOT platform of Micronova
Apache License 2.0
27 stars 15 forks source link

no more status codes #49

Closed silkyclouds closed 11 months ago

silkyclouds commented 1 year ago

Hi there,

Last year I created a set of notifications based on the status codes of my stove, like that one :

alias: "Notification : plus de pellets insert"
description: ""
trigger:
  - platform: state
    entity_id: sensor.device_status
    to: "12"
action:
  - service: notify.alexa_media_echo_salle_a_manger
    data:
      message: Il n'y a plus de pellets dans l'insert, veuillez en rajouter
  - service: notify.groupe_de_notifications_famille
    data:
      message: "J'ai FAIM !!! donnez-moi du pellet a manger humains ! "
      title: Insert Montefiore
mode: single

I noticed these notifications are not working anymore, and it seems your integration totally removed the status codes reported by the stoves.

image

Would it be possible to get these back in order to allow people to keep triggering notifications when a stove enters a specific mode (above, an example of a notification I was getting when the stove was empty (no more pellet).

Thanks !

vincentwolsink commented 1 year ago

Hi! In the latest beta the stove status moved to a separate sensor with (textual) status output. If you change your notifications to use that new sensor everything should be good again.

I can also add the attribute with the status code back to the climate entity with the next beta.

silkyclouds commented 1 year ago

I have absolutely no issue using the new sensor if you tell me it's name so I can check what it looks like ;)

but as far as I remember, checking the status codes that matches the specific "status" of my stove took me quite some time (Eg: checking the status on the remote controller of the stove, each time a specific state was reached, in my example, I had to figure out that once the status code was 12, it actually meant the stove was out of pellet).

So, in order to be 100% sure my automations and human redable statuses keeps working, enabling the status codes back would be indeed super nice ;)

Just for you to know how it looks in my templates.yaml:

- platform: template
  sensors:
    current_temperature:
      unique_id: "current_temperature"
      friendly_name: "Temperature actuelle insert"
      unit_of_measurement: "°C"
      value_template: "{{ state_attr('climate.insert_montefiore', 'current_temperature')}}"
    temperature:
      unique_id: "temperature"
      friendly_name: "Temperature voulue insert"
      unit_of_measurement: "°C"
      value_template: "{{ state_attr('climate.insert_montefiore', 'temperature')}}"
    fan_mode:
      unique_id: "fan_mode"
      friendly_name: "Vitesse ventilateur insert"
      unit_of_measurement: "state"
      value_template: "{{ state_attr('climate.insert_montefiore', 'fan_mode')}}"
    hvac_action:
      unique_id: "stove_hvac_action"
      friendly_name: "Etat insert"
      unit_of_measurement: "state"
      value_template: "{{ state_attr('climate.insert_montefiore', 'hvac_action')}}"
    smoke_temperature:
      unique_id: "smoke_temperature"
      friendly_name: "Temperature Fumees insert"
      unit_of_measurement: "°C"
      value_template: "{{ state_attr('climate.insert_montefiore', 'smoke_temperature')}}"
    human_device_status:
      unique_id: "human_device_status"
      friendly_name: "Statut insert"
      value_template: "{{ state_attr('climate.insert_montefiore', 'human_device_status')}}"
    device_status:
      unique_id: "device_status"
      friendly_name: "Code statut insert"
      value_template: "{{ state_attr('climate.insert_montefiore', 'device_status')}}"
    real_power:
      unique_id: "real_power"
      friendly_name: "puissance effective insert"
      value_template: "{{ state_attr('climate.insert_montefiore', 'real_power')}}"
    readable_device_status:
      value_template: >-
        {% set t = states('sensor.device_status')|int(0) %}
        {% set values =
            ['Insert éteint', 'Démarrage', 'Préchauffe',
             'Chargement pellets allumage', 'Allumage bougie', 'Allumage initial',
             'Finallisation allumage', 'Chauffage en cours', 'Demande extinction',
             'Nettoyage final', 'Attente de Standby', 'Standby',
             'Alerte: Plus de pellet', 'Alerte: Nettoyer brasier'] %}
        {{ values[t] }}
    readable_real_power:
      value_template: >-
        {% set t = states('sensor.real_power')|int(1) %}
        {% set values =
            ['Eco', 'Eco', 'Low',
             'Medium', 'High', 'Giga',
             'Ultra'] %}
        {{ values[t] }}

Here you can see I am expecting these codes and translate them back to "human readable" states. If you have a better idea that would allow me to get the human readable states without the need of these templates, I'm all ears !

thank you for your fast answer by the way, Vincent. ;)

jipem01 commented 1 year ago

I think we could implement "raw" status code as dedicated sensor. Better than having them as attribute.And quite easy with the new architecture (thanks vincent to have get rid of pyaguaiot api!).

vincentwolsink commented 1 year ago

The new status sensor, see below, gets the human readable status directly from the api. (This is better since different vendors implemented different statuses for the raw numbers). You just have to translate them to your own language.

I’m also thinking about supporting multi-language for the human readable values, since some vendors actually support that.

Scherm­afbeelding 2023-10-11 om 12 02 52
vincentwolsink commented 12 months ago

In #54 I expose the raw value as extra attribute for all sensors that do auto translation of the value. Also useful for doing numerical comparison on some sensors. In your case you can probably use it with state_attr('sensor.insert_montefiore_status', 'raw_value')

silkyclouds commented 11 months ago

can you eventually help me out a little bit here ?

What do I exactly need to change ? I guess it's a change to the entity I point to in my sensors.yml list right ?

    readable_device_status:
      value_template: >-
        {% set t = states('sensor.device_status')|int(0) %}
        {% set values =
            ['Insert éteint', 'Démarrage', 'Préchauffe',
             'Chargement pellets allumage', 'Allumage bougie', 'Allumage initial',
             'Finallisation allumage', 'Chauffage en cours', 'Demande extinction',
             'Nettoyage final', 'Attente de Standby', 'Standby',
             'Alerte: Plus de pellet', 'Alerte: Nettoyer brasier'] %}
        {{ values[t] }}
    readable_real_power:
      value_template: >-
        {% set t = states('sensor.real_power')|int(1) %}
        {% set values =
            ['Eco', 'Eco', 'Low',
             'Medium', 'High', 'Giga',
             'Ultra'] %}
        {{ values[t] }}
vincentwolsink commented 11 months ago
    readable_device_status:
      value_template: >-
        {% set t = state_attr('sensor.device_status', 'raw_value')|int %}
        {% set values =
            ['Insert éteint', 'Démarrage', 'Préchauffe',
             'Chargement pellets allumage', 'Allumage bougie', 'Allumage initial',
             'Finallisation allumage', 'Chauffage en cours', 'Demande extinction',
             'Nettoyage final', 'Attente de Standby', 'Standby',
             'Alerte: Plus de pellet', 'Alerte: Nettoyer brasier'] %}
        {{ values[t] }}
    readable_real_power:
      value_template: >-
        {% set t = state_attr('sensor.real_power', 'raw_value')|int %}
        {% set values =
            ['Eco', 'Eco', 'Low',
             'Medium', 'High', 'Giga',
             'Ultra'] %}
        {{ values[t] }}
silkyclouds commented 11 months ago

image

strangely, changing the code for the one you provided is not translating the codes to the values I did setup before. You can see if actually shows a readble status in english.

vincentwolsink commented 11 months ago

Probably you are displaying the original sensor. You should change it to the templated one (sensor.readable_device_status)

silkyclouds commented 11 months ago

I changed it and still, I read "off" as status, which is not one of the frenchie statuses I defined earlier and part of my list ;)

vincentwolsink commented 11 months ago

The code works, I tested it on my own stove. So you must be doing something wrong 😉

silkyclouds commented 11 months ago

probably, yes. :)

image

vincentwolsink commented 11 months ago

In my code replace sensor.device_status with the actual device status sensor provided by the integration. It is named like sensor.STOVENAME_status. If you have difficulties with generic Home Assistant things, like templating sensors etc, you can also try to find help on the Home Assistant forum

silkyclouds commented 11 months ago

If you have difficulties with generic Home Assistant things

Dude, I know how my sensors are named. :D

sensor.insert_montefiore_status-> Insert montefiore Status | OFF | raw_value: 0

I was simply tired enough to change the actual status I've added to the dashboard. putting readable_device_status back and it's back in business ! thanks for all the time you spent on this ! ;)