Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entity translations to HVV Departures #95442

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions homeassistant/components/hvv_departures/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ class HVVDepartureSensor(SensorEntity):
_attr_attribution = ATTRIBUTION
_attr_device_class = SensorDeviceClass.TIMESTAMP
_attr_icon = ICON
_attr_translation_key = "departures"
_attr_has_entity_name = True
_attr_extra_state_attributes = {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't initialize a class attribute to a mutable object. That's error prone and rarely needed.

If this platform would have added more than one sensor entity, every time one entity updated its state attributes, all sensor instances would get that update to their state attributes dict.

_attr_available = False

def __init__(self, hass, config_entry, session, hub):
"""Initialize."""
self.config_entry = config_entry
self.station_name = self.config_entry.data[CONF_STATION]["name"]
self._attr_extra_state_attributes = {}
self._attr_available = False
self._attr_has_entity_name = True
self._attr_name = "Departures"
self._last_error = None

self.gti = hub.gti
Expand Down
7 changes: 7 additions & 0 deletions homeassistant/components/hvv_departures/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,12 @@
}
}
}
},
"entity": {
"sensor": {
"departures": {
"name": "Departures"
}
}
}
}