Haverland Radiators Smart Box Integration

You don’t need to add the python package now. The integration pulls the package from the repo

Thanks for the update. The new version is working flawlessly

I’ve just pushed out a new version: https://github.com/graham33/hass-smartbox/releases/tag/v0.0.4, release notes below. I’d recommend updating. The newer version of the smartbox module also contains a fix for the python-socketio dependency which could cause weird bugs if you ended up installing too new a version, so worth ensuring that is up to date.

Features

  • Add power sensor
  • Implement away preset
  • Update to smartbox 0.0.5

Bugfixes

  • Fix state returned by climate entity
    • This was accidentally overridden to return temp rather than default (HVAC
      mode)
    • This primarily caused the current HVAC mode to not be highlighted in the UI,
      but might also impact automations

@gr_h_m or @davefrooney
I’ve just installed v0.0.5 (first time installation), with the following config

smartbox:
  accounts:
  - api_name: 'climastar'
    username: !secret smartbox_id
    password: !secret smartbox_pw
    device_ids:
    - !secret smartbox_device
  basic_auth_creds: !secret smartbox_auth

but obtained the following error log:

Logger: homeassistant.setup
Source: custom_components/smartbox/model.py:15
First occurred: 12:20:31 AM (1 occurrences)
Last logged: 12:20:31 AM

Error during setup of component smartbox
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 213, in _async_setup_component
    result = await task
  File "/config/custom_components/smartbox/__init__.py", line 61, in async_setup
    devices = await get_devices(hass, account[CONF_API_NAME], basic_auth_creds, account[CONF_USERNAME],
  File "/config/custom_components/smartbox/model.py", line 15, in get_devices
    session = await hass.async_add_executor_job(Session, api_name, basic_auth_creds, username, password)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/site-packages/smartbox/session.py", line 16, in __init__
    self._auth({'grant_type': 'password', 'username': username, 'password': password})
  File "/usr/local/lib/python3.8/site-packages/smartbox/session.py", line 28, in _auth
    self._access_token = r['access_token']
KeyError: 'access_token'

I’m not sure but does this error mean that the <basic_auth_creds> I provide is wrong ?
I used a Basic Authentication Header Generator to generate this credential.
Thanks in advance for pointing out what should I fix.

Hello, ooo, oooo,
It’s anybody out there who can help me on the above question ? I’m stuck :worried:
Thanks

I’m not sure what the header generator tool is but you should be able to grab the token from the browser. This link might help

You need to be logged in to see the data.

:+1: :pray: Thanks a lot @davefrooney.
It works !!
I have tried 3 or 4 different Basic Authentification generators which gave me the same credential string but it is not the one in the header which I’m able to grab just now with your help.

Excellent!. I’m happy you got it working

I see you have made great progress before I even made a single move, @gr_h_m :slight_smile: Great job!

I have installed the integration yesterday to test it out. I have a few issues / suggestions - I would love to try working on some of it, but I lack the HA & python experience.
Since my contribution up to this point is exactly zero, please know that I am making these remarks in a very humble tone:

  1. Do you know how to make the entities “pushing” the state, rather than being polled by HA? The heaters respond to commands immediately, the updates come in right away, but the HA entities update only roughly once a minute. My gut feeling is it would be ideal to work on this before extending the integration with further functionality.
  2. I have a low/high tariff in the house and the heaters are cut off during high tariff periods. This makes them disappear ('sync_status': 'lost'). This causes errors, sometimes irrecoverable, because the node.status fields are no longer present. (i.e. return TEMP_CELSIUS if self.**_node.status['units']** == 'C' else TEMP_FAHRENHEIT throws KeyError: 'units')
  3. There is a missing heater mode mapping for “modified_auto” - that is when the heater was in “auto” / schedule mode and the target temperature is changed without switching to manual mode. I am not sure what the mode in HA climate should be to reflect this (ValueError: Unknown smartbox node mode modified_auto)

I offer my help with maintaining / helping out with this integration - but I am not sure how I can be of help without learning a a few bits about HA internals. It would be fantastic if we find a way to cooperate - if you don’t mind, of course.
The 2 things I would want to (or help to) work on:

  1. push vs poll
  2. Add UI configuration flow, to get more people onboard and help with testing

What is your opinion?

Thank you for all the excellent work so far - it is great to see the heaters in HA!

Cheers,
J.

Sorry for the delayed response! Thanks for the feedback.

  1. Yes I think this could use some work. At the moment theresolve updates come in from the radiators asynchronously, but HA itself only updates by polling right now. This is something I should look into, it’s just due to my limited knowledge of the HA event model. My plan is to first write some simple tests of the custom component before extending it further.
  2. That should be fairly easy to handle more gracefully, I’ll try to add a test for it.
  3. Ah, I haven’t seen that mode. Again it should ve fairly easy to handle (I guess I’ll just treat it similar to the regular auto).

Definitely up for any help you can give. I’ll try to set up the tests so the project is easier to contribute to, but if you want to try to make some pull requests or log suggestions as issues on github that’d definitely be great.

I’m hoping to get some time to look at this in the next few days, and will update here with any progress.

1 Like

Thank you for getting back to me! Is there a more direct communication channel we could establish for the short term? I don’t feel like using github to report miniscule issues when the overall design is in such an early stage.
I have tried to create a HA development environment (successfully, but need to redo for other reasons) and play around with the push mode for the sensors - with great results. I would gladly share the information with you - it is surprisingly simple, but don’t feel like cluttering this forum - I would give you specific code changes.

I have also played with the option to configure the integration with UI only, to support multiple accounts, to have the ability to reload the integration and not have to mess with configuration.yaml - hopefully not even restarting HA on every code change to test it out. I have made some progress, but nothing to share yet, as I am still trying to understand the available framework. But we could coordinate / split what we work on to prevent work duplication and code conflicts.

I try to setup a simple script to switch preset mode:

test_val:
  sequence:
  - service: climate.set_preset_mode
    data:
      entity_id: climate.Val_LivingS
      preset_mode: away

and get the following error log

Logger: homeassistant.components.script.test_val
Source: components/climate/__init__.py:442 
Integration: Script ([documentation](https://www.home-assistant.io/integrations/script), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+script%22)) 
First occurred: 2:27:27 PM (1 occurrences) 
Last logged: 2:27:27 PM

test_val: Error executing script. Unexpected error for call_service at pos 1: 

Traceback (most recent call last): 
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 262, in _async_step await getattr( 
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 463, in _async_call_service_step await service_task 
File "/usr/src/homeassistant/homeassistant/core.py", line 1488, in async_call task.result() 
File "/usr/src/homeassistant/homeassistant/core.py", line 1523, in _execute_service await handler.job.target(service_call) 
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service await self.hass.helpers.service.entity_service_call( 
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 642, in entity_service_call future.result() # pop exception if have 
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 681, in async_request_call await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 679, in _handle_entity_call await result 
File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 446, in async_set_preset_mode await self.hass.async_add_executor_job(self.set_preset_mode, preset_mode)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) 
File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 442, in set_preset_mode raise NotImplementedError() 
NotImplementedError

Does this mean that this service “set_preset_mode” is not implemented in the integration or did I make some mistake ?
Thanks.

This is likely something I just haven’t implemented. I’m hoping to get some time to work on this this weekend, so I’ll try to fix it.

Hi,

great work so far! I have searched for a project like this for quite some time.

I found out that I also have a smartbox for my heating, from a small German company called ‘wibo’. They use the api as evidenced by a wireshark sniff, but they directly use ‘api.helki.com’, which is currently not compatible with the possible configuration options.
Also, they only provide an app, not a web interface, so I cannot find out which are the correct basic auth credentials used. Can someone point me in the right direction? E.g. is it something like a base64-encoded ‘username:password’-combination?

Any help would be much appreciated!
Thanks

There is a generic login page that they use for the Alexa skill. You might be able to retrieve from there

https://heatingcontrol.eu/alexa/login.html

Thanks, I can log in there! :grinning:

Works great so far :slight_smile:

1 Like

thanks, I will test, I think half Europe selling these radiators, they are very good ones really

Hello, I tried to set up this integration but I can’t see any device, I obtained my basic auth token and put all data in configuration.yaml. In the Home Assistant log I only can see:

2021-04-04 22:48:18 WARNING (MainThread) [homeassistant.loader] You are using a custom integration smartbox which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2021-04-04 22:48:18 WARNING (MainThread) [homeassistant.loader] No 'version' key in the manifest file for custom integration 'smartbox'. This will not be allowed in a future version of Home Assistant. Please report this to the maintainer of 'smartbox'

I don’t know what I’ve done wrong. any idea?

Thanks!

I’ve finally got around to making a new release with several changes: https://github.com/graham33/hass-smartbox/releases/tag/v0.1.0.

Here are the release notes:

0.1.0 (alpha)

Bug Fixes

  • Fix status handling on node unavailable

Features

  • Add initial tests, minor refactorings
  • Add requirements.txt
  • Add initial tests using pytest-homeassistant-custom-component
  • Reformat with black and add CI check
  • Add codecov
  • Improve custom component manifest
  • Support modified_auto mode (mapped to HVAC_MODE_AUTO)

Breaking Changes

  • Upgrade to smartbox 0.1.0
    • The API name parameter must now be api-foo where it was previously foo (to connect to api-foo.xxxx ). This allows some devices which connect to api.xxx to work.
  • Only add configured devices (previously all were added). Report errors if configured devices are missing, warnings if extra devices are found.