Hello, i want to combine some values coming from three similar sensors to a single sensor (attributes to attributes not attributes to state sensor). Is it even possible?
Thanks
Gekomax
Hello, i want to combine some values coming from three similar sensors to a single sensor (attributes to attributes not attributes to state sensor). Is it even possible?
Thanks
Gekomax
Sure. Use a template sensor with the state_attr() jinja function.
Yes, you can use attribute templates with the template sensor. If you show a screenshot of the attributes you want to combine, I can help you tailor the resulting sensor.
Hi, thanks.
These are the sensors attributes I’m going to combine:
[sensor.notizie_adnkronos]
entries:
- title: 'Tv: concluse a Roma riprese della serie evento Rai ''Leonardo'''
summary: ''
- title: 'Roma, Beppe Grillo ''benedice'' il Raggi bis: "Daje"'
summary: >-
Su Twitter il garante e fondatore del M5S, dopo l'annuncio della sindaca di
Roma Virginia Raggi di voler correre per un altro mandato, posta una foto
che lo ritrae assieme alla prima cittadina pentastellata
- title: >-
Dj morta: Soccorritore Gdf, 'ricerca Gioele sempre più complicata ma lo
dobbiamo trovare'
summary: ''
etc...
then…
[sensor.notizie_ansa]
entries:
- title: 'Branco umilia invalido e gli incendia casa, 3 arresti'
summary: 'E'' successo a Castrovillari, in Calabria. Nel gruppo anche due minorenni'
- title: 'Amazon cambia nome a Twitch Prime, ora è Prime Gaming'
summary: Il servizio continua a dare accesso gratuito ai videogiochi
- title: Governo Usa annuncia nuova asta frequenze per 5G
summary: Disponibile ulteriore spettro per lo sviluppo delle reti mobili
etc...
All these should be combined on sensor.notizie attributes.
I used this code but I doesn’t achieve what I want:
- platform: template
sensors:
notizie:
friendly_name: 'Notizie'
value_template: >
{{ states.sensor.notizie_ansa.attributes.entries }}
{{ states.sensor.notizie_corriere.attributes.entries }}
{{ states.sensor.notizie_adnkronos.attributes.entries }}
Thanks!
Gekomax
Ah, and I’m sure you’re going to want to use the title and summaries. What you want is not possible because templates return strings, not usable objects. I recommend using a python script to combine the data into 1 sensor.
yes, you’re right.
I think I should install AppDaemon, right?
you could just use a simple python_script with an automation. Or you could use appdeamon. Choice is yours.
I’ve never lauch python script. I’ll investigate this.
Thanks for your time!
Gekomax