andyboeh / mediola2mqtt

Mediola MQTT Gateway
11 stars 13 forks source link

Gateway V6 - UDP broadcast with blinds in hex number cause error #11

Open ThoSig opened 2 years ago

ThoSig commented 2 years ago

Hi all!

I just tried to make UDP broadcasts finally work on my HA instance when i noticed, that UDP broadcasts with blinds higher than 8 seem to have issues. as a reference i will simply copy some debug log in here:

Received message: b'STA:{"type":"ER","sid":"0E","adr":"0E","state":"1002","ts":{"m":"6282B4ED"}}'
Sending PUBLISH (d0, q0, r0, m47), 'b'mediola'', ... (76 bytes)
Error handling v6 packet: b'{"type":"ER","sid":"0E","adr":"0E","state":"1002","ts":{"m":"6282B4ED"}}'

For my first blind, which is 01, this does not seem to be an issue at all:

Received message: b'STA:{"type":"ER","sid":"01","adr":"01","state":"1002","ts":{"m":"6282C160"}}'
Sending PUBLISH (d0, q0, r0, m56), 'b'mediola'', ... (76 bytes)
Sending PUBLISH (d0, q0, r1, m57), 'b'mediola/blinds/mediola/ER_01/state'', ... (6 bytes)

It seems to be related to the handle_packet_v6 method within the mediola2mqtt.py, but i didn't dig any deeper as i am not an expert on python anyways.

I remember changing some stuff for recognition and sending commands towards the gateway for blinds higher than 09 as the standard procedure didn't seem to work. So this might be related that it needs adaptions as well?

Thanks in advance for your great efforts already! Best regards, Thomas

andyboeh commented 2 years ago

Well, according to #8 you modified the script yourself. Without knowing your modifications we're just guessing here.

For the unmodified mediola2mqtt.py: 0E is converted to 14 and this needs to be defined in the configuration file.

One important thing: After the tries in #8 you might have to start from scratch by deleting your Elero blinds from the MQTT broker and having mediola2mqtt.py re-register them.

ThoSig commented 2 years ago

hi @andyboeh! The changes are rather simple, in the on_message i just replaced the format(int(adr), "02x") + 0x parts with simply adding up those two like adr + 0x (x stands for open, close whatever). All blinds below 10 still work just fine. So re-registering might not be needed in this particular case.

I actually changed my configuration file, so that 0E was '14' (which was also my first approach when i installed and registered it the first time), but unfortunately it did not work this time as well..

andyboeh commented 2 years ago

That's strange if that works for you. adr + 01 returns "1401" which does not correspond to the blind address of "0E01". However, I might have missed a call to .upper() so that "0e01" becomes "0E01". Could you give it a try?

format(int(adr), "02x") + 0x).upper()

Please make sure that all devices are reported in int within Home Assistant. You can check that if you go to one of the Mediola Devices and click on 'MQTT Info': Screenshot-20220516-2347

If something is in hex, you will have to flush the MQTT device configs and start from a fresh configuration.

Another option would be hex addresses everywhere, but then you will need to remove all calls to format(...).

ThoSig commented 2 years ago

Yep, that is exactly what i did, just removing all format calls and use hex for messages and commands all the way. I basically ignored the fact, that UDP broadcasts did not work as they were not received at all before.

I actually added all my blinds manually, which means, no auto-discovered devices (which i back then did not get to work either, so maybe its just me being stupid). However, those seem to work just fine and the typecasting of all values was fine so far as well. i will give it a go and add .upper() and see what happens. For now i am just facing the issue, that it does not want me to "rebuild" the addon in home assistant. So i might need to re-install it anyways because for some reason where supervisor states: ERROR (MainThread) [supervisor.addons] Add-on local_mediola2mqtt is not available inside store

UPDATE: Unfortunately adding .upper() did not make a difference in that regard. All blinds up until 09 seem to work just fine, all others don't. This is partially, what my configuration looks like:

...
- type: ER
  adr: '08'
  name: KiZ2 Fenster
  mediola: mediola1
- type: ER
  adr: '09'
  name: KiZ1 Balkontüre
  mediola: mediola1
- type: ER
  adr: '10'
  name: Bad Fenster
  mediola: mediola1
- type: ER
  adr: '11'
  name: SZ kleines Fenster
  mediola: mediola1
...

Also inside the log when starting the addon, it does look good so far:

Sending SUBSCRIBE (d0, m19) [(b'mediola/blinds/mediola/ER_10/set', 0)]
Sending PUBLISH (d0, q0, r1, m20), 'b'homeassistant/cover/mediola_ER_10/config'', ... (385 bytes)
Sending SUBSCRIBE (d0, m21) [(b'mediola/blinds/mediola/ER_11/set', 0)]
Sending PUBLISH (d0, q0, r1, m22), 'b'homeassistant/cover/mediola_ER_11/config'', ... (392 bytes)
Sending SUBSCRIBE (d0, m23) [(b'mediola/blinds/mediola/ER_12/set', 0)]
Sending PUBLISH (d0, q0, r1, m24), 'b'homeassistant/cover/mediola_ER_12/config'', ... (396 bytes)
Sending SUBSCRIBE (d0, m25) [(b'mediola/blinds/mediola/ER_13/set', 0)]
Sending PUBLISH (d0, q0, r1, m26), 'b'homeassistant/cover/mediola_ER_13/config'', ... (392 bytes)
Sending SUBSCRIBE (d0, m27) [(b'mediola/blinds/mediola/ER_14/set', 0)]
Sending PUBLISH (d0, q0, r1, m28), 'b'homeassistant/cover/mediola_ER_14/config'', ... (391 bytes)

So i will revert back to non-formatting the values and will see if hex works just fine.

andyboeh commented 1 year ago

We discovered just today that the v6 has all values in dec while the v4 has all values in hex. Dealing with this is more complicated than it seems in the first place, so this will have to wait for some time.

ThoSig commented 1 year ago

So i assume, that also a bad reporting of the state of the blind is related to this? At least in Home Assistant, the configured blinds do not get any updates, allthough i see received messages in the log which also contain a state.. So i assume the addon needs to be modified for this as well to work well with V6 gateways? Or is there anything else that needs to be configured properly for HA? With the latest release, there should even be a functionality to set a certain height and ventilation for covers. Did you try that one out already? Does it work for this addon? https://www.home-assistant.io/blog/2023/04/05/release-20234/#new-dialogs-for-alarm-cover-and-fan-entities

BR