cyberjunky / home-assistant-toon_climate

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

How to use with Google Home/Assistant? #30

Closed jant90 closed 2 years ago

jant90 commented 3 years ago

I use my Toon in auto mode, so it follows its internal program and I'm using the simple-thermostat card in HA to make the occasional changes. All that has been working perfectly for the 8 months or so that I've been using HA. I'm now adding the Google Assistant integration to HA and I'm running into issues with the Toon.

I believe the main issue is that Google Home doesn't recognize the HVAC mode auto so it shows up as mode "Anders" within the Home app and in that mode it's not possible to change the setpoint (screenshow below), it just shows the current room temperature. Oddly enough, when issuing voice commands ("Hey Google, set Toon to XX degrees") it is possible to set the setpoint, but when using a command such as "Hey Google, raise Toon by 1 degree" the setpoint is set to 1 degree higher than the current room temperature instead of the current setpoint (probably because Google isn't aware of the current setpoint).

Screenshot_20210708-183454_Home Screenshot_20210708-183630_Home

If I change the operating mode inside Google Home to "Verwarmen" (= heat without program) or "Eco" (= eco/vacation mode) I'm able to see the current setpoint and room temperature but I don't want to use "Verwarmen" because it disables the internal program of my Toon.

I believe all my problems would be solved if Google saw auto mode as heat instead. Then Google would show the current setpoint and room temperature and all voice commands would work.

Is there any way I could achieve this? I would love to make a template climate of sorts (just like you can create template fans for example) that always is in heat mode and get the current room temperature and setpoint straight from this Toon Climate integration. I could expose the template climate to Google Home and get everything working but I don't think there is such a template climate option for HA.

rbak69 commented 3 years ago

Hi @jant90 thanks for the detailed information.

I had a similar experience when using Google Home. For some reason Google Home does not understand the "Auto" (Programma) but it is only offering the option “Heat” (Verwarmen) and "Eco".

I tried the Google Home app on my iPhone and I have discarded it as for me it adds no additional value compared to the Home Assistant app. The Home Assistant app provides all I need in one app including all the functionality of the Toon thermostat. Even better it shows all the details and supports all the different modes. Is there a reason why you prefer the Google Home app over the Home Assistant app?

To me it actually makes sense that in “Auto” mode the setpoint is set to 1 degree higher than the current room temperature when you ask the google assistant to raise by one degree. At the end you might feel a bit chilly and just want to raise the current temperature a bit. If you want to set it to a specific temperature you would just to instruct it to set the temperature to a certain value.

As I was interested to use the Toon in combination with Home Assistant I wanted to have both the HVAC modes "Auto" (Programma) and “Heat” (Verwarmen). I also wanted to have the option to (automatically) switch the Toon to Vacation mode and back to Auto when the vacation is over (why else do you integrate your thermostat with your home automation system). Unfortunately the Vacation mode was not really exposed and there was no real corresponding HVAC mode for this. Hence why I decided to use the PRESET mode “Eco” for this.

If you look at it from a Home Assistant point of view the Thermostat card now provides the correct modes that correspond with the operation mode of the Toon. In Auto mode it shows the calendar icon and the Heat modes shows a flame icon. And under the presets you now have an additional “Eco” preset that allows you to mimic the “Vacation” mode the Toon offers.

image image

In my opinion the custom integration now mimics the Toon in the most realistic way and provides access to nearly all the features.

Now coming back to your question can you create a custom Ton integration that uses the HVAC mode “Heat” for the Toon operation mode “Programma”. Yes you can and it is not even that difficult. But in my opinion it would mess up the actual Toon integration in Home Assistant.

I would argue with you when you say that in that case "all voice commands would work". As I like to be able to ask my google assistant to change the mode to “Automatisch” or to “Verwarmen” and that would no longer be possible in that case. Yes you would indeed be able to see and change the setpoint for the Toon in "Programma" mode using your Google Home app. But are we integrating with Google Home or with Home Assistant? I prefer it to show correctly in Home Assistant and I love the Home Assistant app that allows me to do all the things that you are “complaining” about with Google Home

By the way nothing stops you from downloading (or forking) the code and to manipulate the code so it functions the way you would like it to work. That is the beauty of open source!

By the way I am not 100% sure what you mean by the "template climate" at the bottom of your detailed explanation. Can you clarify what you mean by that?

jant90 commented 3 years ago

Thanks for your extensive reply @rbak69! I agree that the Google Home app is garbage for the most part (e.g. it combines all lights in the same room) and HA's Lovelace is better in every single way. I merely use Google Home to configure my devices for voice control through Google Assistant.

I use the simple-thermostat card in HA and for me that is just perfect, all preset accessible with a single press and changing the setpoint is very intuitive as well. This custom integration really elevates my Toon experience as it's just way better and faster than the official Toon app so I'm very happy with this!

It just seems that our opinions on the proper interpretation of the voice commands differ. All types of thermostats (analog, digital, smart) that I know for all the years that we use them are controlled by setting a desired temperature, the setpoint. For me it makes the most sense that the next step in manually controlling them (voice commands) this remains the same, this is of course already the case when issuing commands such as "Google, set Toon to XX degrees", but when using relative commands (i.e. "Google, increase Toon by 1 degree") this should still control the thermostat (the setpoint). Unless you say something like "Google, increase the temperature by 1 degree in here". Anyways, that's just my view on it and it's OK that we differ on that of course, I remain a very happy user of this integration haha! :)

What I mean by "template climate" is that HA allows users to "template" entities in certain domains in configuration.yaml, e.g. it's possible to template a fan that gets the current fan values through templating and makes service calls to control whatever you want, however you want. I wish something similar would be possible for a thermostat, then I would template a thermostat that would basically act as a proxy for the Toon, while always being in heating mode. The current room temperature and setpoint can be read through templating from this Toon integration and changing the setpoint can be done by calling service climate.set_temperature. I would then expose this template climate entity to Google Home (instead of the Toon entity) and get the voice control I want.

Of course there is no such template thermostat integration so when I have the time I'm gonna play around with the generic thermostat integration to see if I can let it act as a proxy by combining it with some automations that trigger when the setpoint changes for example. Or maybe even try it with the MQTT HVAC integration with some Node-RED logic. Or, now that I think of it, maybe it's entirely possible inside Node-RED with the right nodes.

jant90 commented 3 years ago

I got a working solution using the generic thermostat integration. I created a generic thermostat (named it Toon proxy) that gets the current room temperature from the Toon and made an automation that triggers on changes in the setpoint from either the Toon or the Toon proxy and syncs the setpoint to the other climate entity. I expose this 'Toon proxy' to Google Home and now I get the voice control that I was looking for.

In configuration.yaml:

climate:
  - platform: toon_climate
    name: Toon
  - platform: generic_thermostat
    name: Toon proxy
    heater: input_boolean.toon_proxy_heater
    target_sensor: sensor.toon_current_temperature
    initial_hvac_mode: "heat"
    min_temp: 6
    max_temp: 30
    precision: 0.5

template:
  - sensor:
      - name: toon_current_temperature
        unit_of_measurement: "°C"
        state: "{{ state_attr('climate.toon', 'current_temperature') }}"

google_assistant:
  report_state: true
  expose_by_default: false
  entity_config:
    climate.toon_proxy:
      name: Toon
      room: Woonkamer

And to sync the setpoint between the two climate entities I use the following automation:

- alias: Toon proxy helper
  trigger:
  - platform: state
    entity_id: climate.toon
    attribute: temperature
    id: toon_changed
  - platform: state
    entity_id: climate.toon_proxy
    attribute: temperature
    id: proxy_changed
  condition: []
  action:
  - choose:
    - conditions:
      - condition: trigger
        id: toon_changed
      sequence:
      - service: climate.set_temperature
        target:
          entity_id: climate.toon_proxy
        data:
          temperature: '{{ state_attr(''climate.toon'', ''temperature'') }}'
    - conditions:
      - condition: trigger
        id: proxy_changed
      sequence:
      - service: climate.set_temperature
        target:
          entity_id: climate.toon
        data:
          temperature: '{{ state_attr(''climate.toon_proxy'', ''temperature'') }}'
    default: []
  mode: single