Template Attribute for Entity Added through UI

Can I template an attribute for an entity(integration) that was added through the UI?

Specifically, I’d like to template the friendly_name for the weather forecast entity to set it to the current city my camper is in. I have a sensor that provides the current city, state, and I update the weather forecast every time the camper location changes, but want to be able to show the current city and state on my weather card on my dashboard.

If you configure the sensor in YAML you can use a template to define the name.

Sorry, I should have been more clear. I am trying to template the friendly_name for the weather entity created by the Meteorologisk institutt integration.

I can’t find any info on adding/configuring this integration through yaml.

I’ve tried setting this attribute through an automation, but it reverts back to “forecast home” every time the integration updates or reloads.

Ultimately, when I place a weather card on my dashboard, I want the current city/state to show up in place of the friendly_name. I tried templating the name in the card’s yaml, but I don’t believe that allows templates.

You can’t dynamically overwrite the name like that. AFAIK, your only option if you want a dynamic name would be to create a Template Weather entity.

That looks like too much work with the somewhat recent removal of forecast data attributes. I did find a good workaround though - the Config-Template-Card.

type: custom:config-template-card
entities: weather.forecast_home
card:
  type: weather-forecast
  entity: weather.forecast_home
  show_current: true
  show_forecast: true
  forecast_type: daily
  forecast_slots: 7
  name: >-
    ${(states['sensor.location'].attributes.city)+',
    '+(states['sensor.location'].attributes.state_abbr)}

I ended up scrapping this approach since it requires a page refresh if the city changes. Instead, I used card mod to add the city/state to the weather card.