The system cannot restart because the configuration is not valid: Integration error: state - Integration 'state' not found

Hello, I am just trying to do what I thought would be a simple thing but now I have spent a couple of hours on this… I just want to add a constant to an entity value that I monitor. It is an electricity price that I want add a constant to so it will show what I will actually pay in the end (the utility company adds a cost per transferred kWh). There is no simple UI based way to do this if I understand this correctly, I have to create a “Template” and add it to configuration.yaml. So I add this to configuration.yaml:

template:
- sensor:
- name: Elpris_inkl_allt
state: "{{ states('sensor.electricity_price_fensbol_134')| float(0)  + 0.63| float(0)  }}"

I get the green light in the file editor but then HA can’t reboot and I get this error message:
The system cannot restart because the configuration is not valid: Integration error: state - Integration ‘state’ not found.

I am grateful for help to solve this -and I hope the answer is “there is a simpler way to do this”… :slight_smile:

The indentation is wrong and you should also take more care about the spaces you set. Try this (not tested though):

  template:
    - sensor:
        - name: "Elpris_inkl_allt"
          state: >
            {{ states('sensor.electricity_price_fensbol_134')| float(0) + 0.63| float(0) }}

Thank you very much Tamsy, it works! Doesn’t show exactly how I want it, but I can work on that.

I am not used to code and to be honest I don’t want to take the time to learn. I’ve spent too much time on that in the past, I am just not good at it. Do you have any idea of why a basic functionality like this is not available in the frontend UI? Where you can just create new entities, without code, by picking entities to manipulate e.g. “entity 1 + entity 2” and call it “entity 3”? There must be a million use cases for this, and equally many people who prefer not to code.

Me neither. I’m more into system administration than into coding and I do rarely reply to questions regarding coding. However, those wrong indentations with your template above jumped straight into my eyes :laughing:

1 Like

I don’t remember what it’s called but I remember reading in the release notes for the December release that there is a new helper entity that returns the sum of two other sensors.

It should be configurable thru the UI like other helpers.

I did have a look at the helpers but couldn’t find anything useful there. If you find it, let me know! In this case however, I just want to add a constant to a sensor value.

Have you updated to the latest version of HA? If so then where did you look?

According to the release notes it should be in the helpers section.

I haven’t updated so I can’t tell you specifically where it is but according to this…

…it should be there somewhere.