1 """Support for 1-Wire entities."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
9 from pyownet
import protocol
15 from .const
import READ_MODE_BOOL, READ_MODE_INT
18 @dataclass(frozen=True)
20 """Class describing OneWire entities."""
22 read_mode: str |
None =
None
25 _LOGGER = logging.getLogger(__name__)
29 """Implementation of a 1-Wire entity."""
31 entity_description: OneWireEntityDescription
32 _attr_has_entity_name =
True
36 description: OneWireEntityDescription,
38 device_info: DeviceInfo,
40 owproxy: protocol._Proxy,
42 """Initialize the entity."""
48 self.
_state_state: StateType =
None
54 """Return the state attributes of the entity."""
61 """Read a value from the server."""
63 return read_bytes.decode().lstrip()
66 """Write a value to the server."""
70 """Get the latest data from the device."""
73 except protocol.Error
as exc:
75 _LOGGER.error(
"Error fetching %s data: %s", self.
namename, exc)
81 _LOGGER.debug(
"Fetching %s data recovered", self.
namename)
dict[str, Any]|None extra_state_attributes(self)
None __init__(self, OneWireEntityDescription description, str device_id, DeviceInfo device_info, str device_file, protocol._Proxy owproxy)
None _write_value(self, bytes value)
str|UndefinedType|None name(self)