Use attributes octoprint (#58241)

This commit is contained in:
Marc Mueller 2021-10-22 21:41:06 +02:00 committed by GitHub
parent b0b49c611e
commit 823ca7ee40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 60 deletions

View file

@ -52,9 +52,9 @@ class OctoPrintBinarySensorBase(CoordinatorEntity, BinarySensorEntity):
) -> None:
"""Initialize a new OctoPrint sensor."""
super().__init__(coordinator)
self._name = f"Octoprint {sensor_type}"
self.sensor_type = sensor_type
self._device_id = device_id
self._attr_name = f"Octoprint {sensor_type}"
self._attr_unique_id = f"{sensor_type}-{device_id}"
@property
def device_info(self):
@ -65,16 +65,6 @@ class OctoPrintBinarySensorBase(CoordinatorEntity, BinarySensorEntity):
"name": "Octoprint",
}
@property
def unique_id(self):
"""Return a unique id."""
return f"{self.sensor_type}-{self._device_id}"
@property
def name(self):
"""Return the name of the sensor."""
return self._name
@property
def is_on(self):
"""Return true if binary sensor is on."""