Eq3 Max! Cube and thermostat integration via Mqtt and Max Home Automation

Yes the issue was installing max home automation on a stretch hassbian
Two questions: did upgrading hassbian to buster provoke any issue? Also didn’t you have any slowing issue?

Well, I have started with freshly installed Raspbian Stretch Lite. The upgrade was without any issues. I wrote a guide for it, which is published by Dimitri Kazakov on sourceforge: https://sourceforge.net/p/max-home-automation/wiki/Raspberry%20installation/.
Problem of running max_home_automation on Stretch is, that it needs libgnat-8 which has no packages for Stretch.
I really don’t know if there is some slowing issue.

“top” output - hope this helps a bit:

Tasks: 106 total,   1 running, 105 sleeping,   0 stopped,   0 zombie
%Cpu(s):  4.0 us,  1.2 sy,  0.0 ni, 94.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :    927.2 total,    353.1 free,    115.2 used,    458.9 buff/cache
MiB Swap:    100.0 total,    100.0 free,      0.0 used.    742.8 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
 1240 pi        20   0  131836  38180  22124 S  11.3   4.0  20:43.44 Xvfb
 1247 pi        20   0  259040  73596  60260 S   7.9   7.8  13:13.90 max_home_automa
 1756 root      20   0       0      0      0 I   0.3   0.0   0:03.64 kworker/u8:1
 2516 pi        20   0   10596   3064   2548 R   0.3   0.3   0:00.40 top
    1 root      20   0   30960   7332   5872 S   0.0   0.8   0:08.76 systemd

There is running HA, max_home_automation, headless X11 (xvfb) on the RPi. It is model 3B+.

So far I have not encounter any slow responses.

I had some minor problems when installing HA in virtual python environment. It was some perrmisions issues. I solved it by installing and first run of HA without virtual environment. After that I was able to run HA in virtual environment.

Ok I just tried to switch to Buster following your instructions, it broke my HA install :expressionless:
I have to get revert to my backup now…

Any way to install MHA on Rpi running HASSIO? through out an add-on maybe?

I am realy sorry to hear that. As I wrote, I made a clean instalation.
Can you tell what went wrong?

Hope You didn’t lose any crucial settings.

not your fault!
I did a backup before, but now I can’t get my Zwave stick to work on the backup… I don’t understand why! -> Issue after restoring a backup

I might start from scratch with a docker container this time…

Ok my problem is solved and I’m back to my previous configuration
So I might give another try with a spare Pi (1) I have!

so I tried again to install max home automation on a spare Pi, followed your instructions and everything seemed fine
the only (big) problem I have is that the X11 forwarding does not work (neither on a Mac or Windows) so I cannot set up the software :face_with_symbols_over_mouth:

With windows I use MobaXterm https://mobaxterm.mobatek.net/download.html. Home edition is sufficient.

The integration is using JSON API for whole cube from max_home_automation. I encounter, that sometimes, usually after restart of RPi, some windows sensors and eco button get to some strange state, that max_home_automation is not able to process. Unfortunatelly the JSON API returns empty device list.

Open&close window and clicking the button usually helps to resolve the issue.

I plan to read list of devices via another max_home_automation API, that does’n suffer this issue and use JSON API for separate devices. Hope I will finish this by end of week.

I used Moba Xterm! and confirmed it worked with xclock, so not a set up issue between server and client…

So your setup is as follows?
Two RPis, one with HA and second with MHA.
MHA with HTTP API enabled and set to be available not on localhost and port 8080, but on IP of your RPi with MHA.

Did you try to call MHA with wget or curl?
Something like: http://192.168.1.123:8080/get-status-json?cube=ABCDEF
It should return JSON with devices. If this doesn’t work, then there is problem with MHA configuration.

Run MHA X11 forwarded. Look in the “trace”. To run HTTP API on port 80 may return in error, if ths port is already used.

Correct
But I can’t activate the http API in MHA since the X11 forwarding does not work…

I am not sure if this helps…
Stop MHA.
Locate file in your home .local/share/recently-used.xbel.
There should be stored the MHA configuration.

One configuration entry looks like this:

<bookmark href="http-server" added="2019-02-20T07:31:42Z" modified="2019-02-26T17:52:54Z" visited="2019-02-20T07:31:43Z">
    <title>on</title>
    <desc>stored value for http-server</desc>
    <info>
      <metadata owner="http://freedesktop.org">
        <mime:mime-type type="application/octet-stream"/>
        <bookmark:applications>
          <bookmark:application name="max_home_automation" exec="&apos; max_home_automation%u&apos;" modified="2019-02-26T17:52:54Z" count="15"/>
        </bookmark:applications>
      </metadata>
    </info>
  </bookmark>

Find and set values for following - the value is in “title” element:

http-server : on
http-address : <IP>
http-port : 8080

Start MHA.

just tried
I have no file in this directory…
so it seems MHA is not starting fully but I have no way to know what’s going on without display…
it appears in the list of processes but that’s all I can say
thanks for your help, but forget it, since my cube has reset once again (third time in a week!), I’ve decided to try to flash it: Converting a MAX! Cube to CUL/CUN to use with Home Assistant

Since koleo9ams Addon doesnt work anymore I made some progress to bridge mqtt. Here is how I did it:

1: Activate MQTT server in max! home automation on a different port than your hass port e.g 1880
2: Go to your hass.io Mosquitto Addon and set customize to true. After this follow the steps here under Access Control Lists (ACLs) and create the two files listed there with its content
3: create a file called bridge.conf (name doesnt matter) in the share\mosquitto folder where you put the files from step 2
4: fill the bridge.conf file with the following content and save it: (all commands and information is going over the thermostat topic. Nothing beside whats written in here will be send to max home automation mqtt server)

connection bridge
address YOUR_ADRESS:PORT
clientid max
try_private false
start_type automatic
topic # out 0 thermostat/ “”
topic # in 0 thermostat/ “”

5: restart the addon
6: enjoy

I will now figure out how I can add the Thermostats into Home Assistant. :slight_smile:

Edit: I got this basic setup working now with my Thermostat. You can change the temperatue in the manual mode. I could not figure out how to use the other modes like boost or schedule. If we want to use some schedule it is also possible to send it over mqtt. But I think we will need some sort of menu to make it possible. Please tell me if it works for you too and your suggestions.

climate:
  - platform: mqtt
    name: YOUR_NAME
    unique_id: YOUR_ID
    qos: 0
    retain: true
    send_if_off: true
    #initial: "20"
    current_temperature_topic: "thermostat/CUBE_ADDRESS/radiator thermostat/DEVICE_ADDRESS/set temperature"
    temperature_command_topic: "thermostat/CUBE_ADDRESS/set/DEVICE_ADDRESS/manual"
    availability_topic: "thermostat/CUBE_ADDRESS/radiator thermostat/DEVICE_ADDRESS/link"
    payload_available: "ok"
    payload_not_available: "error"
    #mode_state_topic: "thermostat/CUBE_ADDRESS/radiator thermostat/DEVICE_ADDRESS/mode"
    #mode_command_topic: "thermostat/CUBE_ADDRESS/radiator thermostat/DEVICE_ADDRESS/mode"

Thanks for your feedback.
I’ve tried to reproduce your config but mosquitto do not connect to max mqtt with a simple error message:
1573378408: Connecting bridge max_cube (max:1884)
1573378408: Socket error on client local.max, disconnecting.

Any idea how to solve this ?
I’m running hass, mosquitto and Max on docker.

edit: ok now it looks like the connexion is ok.
Didn’t notice “” caracters and I’ve replaced them with “”
Still need to configure the climate entity.
By CUBE_ADDRESS you mean his ip address ?

Sorry I didnt had time to answer faster. No I mean the CUBE_ADDRESS. Its the hex number you can see when Max Home Automation is running. See here under Adress http://www.dmitry-kazakov.de/ada/overview-screen-shot.png

Ok I’ve made some progress thanks to you:

  • platform: mqtt
    name: dorian_chauffage
    unique_id: dorian_chauffage
    retain: true
    temp_step: 0.5
    modes:
    • auto
    • heat
    • cool
    • ‘off’
      mode_state_topic: “thermostat/1803FC/radiator thermostat/180968/mode”
      mode_state_template: >-
      {% set values = { ‘automatic’:‘auto’, ‘boost’:‘heat’, ‘manual’:‘cool’, ‘vacation’:‘off’} %}
      {{ values[value] if value in values.keys() else ‘off’ }}
      current_temperature_topic: “thermostat/1803FC/radiator thermostat/180968/temperature”
      temperature_state_topic: “thermostat/1803FC/radiator thermostat/180968/set temperature”
      temperature_command_topic: “thermostat/1803FC/set/180968/automatic”
      availability_topic: “thermostat/1803FC/radiator thermostat/180968/link”
      payload_available: “ok”
      payload_not_available: “error”

There’s a lot of work to :

  • being able to change mode, because each mode is a different topic
  • find a way to change the temperature without changing the mode (actually I prefer to keep the automatic mode in case of manual change but it could be usefull to use manual mode instead sometimes).

And the last thing I’ve to understand it’s why hass does not seems to read correct values for states after a restart.


Actually correct values are 18.5, 17.5 and auto.
I’ve to change to a different value for mode and target t° and then hass ui is updated. (doesn’t work for the current t° of coures)
But on the web site of MAX! cube home automation I can read this:

All topics are retained, that means a client may subscribe to them at any time and get the latest values of.

Ok I’ve somthing working as I want.
First I’ve remove all retain flag from my hass config and reset my mqtt boker, now hass display the correct information just after a restart.

Here’s my climate config:

  - platform: mqtt
    unique_id: d_chauffage
    name: d_chauffage
    temp_step: 0.5
    min_temp: 12
    max_temp: 22
    modes:
      - auto
      - heat
      - cool
    mode_state_topic: "thermostat/1803FC/radiator thermostat/180968/mode"
    mode_command_topic: "temp/climate/max_mode/1803FC/180968"
    mode_state_template: >-
      {% set values = { 'automatic':'auto', 'boost':'heat',  'manual':'cool'} %}
      {{ values[value] if value in values.keys() else 'off' }}
    current_temperature_topic: "thermostat/1803FC/radiator thermostat/180968/temperature"
    temperature_state_topic: "thermostat/1803FC/radiator thermostat/180968/set temperature"
    temperature_command_topic: "thermostat/1803FC/set/180968/automatic"
    availability_topic: "thermostat/1803FC/radiator thermostat/180968/link"
    payload_available: "ok"
    payload_not_available: "error"

And I’ve found this post telling me how I can template mode command with a dummy intermediate topik and an automation, here’s the automation:

- alias: max_mode controller
  trigger:
    platform: mqtt
    topic: temp/climate/max_mode/#
  action:
    service: mqtt.publish
    data_template:
      topic: >
        {% set values = { "auto":"automatic", "heat":"boost", "cool":"manual"} %}
        thermostat/{{ trigger.topic[22:-7] }}/set/{{ trigger.topic[29:] }}/{{ values[trigger.payload] if trigger.payload in values.keys() else "automatic" }}
      payload: >
        {% set values = { "auto":"automatic", "heat":"boost", "cool":"manual"} %}
        {{ "eco" if trigger.payload == "cool" }}

Now when I click on heat it activate boost mode with the thermostat config.
When I click cool it activate manual mode with the eco temp thermostat config
And finally if i click auto the thermostat is back in automatic and with the scheduled temp at this moment.

For the temp setting, when I increase or decrease it I stay in automatic mode, doing it that way on the next scheduled change the thermostat will get back on the scheduled temp set in max home automation and do not stay in manual forever.