claudegel / sinope-gt125

Sinope custom component for Home Assistant to manage Sinopé devices directly via the GT125 gateway
GNU General Public License v3.0
16 stars 4 forks source link
home-assistant home-automation homeassistant sinope

This repository has been split up into two.

If you already use this custom_component, make a backup of your file devices.json before first update via HACS. Devices.json will be removed. You'll need to copy your devices data to config/.storage/sinope_devices.json after first run of device.py (see below).

Home Assistant Sinope Custom Components (sinope-gt125)

Here is a custom component to suport Sinopé technologies devices in Home Assistant via a direct connection to the GT125 router from Sinopé Technologies to interact with their smart devices like thermostats, light switches/dimmers and load controllers. It also supports some devices made by Ouellet.

Supported Devices

Here is a list of currently supported devices. Basically, it's everything that can be added in Neviweb.

*Not tested, but should be working well. Your feedback is appreciated if a device doesn't work.

Prerequisite

You need to connect your devices to your GT125 web gateway before being able to interact with them within Home Assistant. Please refer to the instructions manual of your device or visit Neviweb support.

There are two custom component giving you the choice to manage your devices via the neviweb portal or directly via your GT125 gateway:

You need to install only one of them but both can be used at the same time on HA.

Installation (see custom_components/GT125_connect.md for more specific info)

There are two methods to install this custom component:

Configuration

To enable Sinope management in your installation, add the following to your configuration.yaml file, then restart Home Assistant.

# Example configuration.yaml entry
sinope:
  server: "<Ip adress of your GT125>"
  id: "<ID written on the back of your GT125>" no space
  api_key: "<Api_key received on first manual connection with the GT125>" #run device.py for that
  server_2: "<Ip adress of your second GT125>" <Optional>
  id_2: "<ID written on the back of your second GT125>" <Optional> no space 
  api_key_2: "<Api_key received on first manual connection with the second GT125>" <Optional> #run device.py for that 
  my_city: "<the nearest city>" # ex. 'Montreal', needed to get sunrise and sunset hours for your location. <Optional>
  scan_interval: 120 #you can go down to 60 if you want depending on how many devices you have to update. Default set to 180 <Optional>

Make sure the parameters are between quotation mark "" except for the scan_interval which is a number.

DK_KEY and MY_WEATHER parameter have been removed.

First run

To setup this custom_component, login via ssh to your Rpi and cd to the directory config/custom_components/sinope, where you have copied the files. Or use the package «advanced ssh & Web Terminal» to get a terminal inside HA (prefered method). You will need to have the following data handy: On start device.py will ask which GT125 you want to configure; server #1 or server #2

Execute the command: 'python3 device.py' in console (for python3.10: 'python3.10 device.py'). Sudo is required for file permission fix. In homeassistant-supervised (Hass.io) you don't need sudo. Make sure you are in the config/custom_components/sinope directory when you run device.py or it won't run. Running device.py is required to install the data above and to get the Api_Key and later the deviceID for each Sinopé devices connected to your GT125. On first run, device.py ask for IP, Api ID and port number then send a ping request to the GT125. It will then ask you to push de "WEB" button on the GT125. This will give you the Api Key.

You're ready to setup your Sinopé devices. I've put lots of comment in the code so I think you will understand.

Main difference with Neviweb is that with the GT125 we don't have command to request all data and info from one device at once. We need to issue one data read request for each info or data we want. ex:

This is the same for data write request but in that case we normally send one data like changing temperature or mode to one device. One exception is when we sent request to change mode to auto. We need to send correct time prior to send write request for auto mode.

For the data report request it is possible to send data to all device at once by using a special deviceID = FFFFFFFF, using the service sinope.set_outside_temperature and entity_id: all, this special deviceID will be picked automatically to send outside temperature to all thermostats. To send time, date, sunset and sunrise hour, just use the service set_xxxx_basic_data with any device to broadcast to all device at once. To set all device to away mode, use PRESET_AWAY in climate.set_preset_mode, away mode is broadcasted to all devices.

Devices discovery

Look like the GT125 use a different deviceID then the Neviweb portal. Once you have your Api_key written in sinope_devices.json, you will need to run device.py to request deviceID for each devices on your network one by one. The program will wait for you to push on both button of your device to revceive there deviceID. Then, device.py will ask for device data like name, type and connected watt load. To get the list of devices types just type "h" when asked for device type. This will display all known types and then ask for your device type. If you don't have all information just hit enter to leave those fields blank. It will be possible to add missing data later. All devices ID and data will be written in the file 'config/.storage/sinope_devices.json' or 'config/.storage/sinope_devices_2.json' to insure that any new update won't overwrite it. Once you have all your devices, hit "q" at the end to quit the program. Edit 'config/.storage/sinope_devices.json' and add the name, type and wattage (for light devices) for each devices if needed. Light connected watt load is not measured by the light devices but instead written in Neviweb devices on setup of light devices. We need to write it to 'config/.storage/sinope_devices.json' (kind of Neviweb portal equivalent) to finish the devices setup. ex:

["IP", "Api Key", "Api ID", "PORT"] <- do not erase this line
["id", "name", "type", "watt"] <- do not erase or edit this line
["00470100", " ", " ", " "] <- once discovered by device.py, add devices info between the " "
["2e320100", "Office heating", "10", " "] <- thermostat ex.
["5a2c0100", "Office light", "102", "60"] <- light ex.
["6a560100", "Outside timer", "120", " "] <- power control ex.
["00470100", "Dimmer TV Room", "112", "110"] <- Dimmer ex.

For power switch devices, RM3250RF and RM3200RF, you need to push on the top blue ligth (with the wifi logo) to get the deviceID. Each time you will add a new device to your GT125 you will need to run that device.py setup.

Custom services

Automations require services to be able to send commande. Ex. light.turn_on. For the Sinopé devices connected via GT125 it is possible to use custom services to send specific information to devices or to change some devices parameters. Those custom services can be accessed via development tool/services or can be used in automation:

You can also post in one of those threads to get help:

Turning on Sinope debug messages in home-assistant.log file

To have a maximum of information to help you, please provide a snippet of your home-assistant.log file. I've added some debug log messages that could help diagnose the problem.

Add thoses lines to your configuration.yaml file

   logger:
     default: warning
     logs:
       custom_components.sinope: debug

This will set default log level to warning for all your components, except for Sinope which will display more detailed messages.

Sending outside temperature to thermostats

Before using this service you must set the second display setting for each thermostats you want outdoor temperature to be displayed. This is done via dev tool only once with service sinope.set_second_display. After you just need to create and automation that will send that outside temperature to your thermostats every hour or more frequently is you wish. The temperature must be sent at least onece per hour or thermostat will revert to setpoint temperature display. Automation example:

#################################
###       Send outside temperature to thermostats
#################################
  - id: hourly outside temp
    alias: send outside temperature
    initial_state: true
    trigger:
      platform: time_pattern
      minutes: "/59"  ## intervall to send data every hours ajust as needed
    action:
      - service: climate.set_outside_temperature
        data_template:
          entity_id: climate.sinope_climate_office  ## you can add many devices to be updated at once or a group of devices
          outside_temperature: "{{ state_attr('weather.openweathermap', 'temperature') }}"

you can use any temperature provider; Openweathermap, Environment canada, even an ouside sensor that give you your local temperature.

Customization

Install Custom-Ui custom_component via HACS and add the following in your code:

Icons for heat level: create folder www in the root folder .homeassistant/www copy the six icons there. You can find them under local/www feel free to improve my icons and let me know. (See icon_view2.png)

For each thermostat add this code in customize.yaml

climate.sinope_climate_thermostat_name:
  templates:
    entity_picture: >
      if (attributes.heat_level < 1) return '/local/heat-0.png';
      if (attributes.heat_level < 21) return '/local/heat-1.png';
      if (attributes.heat_level < 41) return '/local/heat-2.png';
      if (attributes.heat_level < 61) return '/local/heat-3.png';
      if (attributes.heat_level < 81) return '/local/heat-4.png';
      return '/local/heat-5.png';

In configuration.yaml add this

customize: !include customize.yaml

Floorplan

Under www/floorplan you will find what can be done to add Sinopé devices in your floorplan with the icons you need in svg format. My floorplan was created with inkscape and I use the same icon used for thermostat customisation.

Current Limitations

TO DO

Contributing

You see something wrong or something that could be improved? Don't hesitate to fork me and send me pull requests.

Buy me a coffee

If you want to make donation as appreciation of my work, you can do so via PayPal. Thank you! Support via PayPal