Automation to record peak power - stopping short

I found the problem and a solution.
My key was too long, therefore I added the quotes around the state. My stupid mistake, and not very helpful to post the code after editing (cutting) the real key.

The original (too long) key was something like:

sensor.ew16_garage_blalvhfhfpehflejoivfewjf;qjhvfpjhgflhqgfg32_realtime_power

After changing the template to


      - name: "FusionSolar realtime power W"
        device_class: power
        icon: mdi:solar-power
        unit_of_measurement: "W"
        availability: "{{ is_number(states('sensor.ew16_garage_blalvhfhfpehflejoivfewjf;qjhvfpjhgflhqgfg32_realtime_power')) }}"
        state: >-
          {% set x = states('sensor.ew16_garage_blalvhfhfpehflejoivfewjf;qjhvfpjhgflhqgfg32_realtime_power')|float * 1000  %}
            {{ x | float(0) }}
        unique_id: "FusionSolar realtime power W"

your template worked!
Thank you 123 Taras!

1 Like