Skip to content

Commit

Permalink
Merge pull request #190 from custom-components/Fix-entry_type-for-leg…
Browse files Browse the repository at this point in the history
…acy-versions

Fix entry_type for legacy versions
  • Loading branch information
isabellaalstrom authored Feb 20, 2022
2 parents 4d919b5 + 2ed9a04 commit 670b618
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions custom_components/grocy/entity.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""GrocyEntity class"""
import json

from homeassistant.const import MAJOR_VERSION, MINOR_VERSION
from homeassistant.helpers import entity
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

# pylint: disable=relative-beyond-top-level
Expand Down Expand Up @@ -102,14 +103,22 @@ def icon(self):

@property
def device_info(self):
return {
info = {
# "identifiers": {(DOMAIN, self.unique_id)},
"identifiers": {(DOMAIN, self.config_entry.entry_id)},
"name": NAME,
"model": VERSION,
"manufacturer": NAME,
"entry_type": DeviceEntryType.SERVICE,
}
# LEGACY can be removed when min HA version is 2021.12
if MAJOR_VERSION >= 2021 and MINOR_VERSION >= 12:
# pylint: disable=import-outside-toplevel
from homeassistant.helpers.device_registry import DeviceEntryType

info["entry_type"] = DeviceEntryType.SERVICE
else:
info["entry_type"] = "service"
return info

@property
def device_state_attributes(self):
Expand Down

0 comments on commit 670b618

Please sign in to comment.