Replace Entity Sensor State with String

Good day
I am trying to change the state from “ON” to “1000 W” How do I do that? I have tried various options, but no luck :frowning:

                - entity: sensor.gwmod_element_power
                  secondary_info: last-updated
                  icon: mdi:heating-coil
                  name: Geyser Element Power
                  show_state: true
                  state: >-
                    [[[
                    {% if is_state('sensor.gwmod_element_power', 'ON') %}
                      1000 W
                    {% else %}  
                      0 W
                    {% endif %}  
                    ]]]
                  card_mod:
                    style: >-
                      :host {  {% if states('sensor.gwmod_element_power') ==
                      'ON' %}
                        --paper-item-icon-color: red;
                        color: red;
                      {% else %}  
                        --paper-item-icon-color: green;
                        color: white;
                      {% endif %} }

Probably better off making new template sensor that does that, or maybe use powercalc ?

I agree with @Holdestmade – if you make a sensor that reports 1000 in units of W when it is on and 0 when it is off, then you can display that.

Check custom:template-entity-row - it will allow you to display a custom state.

But the initial task is unclear.
You compare a “sensor” value with “ON”.
Usually binary sensors have “on” (or “off”) value, but here it is a sensor.

Regarding an advice to use a template sensor. It is a good advice - if you need to display this “1000” value in many places. Otherwise using a custom card could be a rather sufficient solution.

Thanks you all. I will create a template sensor. The reason for ON/OFF (capitals) is that the Arduino is programmed to MQTT the message in capitals :slight_smile: