Change Entity.name default to UNDEFINED (#94574)

* Change Entity.name default to UNDEFINED

* Update typing

* Update Pylint plugin

* Update TTS test
This commit is contained in:
Erik Montnemery 2023-06-15 11:09:53 +02:00 committed by GitHub
parent d369d679c7
commit 334dacc322
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 277 additions and 67 deletions

View file

@ -115,10 +115,15 @@ class CupsSensor(SensorEntity):
def __init__(self, data: CupsData, printer_name: str) -> None:
"""Initialize the CUPS sensor."""
self.data = data
self._attr_name = printer_name
self._name = printer_name
self._printer: dict[str, Any] | None = None
self._attr_available = False
@property
def name(self) -> str:
"""Return the name of the entity."""
return self._name
@property
def native_value(self):
"""Return the state of the sensor."""
@ -149,7 +154,6 @@ class CupsSensor(SensorEntity):
def update(self) -> None:
"""Get the latest data and updates the states."""
self.data.update()
assert self.name is not None
assert self.data.printers is not None
self._printer = self.data.printers.get(self.name)
self._attr_available = self.data.available