cyberjunky / home-assistant-toon_climate

This component provides a climate device for rooted Toon thermostats.
MIT License
32 stars 8 forks source link

Program on/ program off behaviour #19

Closed Peklaa closed 3 years ago

Peklaa commented 3 years ago

Very happy with this component! I experienced a flaw that may be resolved. Setting the state of the toon_thermostat entity toggles the program switch on the display of the Toon. That's great, works well. I saw this was addressed with issue #7 However, when I toggle the same switch manually on the Toon display, the state of the toon_thermostat entity doesn't follow. What I would expect is that the toon_thermostat entity in HA follows the state of the Toon display, just like it does for the presets and temperature setpoint attributes. I hope my post here is helpful, I really appreciate the work that's gone into this.

rbak69 commented 3 years ago

Hi I fully agree with you. I am also very happy with the work the author has put in this. And I was just about to add some improvement suggestions and this was my main improvement suggestion. It is a simple change to the code in the file "climate.py". After line 168 in the code I have added the following code:

        programstate = int(self._data["programState"])
        if programstate == 1 or programstate == 2:
            self._hvac_mode = HVAC_MODE_HEAT
        else:
            self._hvac_mode = HVAC_MODE_OFF

This validates the status of the Toon and if the programm state is switched on (values 1 or 2) it updates the HVVAC mode to HEAT and if switched off (value 0 or 4 for holiday) it updates the HVAC mode to OFF.

It is funny as last night I found there was new code since I last implemented this and went through te code. I made a few more cosmetical changes in what I have addded to my Home Assistant setup. I can confirm tha this resolves the issue you mentioned.

I have attached my slightly updated code to this response. So feel free to try it out and test it. Obviously remove the txt extension after downloading before yopu overwrite the old code ;-)

climate.py.txt

rbak69 commented 3 years ago

@Peklaa I have created an updated version of the code. The new code has now been reviewed and has been merged with the master. So the issue you reported should now be fixed with the latest version of the code that has been released today.

Please note that the new code now uses the HVAC modes HEAT (manual mode) and AUTO (scheduled mode) to correctly reflect the behavior of the Toon. I have also introduced the ECO preset to provide an option to set the Toon in "vacation" mode. The latter means it will set the setpoint to the value last used for the vacation option in the Toon. When eco (vacation) mode is active the Toon will no longer use the schedule but will ensure the temperature does not drop below the "vacation" setpoint. As soon as another preset is selected it ill return to the previous active work mode (HEAT/manual or AUTO/schedule).

cyberjunky commented 3 years ago

@rbak69 @Peklaa Too be honest looking at the latest changes, I was happy the way it worked for me, I want to simply hit 'Comfort' to give extra heat when I work home, but I also want it to go to 'Sleep' mode automatically after that, and now this behavior seems gone so when I forget to switch to Auto the heating is on high all night, correct? When I look at this description: (*) The above four presets can be used independent of the selected work mode. - When the Toon is set to "heat" mode the preset will change the setpoint to the setpoint configured for the respective preset. It will keep that setpoint until you change it manually or switch to "auto" mode - When the Toon is set to "auto" mode the preset will change the setpoint to the setpoint configured for the respective preset. However it will only change the setpoint temporatily until the schedule changes to the next programmed preset.

cyberjunky commented 3 years ago

@rbak69 @Peklaa Nevermind, it now works as intended (Version 1.0.9) It only stays on set temp when you choose Manual, on Auto it will still follows the schedule even if you set lower of increase set temp in between.

rbak69 commented 3 years ago

@cyberjunky no that is not correct.

When your Toon is in schedule mode (programma aan) you can temporarily overwrite the active preset with another preset. When the Toon is on scheduled mode and you hit "comfort", either on the Toon or in Home Assistant, it will change the preset to "comfort" until the next scheduled preset becomes active. So if that is "sleep" it will automatically change to the "sleep" preset based on the schedule.

When the Toon is in manual mode (programma uit) you can change the active preset with another preset. When the Toon is on manual mode and you hit "comfort", either on the Toon or in Home Assistant, it will change the preset to "comfort" and stay on that preset until you manually change it to another preset or when you change the Toon to scheduled mode.

I believe the schedule mode is exactly what you described. The latest code results in the Toon Climate component to behave in exactly the same way as the Toon itself. The only difference being (on purpose) is that in the “eco/vacation” mode Home Assistant will show the program mode to be on manual. This is because in vacation mode it will behave exactly as in “manual” mode. It will keep the same preset until another preset is selected, either on the Toon or in Home Assistant, or the vacation period as programmed in the Toon ends. When that happens it will show the correct work mode again (schedule or manual) based on the actual Toon status.

Please note that in the latest code I replaced de previous "hvac off" mode with the "hvac heat" mode and the previous "hvac heat" mode with the "hvac auto" mode. As the Toon does not have an "off" state where it does not do anything. It has a "manual" state (“hvac heat”) and a "schedule" state (“hvac auto”). In Home Assistant it now reflects the correct states. I guess this is where your confusion comes from.

By the way this issue raised by @Peklaa was about the status in Home Assistant not being updated when you manually update the mode from schedule to manual and vice versa. That issue is clearly fixed with the latest code. So I expect this issue can actually be closed.

cyberjunky commented 3 years ago

@rbak69 I guess our posts crossed each other, Version 1.0.9 should appear in HACS any time, I will close this issue, thanks.

Peklaa commented 3 years ago

Awesome! Just updated the add-on to 1.0.9 and now the state of the entity in HA does follow the "programma" toggle switch on the display. I agree that the states heat and auto better describe what the Toon is actually doing. Thank you @cyberjunky and @rbak69!

rbak69 commented 3 years ago

Hi @Peklaa glad you like my updates. You might want to update to version 1.0.10 that was released tonight. I made a few additional minor modifications. The modifications are mainly for the added vacation functionality (activated by the "eco" preset).

Peklaa commented 3 years ago

I'll do that, but I don't often use the vacation functionality. Instead of setting a date and time in the Toon for when I come back, I prefer to have an automation in HA put the Toon back in scheduled mode. Triggered for instance by being on the move and getting within a certain range of home.

What I was trying to achieve is a lovelace card that resembles the Toon display UI as much as possible, using the simple_thermostat custom card. Here, the fifth preset is a distraction, because the Toon display only shows four. But the card can be modified to only show the four.

To further improve my simple-thermostat custom card, I created a template switch that mimics the "programma" toggle switch on the Toon. This works nicely with the toggle_entity option for that card.

Perhaps it's useful to share. This is the yaml code for the switch:

switch:
  - platform: template
    switches:
      toon_program:
        friendly_name: Programma
        value_template: "{{ is_state('climate.toon_thermostaat', 'auto') }}"
        turn_on:
          service: climate.set_hvac_mode
          data:
            entity_id: climate.toon_thermostaat
            hvac_mode: auto
        turn_off:
          service: climate.set_hvac_mode
          data:
            entity_id: climate.toon_thermostaat
            hvac_mode: heat

And this is the yaml configuration for the simple_thermostat custom card I'm using:

type: 'custom:simple-thermostat'
entity: climate.toon_thermostaat
hide:
  state: true
control:
  preset:
    eco: false
    away:
      name: Weg
toggle_entity: switch.toon_program
label:
  temperature: Woonkamer
show_header: true
rbak69 commented 3 years ago

@Peklaa I understand your comment about the additional "eco" preset. I actually created another version of the code where I use the HVAC_MODE_OFF for the same purpose. But at the end I decided to stick with the HVAC_PRESET_ECO option.

I do not use the vacation mode much myself either. In theory you can achieve the same by putting it on "manual/heat" and set the target temperature to a desired setpoint. But since the Toon supports it and the display looks different I decided to add this. Just because we can ;-)

With the "simple-thermostat" I like to keep things minimalistic. So I display the normal presets but do not show the headings. As a result the thermostat card is a lot smaller. It also means that it would not show the button. But to be honest if needed I prefer to click on the temperature preset the odd time I need to change the work mode from "auto" to "manual" for instance.

However as I would like to be able to see what work mode the thermostat is in and for that reason I created the follwing sensor that I show on the "simple-thermostat" card.

sensor:
- platform: template
  sensors:
    toon_operation_mode:
      friendly_name: 'Status'
        value_template: >-
        {% if is_state('climate.toon_thermostaat','off') %}
          Vakantie
        {% elif is_state('climate.toon_thermostaat','heat') %}
          Handmatig
        {% elif is_state('climate.toon_thermostaat','auto') %}
          Programma
        {% endif %}

The sensor will tell you exactly whether it is in the "auto", "heat", or "off" state. It also allows you to show the state in your local language. Since I report the "vacation" mode as "off" you can also easily show this seperate state on the thermostat.

So in my case the "simple-thermostat" card will tell me at a glance whether the work mode is set to "Handmatig", "Programma" or "Vakantie".

As I basically just started using the "simple-thermostat" myself I will have a look at that in more detail later and I might add some additional information in the "README.md" and "info.md" files when I am satisfied with the end result.