Commandline sensor and multivalues

Hi All,

I need some help on value templating, I guess. I have a commandline sensor that returns 4 values ended with a return. So it looks like this:

21
305
0
2

This sesnor is now showing up in HASS as one sensor with all the values separated with a space in one line. Like this: 21 45 0 2

What is the best way to show these values as seperate values like the come from different sensors? Like:
temperature: 21
powerusage: 305
etc.
etc.

This is probably very easy but I cannot figure it out and need an example to work on. Many thnx!

states.sensor.sensor_name.state.split('\n')[0] will get you the first value, being 21. Using the indexes 1, 2 and 3 will get you the three remaining values.

If this doesn’t work, then try replacing '\n' (newline) with ' ' (space).

Many thanks it works now! :slight_smile:

1 Like