Rheem Hotwater heater, econet?

Line 17 has a typo:

print("Vacation mode enabled?: water_heater.vacation_mode_enabled())

Should be:

print("Vacation mode enabled?: " + water_heater.vacation_mode_enabled())

Changed that and getting error:
$python test.py
Please vist the following URL to authenticate.
Traceback (most recent call last):
File “test.py”, line 2, in
print(pywink.get_authorization_url(“YOUR_CLIENT_ID”, “YOUR_REDIRECT_URL”))
NameError: name ‘pywink’ is not defined

Dang sorry, you need to import pywink lol.

At the top of the script add

import pywink

This is what happens when I don’t test the test script and don’t type it in a editor…

Traceback (most recent call last):
File “test.py”, line 1, in
import pywink
File “/home/midnight/waterheater/src/pywink/init.py”, line 5, in
from pywink.api import set_bearer_token, refresh_access_token,
File “/home/midnight/waterheater/src/pywink/api.py”, line 4, in
import urllib.parse
ImportError: No module named parse

Are you running this with python3?

Try running it with

python3 test.py

Also make sure you have requests installed.

pip3 install requests

That worked, got a response. I guess I need some credentials next.

$python3 test.py
Please vist the following URL to authenticate.
https://api.wink.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URL
Enter code from URL:

How are you authenticating to Wink now with HA? Username and password?

I updated the scripts above to just take a token, should be much easier. Get a token from here https://winkbearertoken.appspot.com and change the scripts to match the updated scripts above.

Just user name and password. I dont have a wink hub, so I just got the wink android app so I could get a login and help if needed.

Updated the script with my token.

Name: Heat Pump Water Heater Gen 4
State: eco
Modes: ['eco', 'heat_pump', 'high_demand', 'electric_only']
Traceback (most recent call last):
  File "test.py", line 10, in <module>
    print("Current set point: " + water_heater.current_set_point())
TypeError: Can't convert 'float' object to str implicitly

:frowning: sorry forgot to warp that call in a str() I updated the script again.

But on the positive side you got a response back from the API so it looks like everything is working from a object creation standpoint.

There were a few more str errors. I followed the patterns and added some str. This is the code I now have:

import pywink

pywink.set_bearer_token("***")

water_heaters = pywink.get_water_heaters()
for water_heater in water_heaters:
    print("Name: " + water_heater.name())
    print("State: " + water_heater.state())
    print("Modes: " + str(water_heater.modes()))
    print("Current set point: " + str(water_heater.current_set_point()))
    print("Max set point: " + str(water_heater.max_set_point()))
    print("Min set point: " + str(water_heater.min_set_point()))
    print("Is on?: " + str(water_heater.is_on()))
    print("Vacation mode enabled?: " + str(water_heater.vacation_mode_enabled()))
    print("Type: " + water_heater.rheem_type())

Which resulted in the response:

Name: Heat Pump Water Heater Gen 4
State: eco
Modes: ['eco', 'heat_pump', 'high_demand', 'electric_only']
Current set point: 50.55555555555556
Max set point: 60.0
Min set point: 43.333333333333336
Is on?: True
Vacation mode enabled?: False
Type: Heat Pump Water Heater

So…seeing as that worked. I created a changemode.py with the code you have:

import pywink

pywink.set_bearer_token("***")

water_heaters = pywink.get_water_heaters()
for water_heater in water_heaters:
    water_heater.set_temperature(35)
    water_heater.set_mode("high_demand")
    water_heater.set_vacation_mode(True)

Which resulted in:
Traceback (most recent call last):
File “change.py”, line 8, in
water_heater.set_mode(“high_demand”)
AttributeError: ‘WinkWaterHeater’ object has no attribute ‘set_mode’

I tried all the modes. They each responded the same.

Quick edit: I see the responses are in Celsius: 50.055 = 122 which is what I have set. Can that be changed for us…USA?

Man sorry I made this so difficult. Change the set_mode() to set_operation_mode() and try again.

So the API is in Celsius, but HomeAssistant converts all temperatures based on your config preferences. So if you have imperial set in your config for units or whatever it is call, the temperatures will be in Fahrenheit

No worries. Just look at it this way. Im totally lost when it comes to API stuff. so there’s probably tons of other people out there that are the same. By getting over all these little things now, saves the trouble on debugging later,

new code :

:import pywink

pywink.set_bearer_token("***")

water_heaters = pywink.get_water_heaters()
for water_heater in water_heaters:
    water_heater.set_temperature(55)
    water_heater.set_operation_mode("electric_only")
    water_heater.set_vacation_mode(true)

Nothing responded in terminal so I checked my wink app and it adjusted on the wink app! I checked my rheem app and that adjusted about 1min later.

It appears if you put it into vacationmode(true) it overrides all the other settings because it went into ecomode and down to 35c. So i changed water_heater.set_vacation_mode to (false) and it raised the temp and changed the mode!

YA…working code!

1 Like

Awesome! I’ll get this merged in later today. The new version of HA is getting released some time today so we won’t make it into that release but shouldn’t have any problem making it into the next release in 2 weeks.

Support will get added with this https://github.com/home-assistant/home-assistant/pull/9303

If you have the ability to test this, that would be awesome.

The steps to test are as follows.

HA_CONFIG_DIR = “The directory your homeassistant config is located in.”

create the following directories.
HA_CONFIG_DIR/custom_components/
HA_CONFIG_DIR/custom_components/climate

Place this file https://github.com/w1ll1am23/home-assistant/blob/64281c70c27ef110c18e6d2710ce98f77100cb3d/homeassistant/components/wink.py into HA_CONFIG_DIR/custom_components/

Place this file https://github.com/w1ll1am23/home-assistant/blob/64281c70c27ef110c18e6d2710ce98f77100cb3d/homeassistant/components/climate/wink.py into HA_CONFIG_DIR/custom_components/climate

Restart and wait as the new version of python-wink gets installed. Once HA is back up you should have a new climate device!

I am not sure how this will behave without the current temperature and I have set the climate away mode switch to toggle the vacation mode (hopefully)

Alrighty, got it up and connected. I added the wink: component with my username and PW, that did not initially take. It tossed out a few errors. But after I rebooted my PI i and HA restarted, it connected without issue. if you need the logs on that I can get them for you, it may have just been a configuration error on my side. I got a new entity climate.heat_pump_water_heater_gen_4 which i was able to add to my views.

These are its attributes:

current_temperature: null
operation_list: off,eco,heat_pump,high_demand,electric
max_allowed_temp: 60
unit_of_measurement: °F
min_temp: 45
max_temp: 95
min_allowed_temp: 43.333333333333336
rheem_type: Heat Pump Water Heater
vacation_mode: false
temperature: 110
friendly_name: Heat Pump Water Heater Gen 4
operation_mode: eco

I played around with it and found a few things.

  1. I cant set the temperature higher than 95. It my Wink app, its set at 110, In my rheem app its set at 121, which is displayed on my water heater. If I lower it in HA, neither wink nor rheem register the change. However, as you can see in the picture, the popup window says 95, but the component is at 110.

  2. Current Temp is not displayed

  3. The In the operation setting it defaults to “ECO” If I change it to something else, both rheem and wink register the change, yet this popup defaults back to “eco”

Anything else you want me to check for let me know! Thanks for working on this!

Awesome thanks, I’ll take a look at all this later tonight hopefully.

  1. I cant set the temperature higher than 95. It my Wink app, its set at 110, In my rheem app its set at 121, which is displayed on my water heater. If I lower it in HA, neither wink nor rheem register the change. However, as you can see in the picture, the popup window says 95, but the component is at 110.

This was a bug, I wasn’t setting the correct property if you look in the properties you sent there is a min and max temp they default to 45 and 95. I have corrected that in the newest file.

  1. Current Temp is not displayed
    This was expected since we don’t get it back from Wink (the current water temp) kinda looks strange but don’t think it can be removed in the GUI.

  2. The In the operation setting it defaults to “ECO” If I change it to something else, both rheem and wink register the change, yet this popup defaults back to “eco”

I am not sure what is causing this… in the drop down list you see all of the correct selections? Can you send me a screen shot of that and a log after you try to set it?

Newest file to test is here https://github.com/w1ll1am23/home-assistant/blob/c30533a4aa7e12b2f6a3df103d89b0ac368e5c72/homeassistant/components/climate/wink.py

Seems I’ve run into a new error. I enabled the wink componenet with my username and password. But im getting these errors:

Sep 14 21:57:58 homeassistant hass[2715]: #033[32m2017-09-14 21:57:58 INFO (MainThread) [homeassistant.setup] Setting up logger#033[0m
Sep 14 21:58:08 homeassistant hass[2715]: #033[31m2017-09-14 21:58:08 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved#033[0m
Sep 14 21:58:08 homeassistant hass[2715]: Traceback (most recent call last):
Sep 14 21:58:08 homeassistant hass[2715]: File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
Sep 14 21:58:08 homeassistant hass[2715]: result = next(coro)
Sep 14 21:58:08 homeassistant hass[2715]: File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 381, in async_process_entity
Sep 14 21:58:08 homeassistant hass[2715]: new_entity, self, update_before_add=update_before_add
Sep 14 21:58:08 homeassistant hass[2715]: File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 238, in async_add_entity
Sep 14 21:58:08 homeassistant hass[2715]: yield from entity.async_update_ha_state()
Sep 14 21:58:08 homeassistant hass[2715]: File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
Sep 14 21:58:08 homeassistant hass[2715]: state = self.state
Sep 14 21:58:08 homeassistant hass[2715]: File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/climate/__init__.py", line 412, in state
Sep 14 21:58:08 homeassistant hass[2715]: if self.current_operation:
Sep 14 21:58:08 homeassistant hass[2715]: File "/home/homeassistant/.homeassistant/custom_components/climate/wink.py", line 479, in current_operation
Sep 14 21:58:08 homeassistant hass[2715]: current_op = WINK_STATE_TO_HA.get(self.wink.current_hvac_mode())
Sep 14 21:58:08 homeassistant hass[2715]: AttributeError: 'WinkWaterHeater' object has no attribute 'current_hvac_mode'#033[0m

Sorry, I am doing a bit of refactoring as well for the other climate components and that was from a copy/paste error.

I updated the file. https://github.com/w1ll1am23/home-assistant/blob/aaff058771d5933b0ee7b36bb1dbf1cf510814b0/homeassistant/components/climate/wink.py

 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved#033[0m
Sep 14 22:22:34 homeassistant hass[3170]: Traceback (most recent call last):
Sep 14 22:22:34 homeassistant hass[3170]: File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
Sep 14 22:22:34 homeassistant hass[3170]: result = next(coro)
Sep 14 22:22:34 homeassistant hass[3170]: File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 381, in async_process_entity
Sep 14 22:22:34 homeassistant hass[3170]: new_entity, self, update_before_add=update_before_add
Sep 14 22:22:34 homeassistant hass[3170]: File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 238, in async_add_entity
Sep 14 22:22:34 homeassistant hass[3170]: yield from entity.async_update_ha_state()
Sep 14 22:22:34 homeassistant hass[3170]: File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 246, in async_update_ha_state
Sep 14 22:22:34 homeassistant hass[3170]: attr = self.state_attributes or {}
Sep 14 22:22:34 homeassistant hass[3170]: File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/climate/__init__.py", line 430, in state_attributes
Sep 14 22:22:34 homeassistant hass[3170]: ATTR_MAX_TEMP: self._convert_for_display(self.max_temp),
Sep 14 22:22:34 homeassistant hass[3170]: File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/climate/__init__.py", line 713, in _convert_for_display
Sep 14 22:22:34 homeassistant hass[3170]: raise TypeError("Temperature is not a number: %s" % temp)
Sep 14 22:22:34 homeassistant hass[3170]: TypeError: Temperature is not a number: 60.0#033[0m

Hmm, well that is going to require some investigation. That’s coming from the base climate component. I’ll take a look.

Can you run pylint on the wink.py file? I am not sure where the #033[0m at the end of the 60.0 wondering if it is some copy/paste error? Did you download this file the same way as you did before?