MWD5 WiFi thermostat (OJ Electronics/Microtemp)

Hi.
I do not get this error from this Request Thermostats node.
Used a debug node to watch the result.
23.11.2022, 20:13:47[node: debug 2]
msg.payload : Object
{ GroupContents: array[1], ErrorCode: 0 }

Strange, There must be something wrong on my side. These are the prepare request node settings:

And below the settings there are in the Request Thermostat node. Can you confirm those are right?

image

Hi. The order in my i different. It is not easy to see what your picture shows i details.
image

Have you checked in Flow context that you have SessionId set to a string after you log in?
Should change each time you log in.
Can you hook up a debug-node to the output of your “Request Thermostats” node?
Make the debug node show the entire msg object.

You need to use https, seems like you are using http?
Do you have a git repo for this project? I’m very interested in getting these thermostats working as a hacs integration without nodered/mqtt, and if I have som spare time I would be happy to contribute.

Hi oppigard,

thanks a lot for your node red flow. I can confirm this flow (including the changes from this post) works as expected.

I’m using this flow with Schluter DITRA HEAT E R WIFI. Therefore, I needed to set customerId = 3 in the login node.

Now, we have everything together that we could also create a full integration if someone would have time for it.

Again, thanks a lot.

Hi,
I hacked something together that works for me. My method was to dissasemble the android app and extract the api info from there. The code for the custom integration is extremely ugly, so it should be rewritten by someone more knowledgeable. I will probably not have time to do it right in the near future.
User/pass is hardcoded in python.
It uses the climate (integration I guess it’s called).
It will poll the sensors every 1 minute or sooner if you change a setting.
It supports setting Manual+Temp/Auto/FrostProtect/Boost (boost duration fixed in python script).

If anyone is interested I can share my work.

Sounds great! Would be fantastic if you can share, and perhaps someone here can tidy up the code.

Here you go:

Let me know if this works for you

2 Likes

Got this error

`Error while setting up mwd5 platform for climate

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform
    await asyncio.shield(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/mwd5/climate.py", line 325, in setup_platform
    thermos = t.getThermoInfo()
  File "/config/custom_components/mwd5/climate.py", line 203, in getThermoInfo
    for group in data["GroupContents"]:
TypeError: 'NoneType' object is not subscriptable
`

Seems like you have no groups/zones setup in the application or maybe it could not login using username/password supplied. There should be a file called data.json in the /opt/home-assistant folder that should contain a dump of the current configuration of all zone/thermostats associated with your account.

I tried this, because the Node-Red one is still not working for me. Even with the info in de debug prints not.

Now I put all the files in custom components, edit the files mentioned in the readme. When I try restart HA, it gaves me the message: Platform error climate.mwd5 - Integration ‘mwd5’ not found. Please can u check if I made a mistake?

Information in the logs gives me the following info, but I checked everything and found nothing strange. Other custom components are working fine, with and without HACS.

Logger: homeassistant.components.websocket_api.http.connection
Source: components/hassio/init.py:529
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 21:57:40 (1 occurrences)
Last logged: 21:57:40

[140468305899056] The system cannot restart because the configuration is not valid: Platform error climate.mwd5 - Integration ‘mwd5’ not found.

Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py”, line 200, in handle_call_service await hass.services.async_call( File “/usr/src/homeassistant/homeassistant/core.py”, line 1745, in async_call task.result() File “/usr/src/homeassistant/homeassistant/core.py”, line 1782, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File “/usr/src/homeassistant/homeassistant/components/hassio/init.py”, line 529, in async_handle_core_service raise HomeAssistantError( homeassistant.exceptions.HomeAssistantError: The system cannot restart because the configuration is not valid: Platform error climate.mwd5 - Integration ‘mwd5’ not found.

@0xi3
Maybe I made a mistake in the README.
In the development environment, there is the config/custom_components folder.
Normally, this config folder will not exist in a non-development environment.

Instead this is how it looks like on my PI, where HA runs in a docker container:

pi@raspberrypi:/opt/home-assistant/custom_components/mwd5 $ ls
climate.py  config_flow.py  const.py  __init__.py  manifest.json  __pycache__  strings.json  translations
pi@raspberrypi:/opt/home-assistant/custom_components/mwd5 $

Did you deploy it like above ?

Yes, it is indeed in config/custom_components. There are more custom components in there.

I put the mwd5 folder in it, restart without problems. Add the climate config to configuration.yaml, then restart and the error came. Comment the config with #, save and restart without problems. So looks like it won’t see the mwd5 folder.

@0xi3
I got curious and tested the code on the latest dev branch of home assistant. Sure enough the integration was not loaded by home assistant, showing the following in the error log:

The custom integration ‘mwd5’ does not have a version key in the manifest file and was blocked from loading. See Custom integration changes | Home Assistant Developer Docs for more details

I’m running an older version of HA on my PI, due to some dependencies I didn’t have time to iron out so I didn’t catch this issue on my setup.

Nevertheless, I made a small update to the code an now it seems to work with the latest HA. It’s already on github, so maybe give it a try.

You are a hero! That was the missing line. It is working fine on my HA now! :grin:

Thanks for the help!

P.S. thermostat is branded as “Speedheat”, so confirmed that that is working too.

1 Like

I have a zone defined, and i have checked the user/password. Do i need to do something with the api-key? Also added the versioning before the last post. I dont have a folder in called home-assistant in my opt. ha runs on a raspberry pie
Ant tip on where to find the logfile you refering to?

The API key should be fine as it is.
It seems to me you need to find the configuration directory (same where configuration.yaml is stored).
Inside that configuration directory you can create the custom_components folder if it is not already existing.
Here’s how it looks on my side:

pi@raspberrypi:/opt/home-assistant $ ls
automations.yaml     deps                      influx.yaml
binary_sensors.yaml  groups.yaml               scenes.yaml
blueprints           home-assistant.log        scripts.yaml
certs                home-assistant.log.1      secrets.yaml
configuration.yaml   home-assistant.log.fault  sensors.yaml
core                 home-assistant_v2.db      template_sensors.yaml
custom_components    home-assistant_v2.db-shm  tts
data.json            home-assistant_v2.db-wal
pi@raspberrypi:/opt/home-assistant $ ls custom_components/mwd5/
climate.py      const.py     manifest.json  strings.json
config_flow.py  __init__.py  __pycache__    translations
pi@raspberrypi:/opt/home-assistant $

Inside the custom_components folder you should place the mwd5 folder from gtihub.

Some more info here: Integration File Structure | Home Assistant Developer Docs

Sorry didn´t realise you where talking about the home assistant root_folder.

I think I have set it up just like you. HA starts the component, but i don´t have the data.json file. Maybe my thermostat is not compatible.

It could be.
I see above that some people use a different hostname for the API:
I have ocd5.azurewebsites.net:443 vs owd5-mh015-app.ojelectronics.com menitoned by others above.

The API looks similar, but there are some differences:
In my code I have:

"CustomerId": "99",
"ClientSWVersion": "1060",

but above, I see

"ClientSWVersion": 1,
"CustomerId": 111,

I’ve added a basic test file in the repositoy it should at least allow you to test if your thermostat is compatible with this code, independent of HA.

You can use it like this:

  1. edit mwd5_test.py add your username/password
  2. install dependencies:
    pip install requests
  3. Run the script:
    python .\mwd5_test.py

For me, it looks like this:

python .\mwd5_test.py
Logged in with username xxxxxxx
Session ID: xxxxxxxxxxxxxxxxxxxx

G: Living si Bucatarie  : Setpoint: 22.11 : AUTO
   Living si bucatarie  : Heating OFF  : 21.9/18.0 : MANUAL : ONLINE

If you get something like above then it should work with HA also.
Hope this helps