Howto change value of entity

Hi,
I use NUT integration to read states of my UPS.

I have snsor of temperature that read/comunicate wrong value 255 degree celsius…real tempaerature is 25 degree celsius

So I would have on lovelace dashboard real value of 25 degree celsius…

any ideas?

template:
  - sensor:
      - name: "UPS Actual Temperature"
        unit_of_measurement: "°C"
        state: >-
          {{ states('sensor.your_ups_sensor') | int / 10 }}

Try creating a new template sensor. Replace sensor.your_ups_sensor with your actual sensor entity ID.

You will now have a new sensor entity ID called sensor.ups_actual_temperature.

Hi,
I tried to add your suggestion in my configuration.yaml.

this is the lines I added:


sensor:
  - platform: template
    sensors:
      sensor.riello_ups_temperature_real:
        friendly_name: "UPS temperatura reale"
        device_class: temperature
        unit_of_measurement: "°C"
        attribute_templates:
          state: >-
            {{ sensor.your_ups_sensor | int / 10 }}

but when I go to do check of config before reboot, I receive this error:

Invalid config for [sensor.template]: invalid slug sensor.riello_ups_temperature_real (try sensor_riello_ups_temperature_real) for dictionary value @ data[‘sensors’]. Got OrderedDict([(‘sensor.riello_ups_temperature_real’, OrderedDict([(‘friendly_name’, ‘UPS temperatura reale’), (‘device_class’, ‘temperature’), (‘unit_of_measurement’, ‘°C’), (‘attribute_templates’, OrderedDict([(‘state’, ‘{{ sensor.your_ups_sensor | int / 10 }}’)]))]))]). (See ?, line ?).

any idea?

Try adding the line that I proposed in your configuration.yaml. This goes directly in your configuration.yaml and NOT under the sensor header. The template sensor I proposed is based on State-based Template Sensor-

template:
  - sensor:
      - name: "UPS Temperatura Reale"
        unit_of_measurement: "°C"
        device_class: temperature
        state: >-
          {{ states('sensor.riello_ups_temperature_real') | int / 10 }}

The result of this template is a new entity called sensor.ups_temperatura_reale that you can use in your lovelace dashboard.

you are right: this worked fine…

I don’t understand why my config in sensor section don’t worked fine…can you explain it?

Currently, there are 2 formats that you can use to create template sensor - Modern Template Sensor format and Legacy format.

Mine uses the modern format to configure Template Sensor (see here).

The one that you first want to use is called Legacy Sensor. If you want to fix your legacy sensor, change it like below. This code assumes that you don’t have sensor: !include sensors.yaml in your configuration.yaml file.

sensor:
  - platform: template
    sensors:
      ups_temperatura_reale:
        friendly_name: "UPS Temperatura Reale"
        device_class: temperature
        unit_of_measurement: "°C"
        value_template: >-
          {{ states('sensor.riello_ups_temperature_real') | int / 10 }}

I believe yours encountering error because the formatting is incorrect. Refer to the Legacy Sensor link that I provided.

@ardysusilo thanks for reply!

so I have to convert all my legacy template sensor in modern template?

you suggest me to add these lines in configuration.yaml?
sensor: !include sensors.yaml
template: !include template.yaml

No. As I said previously, your legacy format does not work because it is formatted incorrectly.

This is entirely up to you. Some want to tidy up their configuration.yaml file by splitting their configuration, while others may want to have it all in one place.

If you decide to split your configuration, please read this-