Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

climate entity for Sonoff TRVZB #1569

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

climate entity for Sonoff TRVZB #1569

wants to merge 3 commits into from

Conversation

bob-tm
Copy link

@bob-tm bob-tm commented Jan 21, 2025

Added climate entity
hvac mode now works like presets (off = off, heat = manual, auto = auto)
fixed Child Lock and Window Switch

@AlexxIT
Copy link
Owner

AlexxIT commented Jan 22, 2025

Why did you create a custom BoolSwitch? What's the problem with the one that was?

@bob-tm
Copy link
Author

bob-tm commented Jan 22, 2025

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})

@AlexxIT AlexxIT self-assigned this Jan 22, 2025
@bob-tm
Copy link
Author

bob-tm commented Jan 22, 2025

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')

@bob-tm
Copy link
Author

bob-tm commented Jan 22, 2025

depending on possibility of changing XBinarySensor code, I will push final TRVZB version with new XHexVoltageTRVZB class for runVoltage and BinarySensor for workMode

@AlexxIT
Copy link
Owner

AlexxIT commented Jan 23, 2025

I don't see the reason to have sensors for work state and work mode.

@bob-tm
Copy link
Author

bob-tm commented Jan 26, 2025

I finish from my side. Everything works like expected. Please leave workstate sensor, to understand when head is changing the valve state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants