stanleypa / eleropy

Python code to control elero blinds
GNU General Public License v3.0
15 stars 7 forks source link

How to find out channel number? #1

Open chrilis opened 1 year ago

chrilis commented 1 year ago

Hi @stanleypa, thank you so much for sharing your work!

This is actually a question and not an issue, so feel free to turn it into a discussion if you want.

I have two VarioTel 2 remotes, one controls 2 blind and the other 4. Strangely I can't control the first blind of each remote, all others work fine. If I control the two blinds with the remote, I do receive the correct status messages in the MQTT server, so I think the adresse is correct. My assumption is that the channels are not correct. Right now, I just use the channel numbers indicated by the remote`s LED (1 - 5). I tried to sniff the traffic and check the channel, but if I understood correctly, I get a different channel for each received message (even if the blind is the same). So I'm not sure how to get the correct channel number for each blind.

I must add that I'm using a CC1101 module for 443MHz, but I don't think this is related as I'm receiving messages from the two blinds and I can control the all other blinds that are much further away without problems.

Here is my current conf.py-file (with masked addresses):


remote_addr = [ [0x3F, 0xE0, 0x01], [0xFB, 0xD1, 0x01] ]

remote_blind_id = [
        [
          [0xXX, 0xXX, 0xXX, 0x01], # does not work
          [0xXX, 0xXX, 0xXX, 0x02], # works
          [0x00, 0x00, 0x00, 0x03], # placeholder
          [0x00, 0x00, 0x00, 0x04], # placeholder
        ],
        [
          [0xXX, 0xXX, 0xXX, 0x01], # does not work
          [0xXX, 0xXX, 0xXX, 0x02], # works
          [0xXX, 0xXX, 0xXX, 0x03], # works
          [0xXX, 0xXX, 0xXX, 0x04], # works
        ]
]

I would be very happy if you could help me. Thanks again!

stanleypa commented 1 year ago

The channel actually has nothing to do with the led number. It can be any number from 1 to 254. The best way to find it is look at the output of the esp32 uart or raspberry pi process while you send commands from your remote to the blind. It may well be different for each of the two remotes. Look for the "chl" parameter where the src is you remote address and the destination is the address of the blind with the comment "does not work".

The 433MHz module working is not that surprising, the chip is the same, just the antenna tuning passive components will be different. I'd assume a 8.2cm antenna would still be better than a 16.x cm one that would normally be used for 433 MHz. Range won't be as good but the blinds form a mesh network of sorts, so in theory you only need to be able to communicate with the nearest one. You should get an idea of which blinds you can "see" and how well by looking at the rssi entries in your mqtt server.

chrilis commented 1 year ago

Thanks for your quick reply! I tried to find lines in the output of the python script running on the Raspberry Pi, but I couldn't find any with the remote address as src or the non-working blind address as des. This gave me the idea that I might have mixed up the addresses of the blinds and remotes (maybe because of the mesh network). Additionally I couldn't find any line where src, bwd and fwd were identical. Shouldn't this be the case for messages send from the remote?

But then I randomly tried a few channels and it worked with chl=0x11 for the first blind of each remote. Now I'm even a bit more confused 😄

stanleypa commented 1 year ago

I think several remotes use 17 instead of 1 for the first channel, not sure why. Also although they will probably assign the others in ascending order the first time they are programmed there is no guarantee. I have a remote with channel number 20,21, 51 and 161 for e.g. (I did reprogram a lot when setting up my system).

I would guess the reason you don't see the messages when you issue a command from the remote is related to the mismatched radio. The command must be sent if your blind reacts - so the module probably isn't receiving the message cleanly - messages which don't pass a CRC check are discarded.

Also the best setting of the frequency registers 0x0E and 0x0F (cc1101.py) depend on the module hardware (quality of the clock crystal?) - values between 0x71,0x70 and 0x72,0x60 were required to get my 3 modules transmitting/receiving on 869500 which is the frequency my remotes and blinds approximate to.

silver085 commented 1 year ago

Dear @stanleypa I'm trying to figure around this code, using a CC1101 module as well with my elero blinds, unfortunately what I can sniff is mostly badpkt. Do you have any hint for me on how to fine tune the registers? I am using the VarioCom remote and not the VarioTel, I don't know if this might be the issue. Thanks a lot.

stanleypa commented 1 year ago

When you say "mostly badpkt" does that mean some are packets are good? If that's the case then I wouldn't expect the remote you're using to be the issue. Tuning the frequency helped me - these cheap modules seem to vary a bit - try tweaking the follow two registers - 0x0E 0x71-0x72 and 0x0F 0x00-0xF0 in steps of 0x10 (32 settings) should be more than enough. in cc1101.py: self.writeReg(0x0E, 0x71) # 71 may need tweaking self.writeReg(0x0F, 0xC0) # 7A may need tweaking

it would be helpful to see the output - both the good and bad packets.

silver085 commented 1 year ago

@stanleypa : Hi, I did like you said, and finally this is the outcome stream: len= 32, cnt= 79, typ=6A, chl=1,src=[CE7355],bwd=[CE7355],fwd=[CE7355] - des=2::[C30138],:[CC0138],rssi=-21.5,lqi=113,crc=1, pay=00:00:10:00:00:00:00:40: len= 29, cnt= 251, typ=CA, chl=79,src=[C30138],bwd=[C30138],fwd=[CE7355] - des=1::[CE7355],rssi=-60.5,lqi=79,crc=1, pay=00:00:00:00:00:00:0D:90:

I'm assuming that the 0xCE, 0x73, 0x55 is the address of the remote communicating with the blind [C30138],[CC0138].

Although if I put the configuration like this: remote_addr = [ [0xCE, 0x73, 0x55]] and remote_blind_id = [ [[0xC3, 0x01, 0x38, 0x01], [0xCC, 0x01, 0x38, 0x01]]] And then I try to subscribe to topic "cc1101mqtt/Status/C3:01:38" I see nothing, or even if I try to execute programmatically a command up/down, no reaction from the blind. Can you point me in the right direction?

Thanks a lot! I really appreciate your work :)

LG

stanleypa commented 1 year ago

I presume you connected to the mqtt server okay? When the program detects a type 0xCA message it will try to publish a message to the topic defined in conf.py

#mqtt server config - currently as simple as possible
mqtt_addr          = '127.0.0.1'
mqtt_port          = 1883
mqtt_alive         = 60
mqtt_status_topic  = "cc1101mqtt/status/"
mqtt_rssi_topic    = "cc1101mqtt/rssi/"
mqtt_command_topic = "cc1101mqtt/command/"

When I wrote the readme I was using "Status" and then obviously changed it to "status" - the readme should refer to the configuration variable - so if you didn't change it you should use "cc1101mqtt/status/"

if the publish fails I'd expect an error message. If you didn't see that then check with a tool like MQTT Explorer to see all the messages that are published.

BTW - It looks like your remote sends to 2 blinds - (des=2::[C30138],:[CC0138]) - although only C30138 responds. So I'd just program that for now.