I’m using {{trigger.entity_id}}
which returns sensor.bmw
. I’d like to be able to strip the “sensor.” part so I’m just left with “bmw”. Is there a way to do this?
You don’t need regex for this. Just split the string at the point
{{ trigger.entity_id.split('.') }}
and use the second value
{{ trigger.entity_id.split('.')[1] }}
Thats something to play with in Dev Tools/Templates.
Assign the string to a variable:
{% set string = 'k10temp-pci-00c3 Adapter: PCI adapter temp1: +47.4°C (high = +70.0°C) (crit = +100.0°C, hyst = +95.0°C) °C' %}
Now split it by spaces and get item 6 (python lists start with 0 so we use 5)
{{ string.split(' ')[5] }}
Now we have +47.4°C
Next we split it by the plus sign and get item 2 (1)
{{ string.split(' ')[5].split('+')[1] }}
Now we have 47.4°C
And at least we split it by the degree …