I have created (I think its called) a template sensor for Day 2 day 3 day 4 etc to specify which day of the week it is (as from the current today…)
E.g. "{{ (as_timestamp(now())+(60*60*72))|timestamp_custom('%A') }}" is the one for day 3.
I use Solcast forecasts for day 2 day 3 etc.
I want a neat way to display the Solcast forecast (it is a number of kWh’s) with e.g. Tuesday Solcast as the title. I’m thinking is there a way (preferably in the UI) to rename the Solcast Day 3 using the Xday Solcast format? It doesn’t seem to like it when I paste the above code into the entity name in UI (I think this is “friendly name”).
Any ideas from less of a novice than me would be welcome as my googling didn’t get me anywhere.
Thanks so much. However the sensor I’m changing the name of is created by the Solcast integration so I don’t know how to get at it in yaml, only in UI??
Will I just have create a new sensor that copies the value of the Solcast sensor and then name it (in yaml) as above, or is there any way to rename the original Solcast sensor?
AFAIK, you cannot apply a dynamic name directly to the original sensor. You will need to set up a template sensor that mirrors the value in question.
If you only need this for display purposes, there are a number of custom cards like Mushroom or Custom Button Card that support templating and could be used to achieve that goal.
I have been looking for how to do this for a while. thanks!
Now… How do I use that sensor in a card? I admit to being a bit of a noob with HA, but, I can’t seem to find the sensor when I search for the unique_id I specified.
The u ique id is not the entity id and I don’t think you can search for it… The entity id is derived from the name, so I would not dare to guess if this works and what the entity might be if it did. But I’m not surprised it woun’t show up by searching for pirateclouds. Try seaching for cloud.
Tht is the int filter. It should be something like
| int(0)
Where 0 is the value it will use if what is before it is not a number (unknown for instance)
No, that was my point. I do not think you can create sensors with dynamic names this way, Because what would be the entity id that is derived from the name, and would it be the same the next time you reboot? And would the entity id stay the same while the name changes without rebooting? HA will likely think you try to load a whole different sensor with the same unique id.
I know that what’s what asked, and what seems like a solution. But has anyone actually succeeded? Templating a name in a card on the front end is a whole lot more sensible then to try templating the friendly name of a sensor at the server side. I do not think this is a case that the devs ever accounted for.
The unique ID does not set the original entity ID, that will be set by the name rendered by the template when the entity is created. IIRC, the only time the unique ID is used to populate the entity ID is when no name is provided.
But does the name change real time and update on screen, or only when loaded? And if it works, the word pirateclouds would not help finding the entity. That is why I suggested searching for cloud, as that should be in the name and in the entity id.
It is nice that is works. But I wouldn’t have expected it to as changing a name in templates would for me usually lead to HA thinking it is a different sensor, and create another entity. Does the unique_id prevent that? Because I usually set it but still have trouble changing names of sensors when you cannot also set the entity id in the template by hand.