SonoffLAN
SonoffLAN copied to clipboard
climate entity for Sonoff TRVZB
Added climate entity hvac mode now works like presets (off = off, heat = manual, auto = auto) fixed Child Lock and Window Switch
Why did you create a custom BoolSwitch? What's the problem with the one that was?
Why did you create a custom BoolSwitch? What's the problem with the one that was?
XBoolSwitch always toggle "switch" param. But childLock should use childLock param and windowSwitch should change windowSwitch.
Logic say it should be "switch" by default or self.param if self.param is set.
class XBoolSwitch(XEntity, SwitchEntity):
params = {"switch"}
def set_state(self, params: dict):
self._attr_is_on = params["switch"]
async def async_turn_on(self, *args, **kwargs):
await self.ewelink.send(self.device, {"switch": True})
async def async_turn_off(self):
await self.ewelink.send(self.device, {"switch": False})
class XBoolSwitchTRVZB(XEntity, SwitchEntity):
params = {}
def set_state(self, params: dict):
self._attr_is_on = params[self.param]
async def async_turn_on(self, *args, **kwargs):
await self.ewelink.send(self.device, {self.param: True})
async def async_turn_off(self):
await self.ewelink.send(self.device, {self.param: False})
class XBinarySensor(XEntity, BinarySensorEntity):
default_class: str = None
def __init__(self, ewelink: XRegistry, device: dict):
XEntity.__init__(self, ewelink, device)
device_class = device.get("device_class", self.default_class)
if device_class in DEVICE_CLASSES:
self._attr_device_class = DEVICE_CLASSES[device_class]
def set_state(self, params: dict):
self._attr_is_on = params[self.param] == 1
There is another question.
workState and workMode can have values '0' or '1' - string type, not integer. Seems like XBinarySensor is better for them.
It is possible to change last line in XBinarySensor ?
self._attr_is_on = (params[self.param] == 1) or (params[self.param] == '1')
depending on possibility of changing XBinarySensor code, I will push final TRVZB version with new XHexVoltageTRVZB class for runVoltage and BinarySensor for workMode
I don't see the reason to have sensors for work state and work mode.
I finish from my side. Everything works like expected. Please leave workstate sensor, to understand when head is changing the valve state.
I've made some changes. I hope I didn't break anything. Writing a converter for such a device blindly is, of course, very difficult.
https://github.com/AlexxIT/SonoffLAN/releases/tag/v3.9.0