Legrand/Bticino MyHome

Hi Guys,
i’m trying your integration beacuse in this moment i’m using openhab but i want to migrate to homeassistant.

After installed ownd with command pip3 and tried to discovery with follow result:
Address: 192.168.137.4
Port: 20000
Manufacturer: BTicino S.p.A.
Model: MyHomeServer1
Firmware: 2.31
Serial: 00:03:50:8C:1E:72

I have installed via HACS your integration but at start of home assistant i receive this error:
2021-01-06 01:19:31 ERROR (MainThread) [custom_components.myhome] configuration.yaml not supported for this component!
2021-01-06 01:19:31 ERROR (MainThread) [homeassistant.setup] Setup failed for myhome: Integration failed to initialize.

In configuration.yaml i put:
myhome:
ip_address: 192.168.137.4
password: mysecretpassword

Could you help me?

Thanks a lot,
Alessandro

Ciao
in myhome configuration currently there is configured 1 central 4 zone, with address 2.
The address of central unit become the same of local zone (zone_1 with address 2) and then there is zone_2 with address 3.
Note that I can get correct update in lovelace interface when I change temperature from bticino directly for both zones, so seems homeassistant can correctly receive data for both zone.
But when I trigger temperature adjust from homeassistant it works for zone_2 (address 3) but not for local zone (address 2).
It is not a matter of climate configuration (yaml), because of I tested directly myhome send commands:

message: '*#4*3*#14*0205*1##'          working for zone_2
message: '*#4*2*#14*0205*1##'          NOT working for local zone
message: '*#4*#2*#14*0205*1##'        NOT working for local zone
message: '*#4*#0#2*#14*0205*1##'    working for both local zone and zone_2

I’'try to investigate with bTicino, meanwhile do you know if there is a way to manually send customized commands using homeassistant thermostat panel ?

Thanks!

Hi, the integration is publicly available now, and can be installed via HACS.
You just need to add the integration repository as a “custom repository” in HACS and you’ll then be able to install it from there!

The integration needs to have the gateway configured with the GUI, it should be detected automatically by Home Assistant!
At least your gateway is correctly detected by the library, so if HA does not detect it, you can try to restart it, maybe the library was not loaded properly at startup?

Unfortunately, there is no real way to send custom commands directly via the climate entity.
(I suppose you could use a “generic thermostat” and send custom commands from there, but it not really a proper solution)

Can you try to simply remove the “central unit” from your configuration, and change the zone to #0#2 for zone_2 in YAML and let me know what it does?
There will probably be some problems I’ll need to fix in the code, but it seems to be the best way forward.

Ciao
after changing with the following configuration (no climate and new id for local zone):

climate:
  - platform: myhome
    devices:
      zone_1:
        zone: '#0#2'
        name: Ground floor
        heat: True
        cool: True
        standalone: False
      zone_2:
        zone: '3'
        name: First Floor
        heat: True
        cool: True
        standalone: True

After I restarted HomeAssistant:

  1. When I try to add in lovelace a new thermostat the new entity has no info available
  2. In the log there are the following:

2021-01-06 18:41:58 DEBUG (MainThread) [custom_components.myhome] Received: *#4*3*13*00##
2021-01-06 18:42:01 DEBUG (MainThread) [custom_components.myhome] Received: *#4*2*12*0205*3##
2021-01-06 18:42:01 WARNING (MainThread) [custom_components.myhome] Unknown device: WHO=4 WHERE=2
2021-01-06 18:42:01 DEBUG (MainThread) [custom_components.myhome] Received: *4*1*2##

I receive this error now:

2021-01-06 18:41:00 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/srv/homeassistant/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/srv/homeassistant/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 118, in impl
    return await handler(request)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/config/config_entries.py", line 136, in post
    return await super().post(request)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/http/data_validator.py", line 60, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/data_entry_flow.py", line 69, in post
    result = await self._flow_mgr.async_init(
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/data_entry_flow.py", line 130, in async_init
    result = await self._async_handle_step(
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/data_entry_flow.py", line 213, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/home/homeassistant/.homeassistant/custom_components/myhome/config_flow.py", line 86, in async_step_user
    return await self.async_step_test_connection()
  File "/home/homeassistant/.homeassistant/custom_components/myhome/config_flow.py", line 131, in async_step_test_connection
    test_result = await test_session.test_connection()
  File "/srv/homeassistant/lib/python3.8/site-packages/OWNd/connection.py", line 183, in test_connection
    result = await self._negotiate()
  File "/srv/homeassistant/lib/python3.8/site-packages/OWNd/connection.py", line 207, in _negotiate
    raw_response = await self._stream_reader.readuntil(OWNSession.SEPARATOR)
  File "/usr/local/lib/python3.8/asyncio/streams.py", line 632, in readuntil
    await self._wait_for_data('readuntil')
  File "/usr/local/lib/python3.8/asyncio/streams.py", line 517, in _wait_for_data
    await self._waiter
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 848, in _read_ready__data_received
    data = self._sock.recv(self.max_size)
ConnectionResetError: [Errno 104] Connection reset by peer
[Errno 104] Connection reset by peer

That would indicate that your gateway is refusing the connection for some reason.
Unfortunately, I don’t have an MHS1 and I don’t know if there is any settings in the gateway itself that could cause that.

I’ll work on making it possible to designate a zone as “central unit”, that should make it possible for your setup to work.
However, I still find they way the 4 zone central works really really strange.
From the tests you made, it is not possible to control zone 2 separately, because the commands to change it are also the “general” commands (with #0#2), is that correct?
Then you cannot control zone 3 via the central unit, it must be configured as standalone in order to work? (I suppose #0#3 does nothing there?)

Then we’ll be having other issues I think with cooling, because if I understand correctly, you having both heating and cooling, but controlled by actuators, not valves?
In that case, how do you know which actuator number controls the heat and cold? Is it something you configure?

Thanks so much!
Just to better clarify the system I have:
bTicino 4695 (central unit 4 zone): also from myHomescreen I can set the mode (e.g. manual, manual with timing, off, …) and the temperature only for all the zones at the same time.
When I change the temperature I cannot set different values for zone 2 (ground floor) and zone 3 (first floor).
But on first floor (zone 3) I have bTicino N4692 so I can set offset (e.g. +/- 1°C) with respect to ground floor.
Central unit can control both heating (floor radiant) and cooling (fan coil) just setting the season (winter for heating and summer for cooling), and use external heat pump.
When using cooling, fan speed can be physically changed with bTicino AM5086 selector for each room).
Central unit is configured with local zone (address 2 - ground floor) and zone 2 (address 3 - first floor). Both zone have 2 actuators (number 2 for heating and number 3 for cooling).
Basing on current configuration I can correctly control first floor (zone 2, id=3) by Homeassistant, also changing the temperature by 0.5 °C (that is not physically possible by N4692, that support only 1°C step).
And I can get state update (temperature, heating/cooling) by central unit for all zone. But I cannot set temperature on local zone (ground floor).

Now basing on OpenWebNet command test (developer tools, service myhome.send_message) the following commands seems to be working:

message: '*#4*#0#2*#14*0205*1##'		all zone 20.5 °C
message: '*#4*3*#14*0200*1##'			set zone 2 (first floor) to 20.0 °C
*4*303*#0#2##					all zone OFF
*4*303*3##					set zone 2 only (first floor) to OFF
message: '*#4*#0#2*#14*0200*2##'		set all zone temperature to 20.0 °C in cooling mode

Do you know if it is possible (and in case with which command) to set manual mode with specified timing (after timer expiration will set to OFF) and how to change central unit from winter mode (heating) to summer mode (cooling) ?

Please let me know if something I reported is not clear or need additional info.

I’d like to help all community to use your addon, if you want i’m available for a session with teamviewer or teams or another software you prefer or to access via VPN.

If you are interesting in my help please contact me via private message.

Best Regards,
Alessandro

Hi Julien,
thank you very much indeed, you did a magnificient work!
I have integrated your library and it works fine, with all the following components I have in my bTicino plant: lights, switch, sensors, climate, cover (automation).
It works much better than other libraries I did integrate in Openhab and HomeAss over the past years.
I will continue to test your library and keep posted all of you if I have any doubts or problems.
Thanks again for your work!

@federicoimg I’ve published a new master of the integration (you can install it by selecting ‘master’ in HACS). It should also automatically update the library to version 0.7.17
It contains the basic support of the central unit local zone. You will need this configuration for your setup:

climate:
  - platform: myhome
    devices:
      zone_1:
        zone: '2'
        name: Ground floor
        heat: True
        cool: True
        central: True
      zone_2:
        zone: '3'
        name: First Floor
        heat: True
        cool: True
        standalone: True

You were mentioning that you have actuator 2 for heating and actuator 3 for cooling, is it something that you need to configure yourself or is it the mandatory values for everybody? (just to know if I can assume this is constant or if I must plan for a way to let users configure it in the integration)

@giadil, I’m glad all is working to your liking! Please feel free to report anything you think would be useful!

@alex4988, many other users are successful integrating their MHS1 gateways, so I must assume there is a problem here that is specific to your gateway or setup. With a bit of luck, authentication would work after some sort of internal timeout in the gateway… Did you try again since your last attempt?
Unfortunately, I will not have much time to debug this in depth, and by principle I will not connect to end users network environments by any means.

Thanks so much, Julien.
I tried today to install by HACS the new version (select “master”) without removing the previous one, but I had some issues, I don’t know if I made something wrong.
After install, I restarted Homeassistant and a lot of errors appears in the log. Also all the existing entities of myhome (lights, cover, …) nothing was recognized more in lovelace.
I tried to remove climate part from configuration.yaml but after that the system was no more able to validate the configuration (the check was running indefinitely).
I also tried to reload the previous snapshot and overwrite in custom_components only the 3 files modified (climate, const, manifest) but after that the result was the same.

What do you suggest me to do ?
Thanks.

Installing the way you did it first was the correct way to go. What errors did you get at that point?
In cases where the library is upgraded as well (as it was here) , another restart of Home Assistant once everything is installed might help.

First step would be to know what errors are present already!

Oh well… my bad :sweat:
It was a REALLY silly typo in OWNd.
I’ve fixed it and published version 0.7.18!
You can re-install from master (double-check that the manifest.json file mentions OWNd==0.7.18)

Thanks! Now I installed successfully the new version, and updated configuration as you suggested.
Still something seems not accepted in the syntax, I attach the screen of the log when I try to change temperature of Ground floor by lovelace.

That was my fault again :smiley:
It’s kinda difficult to develop this when you cannot test the code yourself :sweat:

OWNd version 0.7.19 is published to fix this issue. The integration master is also published with the updated requirement!

Don’t worry and thanks so much for your precious support: you already made a very good work till now!
Step by step…I installed new version (0.7.19) and now the error disappeared, but still not working: as you can see from the log the command sent is with where=#2, I think maybe it should be where=#0#2, basing on the command test I made before…
And in the gui the temperature of ground floor is not updated (report 0°C), it updates just after changing temperature from myhomescreen directly.
Below the screenshots.


screen04

I think I’ve fixed the issue with the wrong command in OWNd. The zone variable is manipulated at multiple places in the code, so it turns out this use-case with the 4 Zones needs to be handled differently than the rest.

Can you try to edit your manifest.json to set the requirement to 0.7.20 and let me know how it goes?

The returned temperature being at 0º is strange, I don’t really know what’s happening without more logs…