I have recently setup Frigate, double-take and the like so I can have camera push notifications when a person is seen. I realized I have a small problem with my setup. I’m not a good enough programmer to figure out the right syntax to solve the problem.
I want my notifications to be well formatted so I took the camera name string test_camera and split it as such:
{{ (trigger.entity_id.split('_')[-2]).capitalize() }} {{ (trigger.entity_id.split('_')[-1]).capitalize() }} seen {{ (trigger.to_state.state.split('_')[-2]).capitalize() }} {{ (trigger.to_state.state.split('_')[-1]).capitalize() }}
Variable examples
trigger.entity_id = “sensor.double_take_billy_joel”, “sensor.double_take_tom”, “sensor.double_take_ups_delivery_guy”
trigger.to_state.state = “test_camera”, “front_door_camera”, “top_right_camera”, “backyard_camera”
This works fine for “test_camera” to convert it to “Test Camera” but what about when I install “front_right_camera” it would get cut off as “Right Camera”
Could somebody help me figure out the logic to make this work for cameras (and people) of various name lengths. I expect I’m going to need to split the string into an array and then parse it with a loop but I don’t know where to start.