cyberjunky / home-assistant-custom-components

My custom components for Home Assistant
MIT License
71 stars 19 forks source link

set_operation_mode programOn & programOff #8

Closed RudolfRendier closed 4 years ago

RudolfRendier commented 6 years ago

I wanted to be able to tell Toon to resume it's normal program and I added the following to the toon.py climate-component.

        self._operation_list = ['Comfort', 'Home', 'Sleep', 'Away', 'Holiday', 'ProgramOn', 'ProgramOff']
    def set_operation_mode(self, operation_mode):
        """Set HVAC mode (comfort, home, sleep, away, holiday, programon, programoff)."""

        state = 2

        if operation_mode == "Comfort":
            mode = 0
        elif operation_mode == "Home":
            mode = 1
        elif operation_mode == "Sleep":
            mode = 2
        elif operation_mode == "Away":
            mode = 3
        elif operation_mode == "Holiday":
            mode = 4
        elif operation_mode == "ProgramOn":
            mode = -1
            state = 1
        elif operation_mode == "ProgramOff":
            mode = -1
            state = 0

        self._data = self.do_api_request(BASE_URL.format(
            self._host,
            self._port,
            '/happ_thermstat?action=changeSchemeState'
            '&state='+str(state)+'&temperatureState='+str(mode)))
        _LOGGER.debug("Set operation mode=%s(%s%s)", str(operation_mode),
                      str(state),str(mode))

ProgramOff disables Toon's program. ProgramOn re-enables it and activates the proper program according to Toon's schedule.

There's probably a more elegant way to solve this, but this works fine for me.

I could open a PR if that's helpful.

joostvanmourik commented 5 years ago

Thanx a lot for this, i use HomeAssistant to put Toon on Away if i leave home, but i like it to return to the programmed state when i'am ariving at home. This does the trick. Thanx

RudolfRendier commented 5 years ago

This code might interfere with Toon's schedule; it might skip programchanges shortly after a command from Home Assistant. Looking for a proper fix.

RudolfRendier commented 5 years ago

It seems that setting state = 2 locks Toon to the manual program and ignores its schedule for some time. state = 1 in the snippet above will do.

state = 2 is required to change the setting

cyberjunky commented 4 years ago

Is this still an issue? Shall I add an option in the config, to enable state 2 or 1 when switching modes?

joostvanmourik commented 4 years ago

Yes please 😀

Op wo 25 dec. 2019 15:16 schreef Ron Klinkien notifications@github.com:

Is this still an issue? Shall I add an option in the config, to enable state 2 or 1 when switching modes?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cyberjunky/home-assistant-custom-components/issues/8?email_source=notifications&email_token=AKUZIVONNTTN6ITUVPUH4KTQ2NTLXA5CNFSM4E7POVQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHUMTWI#issuecomment-568904153, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKUZIVIWQU233AFSYCPJITDQ2NTLXANCNFSM4E7POVQQ .

cyberjunky commented 4 years ago

I have coded this, but it turns out to behave exactly like the current thermostat uit/verwarmen off/heating does. I don't see what is different.

So in my code below you can switch off schedule with 'off' preset, and when pressing 'on' it resumes, or if you made manual changes to preset it jumps back to the pre-programmed schedule option, so if you manually put it on 'home' while thermostat was 'off' and you switch 'on', it jumps to 'away' if that was the schedule setting based on time.

You can find the code below, can you try it? So it gives your preset mode 'on' and 'off', viewable in device params, or mini-thermostat gui.

climate.py.txt

joostvanmourik commented 4 years ago

Will try to do this in the next couple of days. Let you know how it goes

Op do 11 jun. 2020 om 08:13 schreef Ron Klinkien notifications@github.com:

I have coded this, but it turns out to behave exactly like the current thermostat uit/verwarmen off/heating does. I don't see what is different.

So in my code below you can switch off schedule with 'off' preset, and when pressing 'on' it resumes, or if you made manual changes to preset it jumps back to the pre-programmed schedule option, so if you manually put it on 'home' while thermostat was 'off' and you switch 'on', it jumps to 'away' if that was the schedule setting based on time.

You can find the code below, can you try it? So it gives your preset mode 'on' and 'off', viewable in device params, or mini-thermostat gui.

climate.py.txt https://github.com/cyberjunky/home-assistant-toon_climate/files/4762909/climate.py.txt

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cyberjunky/home-assistant-custom-components/issues/8#issuecomment-642431996, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKUZIVI2G2V3QYRGQS5R6M3RWBYZ5ANCNFSM4E7POVQQ .

RudolfRendier commented 4 years ago

I don't think it's different from off/heating either, that works fine for me. The request was created over 2 years ago, long before HA's climate system was refactored (and this component with it)

Closing makes sense to me, but since @joostvanmourik might still have a use case I'll leave it up to him.