Sinope Thermostat Support

Don’t know what you did but you only need to replace the file __init__.py in config/custom_components/sinope by the one you will find in the link I provided.

So you just need to open the __init__.py file in the link and select/copy all lines then open your config/custom_components/sinope/__ini__.py in your HA file editor, select all the lines and paste what you copy before then save and restart HA.

But first you need to check in configuration.yaml to find out if you have a bad character in your ID or api_key because the error you got previously ValueError: non-hexadecimal number mean that in those id and/or api_key you have an invalid character. Those two parameter should contain only numbers from 0 to 9 and / or letters from a to f. For example if you put a letter O instead of a number 0 you will get that type of error.

The file I’ve provided is to extract the data just where you get the error ValueError: non-hexadecimal number to find out where is the error in the parameters.

If you want you can go to GitHub - claudegel/sinope-gt125 at debug-data
there is a green button at the top labelled <> Code. Click and download the zip file. Open it and move the __init__.py file to replace the one you have in config/custom/components/sinope

Ok I had not done it that way. Here is the log data I get now. By the way I do not see anything wrong with the ID or API keys.

2023-03-21 18:06:39.159 DEBUG (SyncWorker_6) [custom_components.sinope] Setting config location to: /config/.storage/

2023-03-21 18:06:39.159 DEBUG (SyncWorker_6) [custom_components.sinope] Setting scan interval to: 0:02:00

2023-03-21 18:06:39.159 DEBUG (SyncWorker_6) [custom_components.sinope] Setting time zone as: America/Toronto

2023-03-21 18:06:39.274 DEBUG (SyncWorker_3) [custom_components.sinope.climate] Setting up sinope Basement Thermostat: a0c70000

2023-03-21 18:06:39.274 DEBUG (SyncWorker_3) [custom_components.sinope.climate] Setting up sinope Kitchen Thermostat: 505c0100

2023-03-21 18:06:39.336 ERROR (MainThread) [homeassistant.components.climate] sinope: Error on device update!

Traceback (most recent call last):

File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 507, in _async_add_entity

await entity.async_device_update(warning=False)

File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 732, in async_device_update

await task

File “/usr/local/lib/python3.10/concurrent/futures/thread.py”, line 58, in run

result = self.fn(*self.args, **self.kwargs)

File “/config/custom_components/sinope/climate.py”, line 430, in update

device_data = self._client.get_climate_device_data(self._server, self._id)

File “/config/custom_components/sinope/init.py”, line 705, in get_climate_device_data

temperature = get_temperature(bytearray(send_request(self, server, data_read_request(data_read_command,device_id,data_temperature))).hex())

File “/config/custom_components/sinope/init.py”, line 556, in send_request

sock.sendall(login_request(self))

File “/config/custom_components/sinope/init.py”, line 623, in login_request

_LOGGER.debug(“login data = %s, crc= %s”, login_data, crc_count(bytes.fromhex(login_data)))

ValueError: non-hexadecimal number found in fromhex() arg at position 45

2023-03-21 18:06:39.705 ERROR (MainThread) [homeassistant.components.climate] sinope: Error on device update!

Traceback (most recent call last):

File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 507, in _async_add_entity

await entity.async_device_update(warning=False)

File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 732, in async_device_update

await task

File “/usr/local/lib/python3.10/concurrent/futures/thread.py”, line 58, in run

result = self.fn(*self.args, **self.kwargs)

File “/config/custom_components/sinope/climate.py”, line 430, in update

device_data = self._client.get_climate_device_data(self._server, self._id)

File “/config/custom_components/sinope/init.py”, line 705, in get_climate_device_data

temperature = get_temperature(bytearray(send_request(self, server, data_read_request(data_read_command,device_id,data_temperature))).hex())

File “/config/custom_components/sinope/init.py”, line 556, in send_request

sock.sendall(login_request(self))

File “/config/custom_components/sinope/init.py”, line 623, in login_request

_LOGGER.debug(“login data = %s, crc= %s”, login_data, crc_count(bytes.fromhex(login_data)))

ValueError: non-hexadecimal number found in fromhex() arg at position 45

Ok That’s really an error in your ID or api_key
please change the line 623 in __init__.py
from
_LOGGER.debug(“login data = %s, crc= %s”, login_data, crc_count(bytes.fromhex(login_data)))
to
_LOGGER.debug(“login data = %s”, login_data)

and restart HA. We will find what is the offending character number.

Did you check your configuration.yaml ?

2023-03-21 19:42:53.755 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing component custom_components.sinope

Traceback (most recent call last):

File “/usr/src/homeassistant/homeassistant/loader.py”, line 760, in get_component

cache[self.domain] = importlib.import_module(self.pkg_path)

File “/usr/local/lib/python3.10/importlib/init.py”, line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

File “”, line 1050, in _gcd_import

File “”, line 1027, in _find_and_load

File “”, line 1006, in _find_and_load_unlocked

File “”, line 688, in _load_unlocked

File “”, line 879, in exec_module

File “”, line 1017, in get_code

File “”, line 947, in source_to_code

File “”, line 241, in _call_with_frames_removed

File “/config/custom_components/sinope/init.py”, line 623

_LOGGER.debug(“login data = %s”, login_data)

^

Looks like a quotation mark is the culprit.

SyntaxError: invalid character ‘“’ (U+201C)

2023-03-21 19:42:53.756 ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration sinope: Unable to import component: Exception importing custom_components.sinope

I just check back what you sent about your configuration.yaml

I think you didn’t put the data between " "

should be

sinope:
  server: "192.168.20.163"
  id: "001EC0aaaaa1E672"
  api_key: "50119aaaaaabd181"
  my_city: "Montreal"
  scan_interval: 180

You see all parameters except scan interval are between braquet " ". If you don’t put them like this it is possible that there is a trailing space character that is included with the parameter and cause the error

Should be
_LOGGER.debug("login data = %s", login_data)

But if you change your configuration.yaml to have quotation mark it should solve the problem. So change the line with the correct quotation mark and add quotation mark in your configuration.yaml and remove any trailing space.

Ok makes sense so this is what it looks like now;

sinope:

server: “192.168.xx.xx”

id: “D880xxxxxxxD148”

api_key: “d62xxxxxxxxx16ee”

dk_key: ‘’

my_city: “montreal” #needed to get sunrise and sunset hours for your location

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


And I tried to restart HA but was not able to because of this error;

2023-03-21 19:49:23.363 ERROR (MainThread) [homeassistant.components.hassio] The system cannot restart because the configuration is not valid: Component error: sinope - Exception importing custom_components.sinope

2023-03-21 19:49:23.366 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140447111788288] The system cannot restart because the configuration is not valid: Component error: sinope - Exception importing custom_components.sinope

Traceback (most recent call last):

File “/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py”, line 199, in handle_call_service

await hass.services.async_call(

File “/usr/src/homeassistant/homeassistant/core.py”, line 1808, in async_call

task.result()

File “/usr/src/homeassistant/homeassistant/core.py”, line 1845, in _execute_service

await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(

File “/usr/src/homeassistant/homeassistant/components/hassio/init.py”, line 528, in async_handle_core_service

raise HomeAssistantError(

homeassistant.exceptions.HomeAssistantError: The system cannot restart because the configuration is not valid: Component error: sinope - Exception importing custom_components.sinope


I had not changed line 623 to the second new code when I generated the above log. Here is the log with the new code you provided.

2023-03-21 19:54:36.665 DEBUG (SyncWorker_0) [custom_components.sinope] Setting config location to: /config/.storage/

2023-03-21 19:54:36.665 DEBUG (SyncWorker_0) [custom_components.sinope] Setting scan interval to: 0:02:00

2023-03-21 19:54:36.665 DEBUG (SyncWorker_0) [custom_components.sinope] Setting time zone as: America/Toronto

2023-03-21 19:54:36.925 DEBUG (SyncWorker_7) [custom_components.sinope.climate] Setting up sinope Basement Thermostat: a0c70000

2023-03-21 19:54:36.925 DEBUG (SyncWorker_7) [custom_components.sinope.climate] Setting up sinope Kitchen Thermostat: 505c0100

2023-03-21 19:54:36.938 DEBUG (SyncWorker_8) [custom_components.sinope] login data = 55001200100148D19F242B3980D8d62bfe4e36c9916ee

2023-03-21 19:54:38.156 ERROR (MainThread) [homeassistant.components.climate] sinope: Error on device update!

Traceback (most recent call last):

File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 507, in _async_add_entity

await entity.async_device_update(warning=False)

File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 732, in async_device_update

await task

File “/usr/local/lib/python3.10/concurrent/futures/thread.py”, line 58, in run

result = self.fn(*self.args, **self.kwargs)

File “/config/custom_components/sinope/climate.py”, line 430, in update

device_data = self._client.get_climate_device_data(self._server, self._id)

File “/config/custom_components/sinope/init.py”, line 705, in get_climate_device_data

temperature = get_temperature(bytearray(send_request(self, server, data_read_request(data_read_command,device_id,data_temperature))).hex())

File “/config/custom_components/sinope/init.py”, line 556, in send_request

sock.sendall(login_request(self))

File “/config/custom_components/sinope/init.py”, line 624, in login_request

login_crc = bytes.fromhex(crc_count(bytes.fromhex(login_data)))

ValueError: non-hexadecimal number found in fromhex() arg at position 45

2023-03-21 19:54:38.171 DEBUG (SyncWorker_2) [custom_components.sinope] login data = 55001200100148D19F242B3980D8d62bfe4e36c9916ee

2023-03-21 19:54:38.294 ERROR (MainThread) [homeassistant.components.climate] sinope: Error on device update!

Traceback (most recent call last):

File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 507, in _async_add_entity

await entity.async_device_update(warning=False)

File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 732, in async_device_update

await task

File “/usr/local/lib/python3.10/concurrent/futures/thread.py”, line 58, in run

result = self.fn(*self.args, **self.kwargs)

File “/config/custom_components/sinope/climate.py”, line 430, in update

device_data = self._client.get_climate_device_data(self._server, self._id)

File “/config/custom_components/sinope/init.py”, line 705, in get_climate_device_data

temperature = get_temperature(bytearray(send_request(self, server, data_read_request(data_read_command,device_id,data_temperature))).hex())

File “/config/custom_components/sinope/init.py”, line 556, in send_request

sock.sendall(login_request(self))

File “/config/custom_components/sinope/init.py”, line 624, in login_request

login_crc = bytes.fromhex(crc_count(bytes.fromhex(login_data)))

ValueError: non-hexadecimal number found in fromhex() arg at position 45

When you post some code you need to select it then click on </> button above to show the formatting.
In your configuration you don’t need the line dk_key… it is not needed anymore.
You can also omit the part starting with # as it is only comment.

So it should look like this for the formatting:

sinope:
  server: "192.168.20.163"
  id: "001EC0aaaaa1E672"
  api_key: "50119aaaaaabd181"
  my_city: "Montreal"
  scan_interval: 180

That’s all you need. Indentation is important in the parameters

sinope:
  server: "192.168.**.**"
  id: "D880*********D148"
  api_key: "d62********16ee"
  my_city: "montreal"
  scan_interval: 120

Sorry about that. Learning something new everyday.

Here is the last log after cleaning up the configuration.yaml

2023-03-21 20:10:02.368 DEBUG (SyncWorker_4) [custom_components.sinope] Setting config location to: /config/.storage/

2023-03-21 20:10:02.368 DEBUG (SyncWorker_4) [custom_components.sinope] Setting scan interval to: 0:02:00

2023-03-21 20:10:02.368 DEBUG (SyncWorker_4) [custom_components.sinope] Setting time zone as: America/Toronto

2023-03-21 20:10:03.580 DEBUG (SyncWorker_8) [custom_components.sinope.climate] Setting up sinope Basement Thermostat: a0c70000

2023-03-21 20:10:03.580 DEBUG (SyncWorker_8) [custom_components.sinope.climate] Setting up sinope Kitchen Thermostat: 505c0100

2023-03-21 20:10:03.721 DEBUG (SyncWorker_0) [custom_components.sinope] login data = 55001200100148D19F242B3980D8d62bfe4e36c9916ee

2023-03-21 20:10:03.965 ERROR (MainThread) [homeassistant.components.climate] sinope: Error on device update!

Traceback (most recent call last):

File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 507, in _async_add_entity

await entity.async_device_update(warning=False)

File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 732, in async_device_update

await task

File “/usr/local/lib/python3.10/concurrent/futures/thread.py”, line 58, in run

result = self.fn(*self.args, **self.kwargs)

File “/config/custom_components/sinope/climate.py”, line 430, in update

device_data = self._client.get_climate_device_data(self._server, self._id)

File “/config/custom_components/sinope/init.py”, line 705, in get_climate_device_data

temperature = get_temperature(bytearray(send_request(self, server, data_read_request(data_read_command,device_id,data_temperature))).hex())

File “/config/custom_components/sinope/init.py”, line 556, in send_request

sock.sendall(login_request(self))

File “/config/custom_components/sinope/init.py”, line 624, in login_request

login_crc = bytes.fromhex(crc_count(bytes.fromhex(login_data)))

ValueError: non-hexadecimal number found in fromhex() arg at position 45

2023-03-21 20:10:03.978 DEBUG (SyncWorker_9) [custom_components.sinope] login data = 55001200100148D19F242B3980D8d62bfe4e36c9916ee

2023-03-21 20:10:04.040 ERROR (MainThread) [homeassistant.components.climate] sinope: Error on device update!

Traceback (most recent call last):

File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 507, in _async_add_entity

await entity.async_device_update(warning=False)

File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 732, in async_device_update

await task

File “/usr/local/lib/python3.10/concurrent/futures/thread.py”, line 58, in run

result = self.fn(*self.args, **self.kwargs)

File “/config/custom_components/sinope/climate.py”, line 430, in update

device_data = self._client.get_climate_device_data(self._server, self._id)

File “/config/custom_components/sinope/init.py”, line 705, in get_climate_device_data

temperature = get_temperature(bytearray(send_request(self, server, data_read_request(data_read_command,device_id,data_temperature))).hex())

File “/config/custom_components/sinope/init.py”, line 556, in send_request

sock.sendall(login_request(self))

File “/config/custom_components/sinope/init.py”, line 624, in login_request

login_crc = bytes.fromhex(crc_count(bytes.fromhex(login_data)))

ValueError: non-hexadecimal number found in fromhex() arg at position 45

Ok look in your log that you sent me
login data = 55001200100148D19F242B3980D8d62bfe4e36c9916ee

This data is subdivided like this
550012001001 48D19F242B3980D8 d62bfe4e36c9916ee

The first part is the command we need to send. This come from the code
The second part is your ID but written reversely. It is 16 characters long which is ok
The third part is your api_key and it is 17 character long.

there is an error in your api_key it should be 16 characters only. Compare it with what you have in sinope_devices.json

1 Like

Thanks Claude your the best!

There are no more errors in the log file.

Should I now replace the original init.py file?

Yes you can replace the original init.py

I’ll add a test on the parameters to catch that error. Thank you for your help

1 Like

image

Any reason why the sinope entity would not be recognized by the Sensor template?

Thanks.

Climate.sinope_basement_thermostat is not a temperature. For that device the sate is heat, auto or off.
If you want the room temperature you need the property current_temperature. For this you need to create a template sensor. In HA the template sensor need to have some specific property like unit_of_measurement, device_class, state_class. For your sinope devices you can have many different data and it is better to create specific template sensor for what you want. ex:

- name: "heat_level_bureau"
        unit_of_measurement: '%'
        state_class: measurement
        state: "{{ state_attr('climate.sinope_climate_bureau', 'heat_level') }}"
- name: "bureau_current_temperature"
        unit_of_measurement: '°C'
        device_class: temperature
        state_class: measurement
        state: {{ state_attr('climate.sinope_climate_bureau', 'current_temperature') }}
1 Like

Thanks Claude

What does the 34 represent in the first example?

Heat level is the percentage of heating that your thermostat is sending to the heating device. On your thermostat you can see 5 barr indication for the intensity of heating.
You can use it to do something like thisheating

So I included the following in ui-lovelace.yaml

views:
  - title: Neviweb125
    path: neviweb125
    icon: mdi:signal-variant
    theme: dark-mode
    cards:
      - type: custom:vertical-stack-in-card
        title: Thermostats
        cards:
          - type: entities
            show_icon: True
            entities:
              - entity: climate.sinope_basement_thermostat
              - entity: climate.sinope_garage_thermostat
              - entity: climate.sinope_living_room_thermostat
              - entity: climate.sinope_kitchen_thermostat
              - entity: climate.sinope_entrance_thermostat
              - entity: climate.sinope_staircase_thermostat

I then included the following in sensors.yaml (note that this is showing only 1 of 5)

#### Sinope Thermostats ####
- platform: template
  sensors:
    basement_temperature:
      friendly_name: Basement Temperature
      #      unit_of_measurement: "°C"
      #      device_class: temperature
      #      state_class: measurement
      value_template: >-
        state: {{ state_attr('climate.sinope_basement_thermostat', 'current_temperature') }}
      icon_template: mdi:thermometer
    heat_level_basement:
      value_template: >-
        state: "{{ state_attr('climate.sinope_basement_thermostat', 'heat_level') }}"

And this is what I see in the Overview section of Home Assistant;
image

Note that I can not make any modifications to the Overview page. I can’t even edit the Yaml. That is the only card on the Overview page.

I also added the following to customize.yaml; (only showing 1 out of 5)

#### Sinope icons ####
climate.sinope_climate_basement_thermostat:
  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';

Lastly I downloaded custom-ui in /config/community which I believe has the heat icons but it doesn’t seem to work.

Sorry for the long post.

The icons are on my git

custom-ui allow you to change the icons but you have to supply the icon you want and add them in
config/www

This is what I currently have in www. Do I need to create another folder and copy the icons from your git?

image