Change status for send email

Hello everyone, from my panel for the management of the off-grid system on Epever 6415 I was able to configure the state of the system’s condition. I would like to send notification emails when the text value changes state . Example how do I send an email if the status changes from “FLOAT” to “BOOST CHARGE” ? Here’s where I stop :

Ecco il file yaml

sensor:                          
  - platform: template
    sensors:
      epeverstatustext:
        friendly_name: "STATO REG1 battery"
        value_template: >-
          {% set mapper =  {
              '0' : 'NORMAL',
              '1' : 'NOT CHARGING',
              '2' : 'UNDER VOLTAGE',
              '3' : 'NONE',
              '4' : 'FAULT',
              '5' : 'NONE',
              '6' : 'NONE',
              '7' : 'NONE' } %}
          {% set state =  states.sensor.PV_Battery_Status_1.state %}
          {{ mapper[state] if state in mapper else 'Unknown' }}
  - platform: template
    sensors:
      epeverstatustext:
        friendly_name: "STATO REG1 charging"
        value_template: >-
          {% set mapper =  {
              '0' : 'NORMAL',
              '1' : 'NOT CHARGE',
              '2' : 'none',
              '3' : 'none',
              '4' : 'none',
              '5' : 'FLOAT',
              '6' : 'none',
              '7' : 'none',
              '9' : 'BOOST CHARGHING',
              '35' : 'OVER VOLTAGE',
              '10' : 'NONE',
              '11' : 'NONE' } %}
          {% set state =  states.sensor.PV_Charging_Status_1.state %}
          {{ mapper[state] if state in mapper else 'Unknown' }}

Have you looked at the googlemail integration?

Perhaps the translation was unclear. The smtp server exists in my network . what I want to do and create an automation that when it changes the state expressed in characters and not numbers sends an email .

You’ve given your two sensors the same slug:

    sensors:
      epeverstatustext:
...
    sensors:
      epeverstatustext:

… so I don’t know what your system will call them. Check and adjust as necessary:

trigger:
  - platform: state
    entity_id:
      - sensor.stato_reg1_battery       # check this entity ID
      - sensor.stato_reg1_charging      # check this entity ID
    not_to:
      - 'NONE'
      - 'none'
      - 'Unknown'
action:
  - service: notify.NOTIFIER_NAME       # adjust as necessary
    data:
      title: "Change of state"
      message: "{{ trigger.to_state.name }} changed to {{ trigger.to_state.state }}."
      target:
        - "[email protected]"

References:

You might also consider re-doing your two sensors in modern format:

template:
  - sensor:                          
      - name: "STATO REG1 battery"
        state: >-
          {% set mapper =  {
              '0' : 'NORMAL',
              '1' : 'NOT CHARGING',
              '2' : 'UNDER VOLTAGE',
              '3' : 'NONE',
              '4' : 'FAULT',
              '5' : 'NONE',
              '6' : 'NONE',
              '7' : 'NONE' } %}
          {{ mapper.get(states('sensor.pv_battery_status_1'), 'Unknown') }}
  - sensor:                          
      - name: "STATO REG1 charging"
        state: >-
          {% set mapper =  {
              '0' : 'NORMAL',
              '1' : 'NOT CHARGE',
              '2' : 'none',
              '3' : 'none',
              '4' : 'none',
              '5' : 'FLOAT',
              '6' : 'none',
              '7' : 'none',
              '9' : 'BOOST CHARGING',
              '35' : 'OVER VOLTAGE',
              '10' : 'NONE',
              '11' : 'NONE' } %}
          {{ mapper.get(states('sensor.pv_charging_status_1'), 'Unknown') }}

Although it starts to be difficult for my knowledge of HA , thank you anyway .