Integration for Watts Vision Smart Home System

Hello!

Is anyone working on integration for Watts Vision Smart Home thermostat?

http://wattswater.eu/catalog/regulation-and-control/watts-vision-smart-home/

Thanks,
Tamas

2 Likes

Not that I know off but i’m intressted.

I am also interested because I want to buy the Watts Vision : Contact | Watts Waterbeveiliging (watts-klimaatregeling.nl)

I am also interested because I own three Watts RF 868MHz Module 6 units and seven Watts Belux RF 868MHz thermostats. I would like to integrate them in Home Assistant. Now I am forced to use the Watts Vision Centrale Touchscreen Unit with WIFI to (remotely) control the thermostats.

Hi, I am also very interested. Is there maybe an update on this?

Same here. I’m close to installing this, but i’m hesitating because there is no integration with HA.

Well I can say that the Watts Vision system works great when you link all the devices in the correct order.

Good to know, but I also would like to have a integration in HA, so I can use it with several different sensors…

Yes, me too. But for now I can remotely control and program my thermostats with the Watts Vision Central Unit. It would be great if that could be done via Home Assistant so that I can build automations for it.

Can you access the Vision Central Unit via web as well, or do you need to use their iOS or Android app?

Yes, you can access it by using a browser as well; it’s an responsive web application.

1 Like

Any sucess on adding it to home assistant?

Well, I succeeded in reading out the temperature from one of my thermostats. But because the access token is refreshed each five minutes I am stuggeling to get a refresh for it in Home Assistant.

- platform: rest
  resource: https://smarthome.wattselectronics.com/api/v0.1/human/smarthome/read
  headers:
    Authorization: !secret watts_vision_token
    Content-Type: application/x-www-form-urlencoded
  method: POST
  payload: !secret watts_vision_payload
  value_template: "{{ ((value_json['data']['zones']['0']['devices']['0']['temperature_air'] | float / 10 - 32) / 1.8) | round(2) }}"
  name: "Woonkamer temperatuur"
  unit_of_measurement: "°C"

I have to manually paste the access token in the authorization header.

The token can be retrieved by doing a POST request to https://smarthome.wattselectronics.com/auth/realms/watts/protocol/openid-connect/token with HTTP body “grant_type=password&username=your username&password=your password&client_id=app-front”.

interested, since we have the same system

2 Likes

Yes, I know. Unfortunately I cannot see a simple manner to store the refresh token since an input helper can only store 255 characters.

Ok, I finally have got it working by using the AppDaemon add-on.

This is my app configuration:

get_watts_vision_status:
  module: get_watts_vision_status
  class: GetWattsVisionStatus
  username: !secret watts_vision_username
  password: !secret watts_vision_password
  client_id: !secret watts_vision_client_id
  url: !secret watts_vision_url
  smarthome_id: !secret watts_vision_smarthome_id

And this is the Python script I have made to set the value of the template sensors every two minutes:

import appdaemon.plugins.hass.hassapi as hass
import requests

class GetWattsVisionStatus(hass.Hass):
  def initialize(self):
    self.run_every(self.fetch_token, "now", 120)

  def fetch_token(self, kwargs):
    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.get_status(access_token = access_token)
    else:
      self.log('Fetching access token was unsuccessful.')

  def get_status(self, access_token):
    smarthome_id = self.args['smarthome_id']
    url = '{}/api/v0.1/human/smarthome/read'.format(self.args['url'])
    headers = { 'Authorization': 'Bearer {}'.format(access_token) }
    payload = { 'token': 'true', 'smarthome_id': smarthome_id, 'lang': 'nl_NL' }
    request = requests.post(url = url, headers = headers, data = payload)
    request_status_code = request.status_code
    if request_status_code == 200:
      result = request.json()
      code = result['code']['code']
      if code == '1':
        data_zones = result['data']['zones']
        self.set_temperature(zone= '0', helper = 'temperature_living_room', data = data_zones)
        self.set_temperature(zone= '1', helper = 'temperature_study_room', data = data_zones)
        self.set_temperature(zone= '2', helper = 'temperature_guest_room', data = data_zones)
        self.set_temperature(zone= '3', helper = 'temperature_bath_room', data = data_zones)
        self.set_temperature(zone= '4', helper = 'temperature_bed_room', data = data_zones)
        self.set_temperature(zone= '5', helper = 'temperature_attic_room', data = data_zones)
        self.set_temperature(zone= '6', helper = 'temperature_laundry_room', data = data_zones)
        self.set_heating_status(zone= '0', sensor = 'living_room_heating_up', data = data_zones)
        self.set_heating_status(zone= '1', sensor = 'study_room_heating_up', data = data_zones)
        self.set_heating_status(zone= '2', sensor = 'guest_room_heating_up', data = data_zones)
        self.set_heating_status(zone= '3', sensor = 'bath_room_heating_up', data = data_zones)
        self.set_heating_status(zone= '4', sensor = 'bed_room_heating_up', data = data_zones)
        self.set_heating_status(zone= '5', sensor = 'attic_room_heating_up', data = data_zones)
        self.set_heating_status(zone= '6', sensor = 'laundry_room_heating_up', data = data_zones)
      else:
        error_message = result['code']['value']
        self.log('Reading temperature was unsuccessful: {}'.format(error_message))
    else:
      self.log('Reading temperature was unsuccessful.')

  def set_temperature(self, zone, helper, data):
    temperature_in_fahrenheit = data[zone]['devices']['0']['temperature_air']
    temperature = self.calculate_fahrenheit_to_celsius_degrees(temperature_in_fahrenheit)
    self.set_value('input_number.{}'.format(helper), temperature)
    gv_mode = data[zone]['devices']['0']['gv_mode']
    if gv_mode == '11':
      set_temperature_in_fahrenheit = data[zone]['devices']['0']['consigne_eco']
    else:
      set_temperature_in_fahrenheit = data[zone]['devices']['0']['consigne_confort']
    set_temperature = self.calculate_fahrenheit_to_celsius_degrees(set_temperature_in_fahrenheit)
    self.set_value('input_number.set_{}'.format(helper), round(set_temperature * 2) / 2)

  def calculate_fahrenheit_to_celsius_degrees(self, temperature_in_fahrenheit):
    return round((float (temperature_in_fahrenheit) / 10 - 32) / 1.8, 2)

  def set_heating_status(self, zone, sensor, data):
    heating_up = data[zone]['devices']['0']['heating_up']
    self.set_state('binary_sensor.{}'.format(sensor), state = 'on' if heating_up == '1' else 'off')

I used this document to set it up: AppDaemon Tutorial for HASS Users — AppDaemon 4.1.0 documentation

Please feel free to contact me if you have any questions.

1 Like

Hello, I have a Watts system myself as well. Just started testing a Home Assistant server so not that trusted with the environment yet.

Any chance this is becomming an add-on soon? Cause it seems like some work at the moment to get this working?

Hiya, I copy pasted ur stuff and so far I don’t get any fault messages anymore.

But i get a message: “get_watts_vision_status: Fetching access token was unsuccessful.”
In my log.

And I can’t see any values. Where do i find this token and where to put it.

Thnx in advance :wink:

You do not need to store the access token. You need your username, password and client ID to retrieve the access token as well as your smart home ID for authentication.
The first two you already have to login into the Watts Vision app or web site. The client ID and smart home ID can be seen in the network tab of the browser developer tools (F-12 key) when you log in on the Watts Vision web site and inspect the http messages.

All these values I store in the secrets.yaml file and these will be used by the AppDaemon script to retrieve the access token.

The whole web API part I tested first in Postman.

When I do the F12 key thing I get this info:
data: {users: {0: {user_email: “[email protected]”, user_id: “1234”, user_token: “”,…}},…}

The URL I use = Watts Vision - Watts Electronics

Tonight or this weekend I’ll try to figure out what that postman is… :wink: … This stuff is fun, but kinda far from my comfort zone.