Combine 2 entities in 1 helper?

hi, I would like to combine 2 entities in 1. In my case I have a humidity and temperature sensor and it would be perfecf if I can display both in one in my dashboard. For instance it could look so → “55% / 23°C”. Is there a way to implement my idea? If yes, what kind of template helper is required and how should look the code?

A template helper.

{{ states('sensor.humidity') + " / " + states('sensor.temperature') }}
2 Likes

Thanks a lot.

May I ask an additional question:-) How do I adjust the code to get rounded numbers? Actually I thought it works if I change the code like this.

{{ states('sensor.abc') + " % + " + states('sensor.xyz')|float|round(0) + " °C" }}

But it doesn’t work :frowning: It woukld be great if you can help a second time:-)

Remove float and round, and make int

{{ states('sensor.abc') | int + " % + " + states('sensor.xyz')|int + " °C" }}

It seems I made some mistake because I don’t get an outcome after adjustment. But I don’t have any idea what is the cause :frowning:

Paste it in the template tool in developer tools and take a picture of it.

You can only ‘add’ a string to a string not to a number, so you need to ensure that both sensors are strings:

{{ states('sensor.abc') | int | string +'%' + ' / ' + states('sensor.xyz') | int | string + '°C'}}

This is my code for my template sensor helper:

{{ states('sensor.abc')|int + " % + " + states('sensor.xyz')|int + " °C" }}

This is the error messager:

TypeError: can only concatenate str (not “int”) to str

There’s no reason to do this all in a single template output. Just output the 2 separately without needing to concatenate the strings.

{{ states('sensor.abc') }} % + {{ states('sensor.xyz') }} °C
1 Like

THANKS!!! It is working<