(RESOLVED) Generic camera and Google Maps - issue/not working

Hi,

Trying to use the generic camera platform to show my tracking_device, but get an error during boot.

@gerard33 Any ideas?

configuration.yaml:

camera:
  - platform: generic
    name: BMW 530i xDrive
    still_image_url: https://maps.googleapis.com/maps/api/staticmap?center={{ states.device_tracker.530i_xdrive.attributes.latitude }},{{ states.device_tracker.530i_xdrive.attributes.longitude }}&zoom=13&size=500x500&maptype=roadmap&markers=color:blue%7Clabel:P%7C{{ states.device_tracker.530i_xdrive.attributes.latitude }},{{ states.device_tracker.530i_xdrive.attributes.longitude }}&key=************
    limit_refetch_to_url_change: true

Error:

Invalid config for [camera.generic]: invalid template (TemplateSyntaxError: expected token ‘end of print statement’, got ‘i_xdrive’) for dictionary value @ data[‘still_image_url’]. Got ‘https://maps.googleapis.com/maps/api/staticmap?center={{ states.device_tracker.530i_xdrive.attributes.latitude }},{{ states.device_tracker.530i_xdrive.attributes.longitude }}&zoom=13&size=500x500&maptype=roadmap&markers=color:blue%7Clabel:P%7C{{ states.device_tracker.530i_xdrive.attributes.latitude }},{{ states.device_tracker.530i_xdrive.attributes.longitude }}&key=************’. (See /config/configuration.yaml, line 179). Please check the docs at Generic Camera - Home Assistant

Image from Device Tracker:
Capture

Try:

https://maps.googleapis.com/maps/api/staticmap?center={{ state_attr('device_tracker.530i_xdrive','latitude') }},{{ state_attr('device_tracker.530i_xdrive','longitude') }}&zoom=13&size=500x500&maptype=roadmap&markers=color:blue%7Clabel:P%7C{{ state_attr('device_tracker.530i_xdrive','latitude') }},{{ state_attr('device_tracker.530i_xdrive','longitude') }}&key=************

You can’t use dot notation for an element that starts with a number. You’d have to do at least this:

states.device_tracker['530i_xdrive'].attributes.latitude

But it’s generally better to use the state_attr function, in which case you’re passing it an entity_id string where it doesn’t matter.

1 Like

Thank you @pnbruckner :slight_smile:

1 Like