Heat Cool Generic thermostat

I managed to modify the generic thermostat code to work in Cool, Heat mode in the same instance. I thought it would help.

Example configuration:

climate:
- platform: thermostat
name: Thermostat
heater: switch.heater
cooler: switch.ac
target_sensor: sensor.living_room_sensor
min_temp: 60
max_temp: 85
target_temp: 70
ac_mode: False
away_temp: 70
initial_operation_mode: “off”
hot_tolerance: 0.5
cold_tolerance: 0.5
min_cycle_duration:
minutes: 2

thermostat.py

10 Likes

This is great.
Now I don’t need two thermostats for the fan and a floor heated for a room.

Thanks

Did you set up the thermostat as a custom component with your modified code?

yes, i added to the config folder/custom_components/climate/thermostat.py

1 Like

Nice! I’m going to have to try this. I was always annoyed with needing 2 generic thermostats for heating and cooling.

Can you submit this to the official project? I think it could be a great addition.

1 Like

I would definitely try. I just don’t think i have the time to do all the steps required for a pull request

1 Like

What dictates when the thermostat goes from “heat mode” to “cool mode”? I took a look at the code, but I am having trouble figuring it out. Thanks.

This doesnt have auto mode. It just lets you have cool and heat on the same component. The original generic thermostat would only support 1 mode per component

2 Likes

I have restarted home assistant with this file in place. This is what I have in my config file (2 generic_thermostat platforms and the new thermostat as the 3rd platform:

climate:
  - platform: generic_thermostat
    name: Finishing Room
    heater: switch.finishing_room_heater_eufy
    target_sensor: sensor.shop_finishing_room_temperature
    min_temp: 50
    max_temp: 75
    ac_mode: False
    # target_temp: 70
    cold_tolerance: 0.5
    hot_tolerance: 0.5
    min_cycle_duration:
      seconds: 5
    keep_alive:
      minutes: 5
    initial_operation_mode: "auto"
    away_temp: 62
    precision: 0.1

  - platform: generic_thermostat
    name: Basement
    heater: switch.basement_heater_eufy
    target_sensor: sensor.basement_average_temperature
    min_temp: 50
    max_temp: 75
    ac_mode: False
    # target_temp: 70
    cold_tolerance: 0.5
    hot_tolerance: 0.5
    min_cycle_duration:
      seconds: 5
    keep_alive:
      minutes: 5
    initial_operation_mode: "auto"
    away_temp: 55
    precision: 0.1

    ##### This requires a custom_component in order to control AC & Heat with a single thermostat component --> thermostat.py
  - platform: thermostat
    name: Shop Thermostat
    heater: switch.shop_heater
    cooler: switch.shop_ac_insight
    target_sensor: sensor.shop_average_temperature
    min_temp: 50
    max_temp: 75
    target_temp: 70
    ac_mode: False
    away_temp: 62
    initial_operation_mode: “off”
    hot_tolerance: 0.5
    cold_tolerance: 0.5
    min_cycle_duration:
      minutes: 2

When I check my config I get an error that says:

Platform not found: climate.thermostat

I think you would have to make sure on which config folder home assistant is using and that its inside the climate folder. If that didnt work, try putting it in the same folder as all the other built in climate components

I also can’t make this work. I get the following callback

2019-01-10 23:24:31 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.climate.generic_thermostat. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/loader.py", line 92, in get_component
module = importlib.import_module(path)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 673, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/homeassistant/.homeassistant/custom_components/climate/generic_thermostat.py", line 25, in <module>
from homeassistant.helpers.restore_state import async_get_last_state
ImportError: cannot import name 'async_get_last_state'

I think it’s looking for a dependency.
a

I think other people are having the same issue with an upgraded version of homeassistant. Maybe you want to take a look here Updated to 0.84.2 Problem loading custom components

This is great cause I stopped using generic thermostat and moved to manual automations just for that reason I had to make two generic thermostats for every AC

But I’m confused from few latest posts, does version in first post works with home assistant v0.85.0?

I am currently using homeassistant 81.1 and i think the newer versions broke it. I will update the file and maybe make a proper repo for it. I will post the link here when its ready.

1 Like

Great to hear! I’ll downgrade mine to 0.81.1 and see if i manage to not break anything else!

Looking forward to an update on this component!

a

Is the link the to repo posted for this? I was keen to give it a rip. But I can’t tell if it was updated after the last comments. :slight_smile:

Unfortunately not. I didnt get a chance to work on.

ImportError: cannot import name ‘STATE_HEAT’ with the latest update. Anything fixable? I really hope this mod can make it into the repo.

I think the fix for it is fairly simple. I just really dont have the time to upgrade my system to test it. Taking it to the main repo is also kinda hard because I would need to create a lot of tests.