Fix some sensor classes (#48254)

* Fix some sensor classes

* Tweak

* Tweak
This commit is contained in:
Erik Montnemery 2021-03-23 15:56:33 +01:00 committed by GitHub
parent 6932cf9534
commit a09c8eecb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 88 additions and 61 deletions

View file

@ -1,4 +1,6 @@
"""Support for 1-Wire environment sensors."""
from __future__ import annotations
from glob import glob
import logging
import os
@ -394,7 +396,16 @@ def get_entities(onewirehub: OneWireHub, config):
return entities
class OneWireProxySensor(OneWireProxyEntity, SensorEntity):
class OneWireSensor(OneWireBaseEntity, SensorEntity):
"""Mixin for sensor specific attributes."""
@property
def unit_of_measurement(self) -> str | None:
"""Return the unit the value is expressed in."""
return self._unit_of_measurement
class OneWireProxySensor(OneWireProxyEntity, OneWireSensor):
"""Implementation of a 1-Wire sensor connected through owserver."""
@property
@ -403,7 +414,7 @@ class OneWireProxySensor(OneWireProxyEntity, SensorEntity):
return self._state
class OneWireDirectSensor(OneWireBaseEntity, SensorEntity):
class OneWireDirectSensor(OneWireSensor):
"""Implementation of a 1-Wire sensor directly connected to RPI GPIO."""
def __init__(self, name, device_file, device_info, owsensor):
@ -431,7 +442,7 @@ class OneWireDirectSensor(OneWireBaseEntity, SensorEntity):
self._state = value
class OneWireOWFSSensor(OneWireBaseEntity, SensorEntity): # pragma: no cover
class OneWireOWFSSensor(OneWireSensor): # pragma: no cover
"""Implementation of a 1-Wire sensor through owfs.
This part of the implementation does not conform to policy regarding 3rd-party libraries, and will not longer be updated.