Integration for Watts Vision Smart Home System

I have found a small bug or change on the site of watts vision. At least the token could not be retrieved.

The token request needs to be the following:

payload = { 'client_id': client_id, 'grant_type': 'password', 'username': username, 'password': password }

I filled in the following information in secrets:

watts_vision_username: <e-mail address of user account>
watts_vision_password: <password>
watts_vision_client_id: "app-front"
watts_vision_url: "https://smarthome.wattselectronics.com"
watts_vision_smarthome_id: <smarthome_id found on website of wattselectronics.com>

It appears that the order is important and the client_id is in my case app-front instead of the real id. Offcourse if the client_id is always the same for everyone it needs to be hardcoded in the request. For now I kept it in de secrets file.

1 Like

Thatā€™s correct; the client ID is ā€œapp-frontā€. I chose to store all settings related to the Watts Vision login in the secrets file. Itā€™s a personal choice to hard-code some of these values.

2 Likes

some how its not working, can you post some kind of installation procedure

  1. What did you do so far?
  2. What kind of error do you see?
  3. Have you tested with Postman to retrieve an access token and send a request for the status? (https://web.postman.co)
  4. Do you have the AppDaemon 4 add-on running without errors?

the app is running in AppDeamon with your latest instructions. now it seems the mapping is incorrect:

2021-12-07 16:08:29.663294 WARNING get_watts_vision_status: get_watts_vision_status: Entity input_number.temperature_kantoor not found in namespace default
2021-12-07 16:08:29.705284 WARNING get_watts_vision_status: get_watts_vision_status: Entity input_number.set_temperature_kantoor not found in namespace default

First you need to create the input helpers for your values. Here are the ones I used:

After that you need to create template sensors in your configuration.yaml. Here are the ones I used:

- platform: template
  sensors:
    temperature_living_room:
      unique_id: sensor.temperature_living_room
      friendly_name: "Woonkamer Temperatuur"
      value_template: "{{ states('input_number.temperature_living_room') }}"
      device_class: temperature
      unit_of_measurement: "Ā°C"
    temperature_study_room:
      unique_id: sensor.temperature_study_room
      friendly_name: "Studeerkamer Temperatuur"
      value_template: "{{ states('input_number.temperature_study_room') }}"
      device_class: temperature
      unit_of_measurement: "Ā°C"
    temperature_guest_room:
      unique_id: sensor.temperature_guest_room
      friendly_name: "Logeerkamer Temperatuur"
      value_template: "{{ states('input_number.temperature_guest_room') }}"
      device_class: temperature
      unit_of_measurement: "Ā°C"
    temperature_bath_room:
      unique_id: sensor.temperature_bath_room
      friendly_name: "Badkamer Temperatuur"
      value_template: "{{ states('input_number.temperature_bath_room') }}"
      device_class: temperature
      unit_of_measurement: "Ā°C"
    temperature_bed_room:
      unique_id: sensor.temperature_bed_room
      friendly_name: "Slaapkamer Temperatuur"
      value_template: "{{ states('input_number.temperature_bed_room') }}"
      device_class: temperature
      unit_of_measurement: "Ā°C"
    temperature_attic_room:
      unique_id: sensor.temperature_attic_room
      friendly_name: "Opslagkamer Temperatuur"
      value_template: "{{ states('input_number.temperature_attic_room') }}"
      device_class: temperature
      unit_of_measurement: "Ā°C"
    temperature_laundry_room:
      unique_id: sensor.temperature_laundry_room
      friendly_name: "Waskamer Temperatuur"
      value_template: "{{ states('input_number.temperature_laundry_room') }}"
      device_class: temperature
      unit_of_measurement: "Ā°C"
    set_temperature_living_room:
      unique_id: sensor.set_temperature_living_room
      friendly_name: "Woonkamer Ingestelde Temperatuur"
      value_template: "{{ states('input_number.set_temperature_living_room') }}"
      device_class: temperature
      unit_of_measurement: "Ā°C"
    set_temperature_study_room:
      unique_id: sensor.set_temperature_study_room
      friendly_name: "Studeerkamer Ingestelde Temperatuur"
      value_template: "{{ states('input_number.set_temperature_study_room') }}"
      device_class: temperature
      unit_of_measurement: "Ā°C"
    set_temperature_guest_room:
      unique_id: sensor.set_temperature_guest_room
      friendly_name: "Logeerkamer Ingestelde Temperatuur"
      value_template: "{{ states('input_number.set_temperature_guest_room') }}"
      device_class: temperature
      unit_of_measurement: "Ā°C"
    set_temperature_bath_room:
      unique_id: sensor.set_temperature_bath_room
      friendly_name: "Badkamer Ingestelde Temperatuur"
      value_template: "{{ states('input_number.set_temperature_bath_room') }}"
      device_class: temperature
      unit_of_measurement: "Ā°C"
    set_temperature_bed_room:
      unique_id: sensor.set_temperature_bed_room
      friendly_name: "Slaapkamer Ingestelde Temperatuur"
      value_template: "{{ states('input_number.set_temperature_bed_room') }}"
      device_class: temperature
      unit_of_measurement: "Ā°C"
    set_temperature_attic_room:
      unique_id: sensor.set_temperature_attic_room
      friendly_name: "Opslagkamer Ingestelde Temperatuur"
      value_template: "{{ states('input_number.set_temperature_attic_room') }}"
      device_class: temperature
      unit_of_measurement: "Ā°C"
    set_temperature_laundry_room:
      unique_id: sensor.set_temperature_laundry_room
      friendly_name: "Waskamer Ingestelde Temperatuur"
      value_template: "{{ states('input_number.set_temperature_laundry_room') }}"
      device_class: temperature
      unit_of_measurement: "Ā°C"

Beside that you also need these binary sensors for the heating up flag:

- platform: template
  sensors:
    living_room_heating_up:
      unique_id: binary_sensor.living_room_heating_up
      friendly_name: "Woonkamer Opwarmen"
      value_template: "0"
    study_room_heating_up:
      unique_id: sensor.study_room_heating_up
      friendly_name: "Studeerkamer Opwarmen"
      value_template: "0"
    guest_room_heating_up:
      unique_id: sensor.guest_room_heating_up
      friendly_name: "Logeerkamer Opwarmen"
      value_template: "0"
    bath_room_heating_up:
      unique_id: sensor.bath_room_heating_up
      friendly_name: "Badkamer Opwarmen"
      value_template: "0"
    bed_room_heating_up:
      unique_id: sensor.bed_room_heating_up
      friendly_name: "Slaapkamer Opwarmen"
      value_template: "0"
    attic_room_heating_up:
      unique_id: sensor.attic_room_heating_up
      friendly_name: "Zolderkamer Opwarmen"
      value_template: "0"
    laundry_room_heating_up:
      unique_id: sensor.laundry_room_heating_up
      friendly_name: "Waskamer Opwarmen"
      value_template: "0"

After that it should workā€¦

1 Like

Yes it does, one down, 7 to go

THanks!

2 Likes

One question I have is why the red H/C led is flashing at the Watts module?

Ordered this unit last weekend and hoping to run this integration to control my heating from home assistant.

Unfortunately iā€™ve added the panel yesterday and the app is still showing " Your Central unit(s) is empty, please configure your Central unit(s)"

Iā€™ve setup my 6 zone master and all the rooms yesterday, but they still donā€™t show up in the app. Did anyone else experience this during setup?

You have to add the devices to the Central Unit in a pre-defined order:
1.) First you need to pair your submodule(s) with your master module.
2.) Second you need to pair your themostat(s) with the module(s).
3.) Finally you need to pair your module(s) with the Central Unit.

See ā€œType 4ā€ on page 5 of the manual of the Central Unit and pages 6 to 9 of the manual of the module.

Thanks that didnā€™t turn out to be the problem, but I think i found it.

I only have one 6 zone master, which was already paired to the each room thermostat when I moved into the house. Since I wanted to have more control I bought the wifi unit and tried adding that.

As my 6 zone master is located behind my fridge and washing machine I set up wifi before pairing it to the master. It then showed up without any zones, obviously.

Later I moved the washing machine and managed to pair the master and wifi unit. I then named all the zones correctly, but the zones wouldnā€™t show up in the app.

I then deleted the device, but didnā€™t disable wifi, and re-added it with a new pairing code from the app. It still didnā€™t show any zones, even after waiting for a day. But it did show the unit

Finally I deleted the wifi setup and re-entered it, then re-paired it for the 3rd time with cloud. Then it almost instantly showed all zones.

My guess is, that the unit posts itā€™s configuration when added to wifi. And the code is only used for coupling your unit, to your account. So if your unit is connected to the internet before being fully configurated, it doesnt take in changes made after being connected to wifi.

Thanks for sharing! I had to make sure the names are correct because of the prefix in the code but after I noticed that it worked like a charm.

1 Like

After some tinkering Iā€™m able to update the set temperature of the thermostatā€™s as wel

class UpdateWattsThermostatSetting(hass.Hass):

  def initialize(self):
    self.listen_state(self.value_changed, "input_number.set_temperature_living_room")
    self.listen_state(self.value_changed, "input_number.set_temperature_study_room")
    self.listen_state(self.value_changed, "input_number.set_temperature_guest_room")
    self.listen_state(self.value_changed, "input_number.set_temperature_bath_room")
    self.listen_state(self.value_changed, "input_number.set_temperature_bed_room")
    self.listen_state(self.value_changed, "input_number.set_temperature_attic_room")

  def value_changed(self, entity, attribute, old, new, kwargs):
    #device id's can be seen in the network tab of the browser developer tools, or 
    #by using the api's read method
    self.device_id = "C001-000" 
    if entity == "input_number.set_temperature_study_room":
      self.device_id = "C002-001"
    if entity == "input_number.set_temperature_guest_room":
      self.device_id = "C003-002"
    if entity == "input_number.set_temperature_bath_room":
      self.device_id = "C004-003"
    if entity == "input_number.set_temperature_bed_room":
      self.device_id = "C005-004"
    if entity == "input_number.set_temperature_attic_room":
      self.device_id = "C006-005"
    
    new_fahrenheit = int((float(new) * 1.8 + 32) * 10)

    username = self.args['username']
    password = self.args['password']
    client_id = self.args['client_id']
    url = '{}/auth/realms/watts/protocol/openid-connect/token'.format(self.args['url'])
    payload = { 'grant_type': 'password', 'username': username, 'password': password, 'client_id': client_id }
    request = requests.post(url = url, data = payload)
    request_status_code = request.status_code
    if request_status_code == 200:
      access_token = request.json()['access_token']
      self.set_thermostat_temperature(access_token = access_token, temperature_in_fahrenheit = new_fahrenheit)
    else:
      self.log('Fetching access token was unsuccessful.')
  
  def set_thermostat_temperature(self, access_token, temperature_in_fahrenheit):
    smarthome_id = self.args['smarthome_id']
    url = '{}/api/v0.1/human/query/push/'.format(self.args['url'])
    headers = { 'Authorization': 'Bearer {}'.format(access_token) }
    payload = { 'token': 'true', 'context': '1', 'smarthome_id': smarthome_id, 'query[id_device]': self.device_id, 'query[time_boost]': '0', 'query[consigne_confort]': temperature_in_fahrenheit, 'query[consigne_manuel]': temperature_in_fahrenheit, 'query[gv_mode]': '0', 'query[nv_mode]': '0', 'peremption': '20000', 'lang': 'nl_NL' }
    request = requests.post(url = url, headers = headers, data = payload)
    request_status_code = request.status_code
    if request_status_code != 200:
      self.log('Setting temperature was unsuccessful. Http error: {}'.format(request_status_code))

I tried to create an integration for Watts. I only have a limited number of devices so I donā€™t know if it will work for other devices. Thereā€™s lots to do therefore only basic functionality. Besides that I find the watts api is unstable and is regurlaly unavailable. Use at your own risk. Source code at https://github.com/pwesters/watts_vision

6 Likes

Thanks! Working for me.

Hi, I have HASS now for 2 days, so itā€™s all VERY new to me

Iā€™ve tried to set everything up according to the posts above, but iā€™m getting the following errors and i hope thereā€™s someone who could help me to getting it to work:

2022-03-02 18:00:21.024459 WARNING watts: Unexpected error in worker for App watts:
2022-03-02 18:00:21.025372 WARNING watts: Worker Ags: {'id': '03a8f434bfa94d909341ded7fcf9d3ca', 'name': 'watts', 'objectid': 'ea99b53a089e425da6c74151d55a933b', 'type': 'scheduler', 'function': <bound method GetWattsVisionStatus.fetch_token of <GetWattsVisionStatus.GetWattsVisionStatus object at 0x7f82d4de20>>, 'pin_app': True, 'pin_thread': 1, 'kwargs': {'interval': 120, '__thread_id': 'thread-1'}}
2022-03-02 18:00:21.026818 WARNING watts: ------------------------------------------------------------
2022-03-02 18:00:21.029558 WARNING watts: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/appdaemon/threading.py", line 904, in worker
    funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
  File "/config/appdaemon/apps/GetWattsVisionStatus.py", line 9, in fetch_token
    username = self.args['username']
KeyError: 'username'

These errors are a result from attempting to add the script higher up.

I tried the package from pwesters as well.
the automatic installation didnā€™t work, so I tried the manual one.
After copying the files, the app didnā€™t show up in Add Integration

Just now i checked the system again and Watts vision now appeared as an option.
Not sure why, but all seems to be working fine now.

I have the same issue as you describe, however Iā€™m not able to see any zones in the app. Also tried deleting the unit from the app, deleting the WiFi config and adding it again and requesting a new pairing code :frowning:
Any more pointers?

I got in touch with Watts technical support and apparently I had a quite new firmware that was not fully supported yet by there backendā€¦
They fixed it and I can see all the zones in my app so next step will be to use Paul his integration :slight_smile: