Remove redundant property definitions in Notion (#52367)

* Remove redundant property definitions in Notion

* Code review
This commit is contained in:
Aaron Bach 2021-07-01 04:24:19 -05:00 committed by GitHub
parent 2868fef7d4
commit 60ea219101
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 83 deletions

View file

@ -61,25 +61,15 @@ class NotionSensor(NotionEntity, SensorEntity):
coordinator, task_id, sensor_id, bridge_id, system_id, name, device_class
)
self._unit = unit
@property
def state(self) -> str:
"""Return the state of the sensor."""
return self._state
@property
def unit_of_measurement(self) -> str:
"""Return the unit of measurement."""
return self._unit
self._attr_unit_of_measurement = unit
@callback
def _async_update_from_latest_data(self) -> None:
"""Fetch new state data for the sensor."""
task = self.coordinator.data["tasks"][self.task_id]
task = self.coordinator.data["tasks"][self._task_id]
if task["task_type"] == SENSOR_TEMPERATURE:
self._state = round(float(task["status"]["value"]), 1)
self._attr_state = round(float(task["status"]["value"]), 1)
else:
LOGGER.error(
"Unknown task type: %s: %s",