andyboeh / mediola2mqtt

Mediola MQTT Gateway
11 stars 13 forks source link

discovery of state of elero blinds #3

Open partydiktator opened 3 years ago

partydiktator commented 3 years ago

In my setup the discovery of the state on elero blinds is not working. I'm using a v6 mediola gateway. I don't seem to receive any broadcast messages of the gateway. Sniffing my network i found out that the v6 gateway is broadcasting on udp/1901. I changed the port in my setting but i'm still not getting any information on state of my blinds. I also turned debug on - the only messages i'm receiving are ping-responses.

Maybe this is an issue with the v6 gateway. Additionaly, my gateway is only broadcasting messages when a blind is closed or opened. So there are no messages will opening or closing. In this case it might be better to discover the blinds states by using the XC_FNC=GetStates request.

andyboeh commented 3 years ago

I only have a v4, it broadcasts on 1902 not 1901. If 1901 is not a typo, then you need to change the port in the configuration of mediola2mqtt and forward the port to the add-on (the configuration for this should be just below the editor for the add-on configuration). The documentation provided by Mediola is actually the v5 documentation, there is none for the v6.

This is very important information because I was going to hard-code the port number in the upcoming release.

As far as I know, it depends on the type of Elero blind you have what state information is published.

Does the state in XC_FNC=GetStates actually change while the blind is moving (it does for me, but the broadcast contains the same information)?

partydiktator commented 3 years ago

v6 is broadcasting on udp/1901 (so no typo).

How can i change the port forward for the add-on because that already seems to be hardcoded:

image

And yes, XC_FNC=GetStates is changing while a blind is moving. I seem to get the following blind states

blind is closed: {XC_SUC}[{"type":"ER","sid":"01","adr":"01","state":"1002","ts":{"m":"60C22432"}} blind is opening: {XC_SUC}[{"type":"ER","sid":"01","adr":"01","state":"100A","ts":{"m":"60C22412"}} blind is closing: {XC_SUC}[{"type":"ER","sid":"01","adr":"01","state":"100B","ts":{"m":"60C22432"}} blind is open: {XC_SUC}[{"type":"ER","sid":"01","adr":"01","state":"1001","ts":{"m":"60C22470"}} blind is in open position but stopped: {XC_SUC}[{"type":"ER","sid":"01","adr":"01","state":"100D","ts":{"m":"60C22530"}}

andyboeh commented 3 years ago

I just had a look at that again: Leave the configuration in the add-on config file at port 1902. That's the port the Python script in the container is listening on. Then, change the field "host" in your screenshot to "1901". This will forward UDP packets arriving at port 1901 on your machine to the mediola2mqtt script at port 1902.

So it's most probably perfectly valid to remove the UDP port configuration option in the mediola2mqtt script and rely on port-forwarding :)

partydiktator commented 3 years ago

Thanks, i'm receiving udp broadcasts now.

partydiktator commented 3 years ago

Just a brief update on state discovery: i'm receiving udp broadcasts but setting the blinds state is not happening. From my log:

Received message: b'STA:{"type":"ER","sid":"04","adr":"04","state":"1002","ts":{"m":"60C7C66B"}}'
Sending PUBLISH (d0, q0, r0, m140), 'b'mediola'', ... (76 bytes)
Received message: b'STA:{"type":"ER","sid":"04","adr":"04","state":"1002","ts":{"m":"60C7C66B"}}'
Pub: 140
Sending PUBLISH (d0, q0, r0, m141), 'b'mediola'', ... (76 bytes)
Pub: 141

The state of the blind in Home Assistant is 'unknown'. Again - this might be an issue with the v6 gateway behaving somewhat different.

andyboeh commented 3 years ago

Again - this might be an issue with the v6 gateway behaving somewhat different.

It is - On my gateway, the status message starts with {XC_EVT} and not with STA: I fixed that in the current "master" branch, could you please check whether it works now?

partydiktator commented 3 years ago

Hi, i'm now getting an error:

Received message: b'STA:{"type":"ER","sid":"05","adr":"05","state":"1002","ts":{"m":"60C877F3"}}'
Sending PUBLISH (d0, q0, r0, m15), 'b'mediola'', ... (76 bytes)
Error parsing status packet
Received message: b'STA:{"type":"ER","sid":"05","adr":"05","state":"1002","ts":{"m":"60C877F3"}}'
Sending PUBLISH (d0, q0, r0, m16), 'b'mediola'', ... (76 bytes)
Error parsing status packet
Pub: 15
Pub: 16
andyboeh commented 3 years ago

Ah sorry, my bad: The v6 packet is more different than I thought. This will be a larger rework, so it will have to wait 'til the end of the week. Stay tuned!

andyboeh commented 3 years ago

The latest commit deals with the different packet formats. It works on my v4 so I'm very interested in your experience with the v6!

partydiktator commented 3 years ago

No more error message but the state of the blind doesn't get set.

Received message: b'STA:{"type":"ER","sid":"04","adr":"04","state":"1002","ts":{"m":"60CC7C50"}}'
Sending PUBLISH (d0, q0, r0, m13), 'b'mediola'', ... (76 bytes)
Sending PUBLISH (d0, q0, r1, m14), 'b'mediola/blinds/ER_04/state'', ... (7 bytes)
Pub: 13Received message: b'STA:{"type":"ER","sid":"04","adr":"04","state":"1002","ts":{"m":"60CC7C50"}}'
Sending PUBLISH (d0, q0, r0, m15), 'b'mediola'', ... (76 bytes)
Sending PUBLISH (d0, q0, r1, m16), 'b'mediola/blinds/ER_04/state'', ... (7 bytes)Pub: 14
Pub: 15
Pub: 16
andyboeh commented 3 years ago

Sorry for that, my mistake (it's really hard to get things right when you don't own the hardware). Could you try again with the latest commit?

partydiktator commented 3 years ago

Thank you, it's working now!

So with the v6 gateway i'm having the following situation:

The v6 gateway doesn't seem to broadcast much information via UDP. I only get a broadcast after a blind is fully closed or fully opened. The gateway is not broadcasting while a blind ist closing, opening or when it stopped in an intermediate position.

So for the v6 gateway the only reliable way to check its state is using XC_FNC=GetStates

Do you think it would make any sense adapting your code to "pull" the blinds states using XC_FNC=GetStates ?

And: i don't know about your v4 gateway but i'm also not getting any broadcast when i control a blind using a remote control (VarioTel 2 in my case). Although the remote control seems to directly talk to the blind, the gateway knows the blinds state, but doesn't broadcast it. Again, this could be achieved by using XC_FNC=GetStates

On the downside, usingXC_FNC=GetStates would spam the network

andyboeh commented 3 years ago

I'm glad it works now!

The v4 reports intermediate positions (opening, closing) so there is definitely a difference in the behavior. Unfortunately, the Mediola documentation does not cover the v6 at all (and v4 and v5 also only partially).

Do you think it would make any sense adapting your code to "pull" the blinds states using XC_FNC=GetStates ?

I'm not a big fan of polling, but you can try it. I don't know the impact on the gateway, the v6 has a quite capable CPU so that shouldn't be an issue, but the v4 is just a microcontroller.

And: i don't know about your v4 gateway but i'm also not getting any broadcast when i control a blind using a remote control (VarioTel 2 in my case). Although the remote control seems to directly talk to the blind, the gateway knows the blinds state, but doesn't broadcast it. Again, this could be achieved by using XC_FNC=GetStates

I do not get status updates either and my gateway doesn't know the state at all (TempoTel 2 IIRC). However, there is a XC_FNC=refreshER&adr=01 command that retrieves the blind's state via RF. At some point, I will add an option to automatically call refreshER at a predefined interval or via a MQTT button, but I haven't had the time to implement that.

SKis274 commented 2 years ago

And: i don't know about your v4 gateway but i'm also not getting any broadcast when i control a blind using a remote control (VarioTel 2 in my case). ~Although the remote control seems to directly talk to the blind, the gateway knows the blinds state, but doesn't broadcast it.~ Again, this could be achieved by using XC_FNC=GetStates

On the downside, usingXC_FNC=GetStates would spam the network

Is there actually a way to get this working with some kind of mqtt-automation or something like that? I'm not really good in that stuff... I'm using my TempoTel 2 multiple times per day and the current state would be nice - espacially when using other automations that are referenced to the states of the blinds.

andyboeh commented 2 years ago

I'm using my TempoTel 2 multiple times per day and the current state would be nice - espacially when using other automations that are referenced to the states of the blinds.

Unfortunately not. The Mediola is not capable of constantly receiving Elero commands. You have to call refreshER periodically to achieve that, but I suppose it can only be called a few times per hour (it produces quite some RF traffic and that is limited on the 868MHz band). Your better bet for your use case is getting a Centero Transmitter Stick as it can receive state changes from other remotes, if I remember correctly.