How to fix this template?

The problem is your .0, you are pretty much asking for states.switch.sonoff_100054cd9a.consumption.0. What are you trying to do here?

For future reference, you’ll get better help if you adhere to these guidelines:

1 Like