I use command line sensors to get TFL train info.
TFL have recently split one line into five so I need five new sensors.
I have been using this successfully for years:
command_line:
- sensor:
name: Metropolitan Line
unique_id: tfl_line_status_metropolitan
command: >
curl https://api.tfl.gov.uk/Line/metropolitan/Status?true 2> /dev/null
| jq '{"name": .[].name, "lineStatuses": [.[].lineStatuses[] | {"description": .statusSeverityDescription, "reason": .reason}], "lineTypes": [.[].serviceTypes[] | {"name": .name}]}'
value_template: *line_state
json_attributes: *line_attributes
command_timeout: 55
So it should be simple to add new lines using exactly the same format like this, right?
Wrong.
- sensor:
name: Mildmay Line
unique_id: tfl_line_status_mildmay
command: >
curl https://api.tfl.gov.uk/Line/mildmay/Status?true 2> /dev/null
| jq '{"name": .[].name, "lineStatuses": [.[].lineStatuses[] | {"description": .statusSeverityDescription, "reason": .reason}], "lineTypes": [.[].serviceTypes[] | {"name": .name}]}'
value_template: *line_state
json_attributes: *line_attributes
command_timeout: 55
The unexpected behaviour is that the original sensors create entities in HA with the ‘correct’ name/unique_id i.e.
sensor.tfl_line_status_[line_name]_line
Whereas the new sensors in identical format don’t.
sensor.[line_name]_line
What is going on here?
Thanks.
PS Note that as the entity_id
is ‘wrong’ my customised entity_picture
isn’t applied.