Add volvo on call device_info to group entities in one device per vehicle (#79329)

This commit is contained in:
DanielV 2022-10-14 12:11:53 +02:00 committed by GitHub
parent faef09d3d7
commit 849688f71f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,6 +23,7 @@ from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import (
@ -314,6 +315,16 @@ class VolvoEntity(CoordinatorEntity):
"""Return true if unable to access real state of entity."""
return True
@property
def device_info(self) -> DeviceInfo:
"""Return a inique set of attributes for each vehicle."""
return DeviceInfo(
identifiers={(DOMAIN, self.vehicle.vin)},
name=self._vehicle_name,
model=self.vehicle.vehicle_type,
manufacturer="Volvo",
)
@property
def extra_state_attributes(self):
"""Return device specific state attributes."""