ESPresense - Dynamically Renaming Rooms

Hi All,

I have a number of ESPresense rooms which use MQTT to display which room someone is in - annoyingly, even though I name the rooms on ESPresense as, for example, Lounge, Kitchen, Hallway - MQTT only provides lower case locations, lounge, kitchen, hallway.

I’ve historically used a Mushroom template card to re-write these rooms as follows:

{% if is_state('sensor.my_phone','hallway') %}
    Hallway
{% elif is_state('sensor.my_phone','lounge') %}
    Lounge
{% elif is_state('sensor.my_phone','kitchen') %}
    Kitchen
{% elif is_state('sensor.my_phone','utility room') %}
    Utility Room
{% else %}
    Not Home
{% endif %} 

But my ever expanding ESPresense network is making the overhead of this cumbersome - so I was wondering if there was another way to do this dynamically so it always capitalises the first letter, in either code or regex? Annoyingly ESPresense doesn’t display the room name as a sensor anywhere so I can’t even rename that.

Thanks
Leacho

{{ states('sensor.my_phone') | title }}

Reference: title filter

2 Likes

Thanks @123 - a super simple solution!

1 Like