Valve position on Max! Cube Thermostat

Hi everybody,
would be nice to have valve position sensor with the Home Assistant Max! Cube integration.


Having each valve position is necessary if you need to switch on and off the heating system automatically.
The two scenario will be:
  • all valve closed or all valve minus then 10% -> switch off the boiler
  • one or more valve open or more then 10% -> switch on the boiler

With MAX! HOME AUTOMATION software by Dmitry A. Kazakov is possible to do this as you can see here:
http://www.dmitry-kazakov.de/ada/max_home_automation.htm#5.5

I wanted this feature too and added a sensor to the maxcube component. An early version is available here:


The configuration works just the same as the official maxcube component. For each thermostat, a new sensor is added with entity id sensor.<name_of_thermostat>_valve_position.

Wonderful job! I want to try it.
Anyway, iā€™m still worried about a problem that is coming using Max Cube integration.
After some time (randomly) the cube loose the configuration.
You can also read here about this known problem:


Seem that the solution is to make it keep the connection with the cube always open (as Dimitryā€™s software do http://www.dmitry-kazakov.de/ada/max_home_automation.htm).
Here are the lines to change this behaviour:
https://github.com/hackercowboy/python-maxcube-api/blob/a0ae75482434c362f8e212f44e6a78787f85c340/maxcube/cube.py#L79

Have you ever met this problem too?

Sorry if iā€™m going outside the main goal of this page

Unfortunately, yesā€¦ For debugging purposes I decreased the polling interval to 30 seconds and within a few days the cube lost its configuration. Before I moved to Home Assistant I controlled the cube with Pimatic which worked for years without any problems. Pimatic indeed seems to keep the connection open instead of reconnecting every few minutes.

Thanks for mentioning this issue, at least now I know where my problems came from :grinning:. Will take a look at the suggested solution soon.

Iā€™ve tryed your code and itā€™s perfect. Iā€™m using it and have valve position in Home Assistant. Great job and thank for your time.
Iā€™ve also tryed deleting disconnection in order to keep connection always on but seem that itā€™s not working. Itā€™s still disconnecting. I check it trought official App.
While using Max! Home Automation software, the app is not working.
With Home Assistant itā€™s still working. Have you tryed this solution also?

Iā€™ve not tried this solution (assuming ā€œthis solutionā€ means modifying the maxcube-api library by deleting line 83 in cube.py). However, I just took a look at the code and I donā€™t think removing this line is enough to solve the problem. Just take a look at connection.py:

On every connection, the MaxCubeConnection object will set the socket property. On every new connection, it will check for this property being set (line 17). If this is the case, it will still call the disconnect method (line 18). This means that calling the connect method of the MaxCubeConnection object (as is done in cube.py, line 81) will still cause HA to disconnect from the cube.

To solve this, you should probably remove line 16 - 20 in connection.py. In the ideal situation, the maxcube-api library should be modified so that MaxCubeConnection also includes an option to keep the connection open.

After integrating my MAX! cube with HA, I played around with the suggested changes to not have the problem of configuration loss in the future.

I deleted line 83 from cube.py - not sure if the other code in the update method should also be deleted though.
I also deleted lines 16-20 from the connection.py.

Unfortunately, the HA still seems to disconnect from the cube as I can access the cube data from an Android ā€¦ :frowning:

yes iā€™ve tryed too but no way to avoid disconnection.
so iā€™ve decided to change max cube firmware

and itā€™s working, no more problems with loosing configuration. and iā€™ve battery level, valve position and more parameter.
i think that the official home assistant integration for max cube should be deleted cause itā€™s not working correctly.

Hm, thatā€™s a pityā€¦ And it seems like the python-maxcube-api repository hasnā€™t been updated for a long time, so thereā€™s no reason to expect this issue being solved in the short term. (Of course I could try doing that myself, and I actually did, but for now I didnā€™t succeed :frowning:.) So thanks @steno for pointing to the CUL/CUN topic, I will try going that way. Having other sensors as well sounds great!

I just read the breaking changes in the beta release notes for HA Core 0.109.0. In 0.109.0, the official maxcube component will also expose the valve position.

https://github.com/home-assistant/core/pull/28845

Important update: MAX! products are no more on the market. You can still find something but they are not producing it anymore. By the way with a-culfw firmware you have then products of ā€œHomeMatic familyā€. So you can still add HomeMatic products if you need

Hello @crnh
I see your plugin stopped working and I get error:
ā€œ2021-10-11 09:35:33 ERROR (SyncWorker_2) [homeassistant.loader] The custom integration ā€˜maxcubeā€™ does not have a version key in the manifest file and was blocked from loading. See https://developers.home-assistant.io/blog/2021/01/29/custom-integration-changes#versions for more detailsā€

Could you please tell us how to fix it?

I think this says enough. Please use the official integration, my custom integration is unsupported and has not been maintained for about 1.5 years. My integration only included a quick fix to expose the valve position, because at that time the official integration did not expose it. Nowadays, the official integration does support this feature, and many more.

Also, I think this feature request has been implemented and can be closed.

Hmm I canā€™t see this valve position feature in official integration :frowning: can anyone help ?

According to the code, the valve position should be an attribute of the climate devices provided by the Max! Cube integration. Unfortunately, I donā€™t have access to any Max! Cube devices anymore, so I canā€™t check this for you in my own HA instance.

It is deffo not there :wink: I had to revert to customā€¦

Got strange issue perhaps you know how to resolve?

Logger: homeassistant.setup
Source: setup.py:320
First occurred: 17:02:50 (1 occurrences)
Last logged: 17:02:50

Unable to prepare setup for platform maxcube.binary_sensor: Platform not found (cannot import name ā€˜BinarySensorDeviceā€™ from ā€˜homeassistant.components.binary_sensorā€™ (/usr/src/homeassistant/homeassistant/components/binary_sensor/init.py)).

If that issue arises when using the custom integration, it is probably caused by the deprecation of the BinarySensorDevice class. You could try to change it to the BinarySensorEntity class. Other than that, I canā€™t help you with this. The custom integration is unmaintained and unsupported, and it is better to use the official integration instead. If that integration doesnā€™t work as expected, file an issue and youā€™re likely to get more help than I can offer you.

1 Like

The above fixed the problem, but is there any option to get updates on the temperature more often? It seems it only updates with HA restart now :frowning:

There probably is, but I donā€™t know how to fix it. Iā€™m afraid youā€™ll have to sort that out yourself. I strongly recommend you to follow the advice in my previous post: use the official integration.