Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95295

Templating - jinja syntax question

$
0
0

@klogg wrote:

I would like to take the average of a series of sensors, so long as they are reporting a valid number as their state (which they do under ‘normal’ circumstances).

I know how to do this but it would take me a lot of lines and I feel sure there is simple (possibly even one line) way to do this that I just don’t know because my jinja/python skills are not good enough.

Anyone care to help?


e.g.

sensor.sensor1 = 2
sensor.sensor2 = 3
sensor.sensor3 = 4
sensor.sensor4 = ‘unknown’

would return 3


sensor.sensor1 = 3
sensor.sensor2 = 4
sensor.sensor3 = 5
sensor.sensor4 = 6

would return 4.5

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95295

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>