Lots of changes and modernization. WIP
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import logging
|
||||
|
||||
from homeassistant.helpers.entity import Entity, async_generate_entity_id
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import (
|
||||
DOMAIN,
|
||||
@@ -15,6 +16,8 @@ from .const import (
|
||||
DATA_SETUP_COMPLETE,
|
||||
)
|
||||
|
||||
from .coordinator import Coordinator
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -69,6 +72,45 @@ def setup_platform(hass, config, async_add_devices, platform, cls):
|
||||
def is_setup_complete(hass):
|
||||
return hass.data[DOMAIN][DATA_SETUP_COMPLETE]
|
||||
|
||||
class BrowserModEntity2(CoordinatorEntity):
|
||||
|
||||
def __init__(self, coordinator, deviceID, name):
|
||||
super().__init__(coordinator)
|
||||
self.deviceID = deviceID
|
||||
self._name = name
|
||||
|
||||
@property
|
||||
def _data(self):
|
||||
return self.coordinator.data or {}
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self.deviceID)},
|
||||
"name": self.deviceID,
|
||||
"manufacturer": "Browser Mod",
|
||||
}
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
return {
|
||||
"type": "browser_mod",
|
||||
"deviceID": self.deviceID,
|
||||
}
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
@property
|
||||
def has_entity_name(self):
|
||||
return True
|
||||
@property
|
||||
def entity_registry_visible_default(self):
|
||||
return False
|
||||
@property
|
||||
def unique_id(self):
|
||||
return f"{self.deviceID}-{self._name.replace(' ','_')}"
|
||||
|
||||
|
||||
class BrowserModEntity(Entity):
|
||||
def __init__(self, hass, connection, deviceID, alias=None):
|
||||
|
||||
Reference in New Issue
Block a user