1
mirror of https://github.com/home-assistant/core synced 2024-10-07 10:13:38 +02:00

Add a device to the sun (#90517)

This commit is contained in:
Franck Nijhof 2023-03-30 16:38:35 +02:00 committed by GitHub
parent 87c4659520
commit cf628dbf23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,8 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import DEGREE
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
@ -126,6 +128,12 @@ class SunSensor(SensorEntity):
self._attr_unique_id = f"{entry_id}-{entity_description.key}"
self.sun = sun
self._attr_device_info = DeviceInfo(
name="Sun",
identifiers={(DOMAIN, entry_id)},
entry_type=DeviceEntryType.SERVICE,
)
@property
def native_value(self) -> StateType | datetime:
"""Return value of sensor."""