-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rfbridge MQTT triggered via MQTT_TOPIC_RFOUT ( {identifier}/rfout/set ) is not queued #422
Comments
There is a queue in the rfbridge module. The queue holds the individual messages and sends them one by one every RF_SEND_DELAY (500ms). When you send an MQTT message "2ABC017C042E500551,2" two messages are enqueued and sent with half a second delay. If your device uses the same code for ON and OFF you will certainly see some disco lights... Also, another "feature" might come to play. There is a flood window for switches. It's meant to prevent physical relays to wear out but it applies to any switch actually. So if you are sending a code that ESPurna identifies with a switch (it's in the RFBridge tab in the web interface) the flood window protection will rule and it will prevent more than 5 changes in less than 3 seconds. |
Original comment by Phil Elson (Bitbucket: pelson, GitHub: pelson): Thanks for your reply. I can see that repeat messages are queued, but can't see where the queue is used for new messages incoming. The problem I have is that I'm getting 5-10 messages at almost exactly the same time (a group of rf-plugs, controlled by home assistant). In this situation, I haven't paired the espurna switches with the codes, and I'm using the MQTT Is there any code that prevents concurrent sending (and therefore turning the device into an rf jammer), as I couldn't see it? I was looking for some locking mechanism in Do you have an interest in having the ability to queue up distinct codes/messages? Without such functionality, I'd basically need to push delays into the code that publishes the mqtt messages, which I'd rather do at the receiving end (i.e. in espurna). |
Original comment by Biddster (Bitbucket: biddster, GitHub: biddster): Hi Phil. I've noticed the same behaviour this week too. I have 4 433mhz lamps controlled by node red which turn on at precisely the same time. Randomly, several of the lamps won't turn on. If I toggle them individually, they are very reliable indeed. If I protect the |
@pelson @biddster I'm checking the code. The _rfbSend(char*, int) was not properly enqueuing the messages since it always tries to push the first one it receives... I'm changing the code (available in the dev branch) to make it always enqueue them and start the ticker to send them every RF_SEND_DELAY including the first one. It's in the dev branch now. Maybe one of you two can give it a try? |
Original comment by Biddster (Bitbucket: biddster, GitHub: biddster): Hi @xoseperez, I've think I've got a pio based build environment up a running thanks to homebrew. I don't have the flash cables to hand as I used my dad's (who lives a long way away) to get started. I presume I can just build the ota and flash via the web admin? I've tried |
If your device is connected to the same network you are you can do :
Where XXX.XXX.XXX.XXX is your device IP. |
Original comment by Biddster (Bitbucket: biddster, GitHub: biddster): Ok, I've tried the dev branch. It doesn't switch any 433mhz things on/off. Telnet from 1.12.1 which is working:
Telnet from HEAD of dev branch:
It just stops and doesn't issue any of the actions. |
The debug log looks good. It's sending the code 3 times as requested and receiving 3 acknowledgements from the EFM0 (that's action 0xA0). Are you sure that code should trigger something? Is that something in the range of the rfbridge? |
Original comment by Biddster (Bitbucket: biddster, GitHub: biddster): The debug log that looks good is from the official build of 1.12.1. I just put it there for comparative purposes. The second snippet is the output from the head of the dev branch. It doesn't output anything after the initial received message. |
Original comment by Phil Elson (Bitbucket: pelson, GitHub: pelson): Just to add that I've now tested the change, and am pleased to say that it works very well. I was half expecting to see only one light turned on per RF_SEND_DELAY, but the whole thing is relatively quick (and seems to be quicker than the 500ms setting). Thanks for fixing this so quickly! Really great addition - I'm starting to feel like I need to write my findings down in a blog.... watch this space. :) |
@biddster It's working for me...
Can you update and try again? |
I'm happy with the change and think it is probably good to close on my behalf. Thanks @xoseperez! |
Must be my build system I guess. I'll update and try again. |
I've tried clean builds again, pushing the ota directly to the bridge. Same result. It doesn't execute the actions. I've checked the firmware and the version is updating when I push the ota. If I go to the admin console and upload your released firmware, it all works again. So I think it's something environment on my machine/build. Somehow. Given that you and @pelson have had success, it must be something I'm doing. |
Could it be that you have TERMINAL_SUPPORT and/or SERIAL_DEBUG_ENABLED to 1 in your build? |
I'll check. All I do is:
|
Nope, I've made sure that both TERMINAL_SUPPORT & SERIAL_DEBUG_ENABLED are 0 and I still have the same problem. Have I missed some build instructions somewhere? My expectation was that |
OK, let's recap.
Can you paste here the debug log on boot? |
Here's what the admin console reports after the ota: This is all I see in the telnet debug:
Is there another log I'm not aware of which contains the boot log? |
Looks like you have an extra slash at the end of the MQTT root topic. Maybe you have "{identifier}/" there? Try removing that slash. |
That trailing slash was it:
I don't always see 3 actions logged, see the snippet above. |
I'm adding some checking code to prevent that from happening again and fixing the hints on the web UI. Yes, sometimes it skips a message, increasing the RF_SEND_DELAY setting will probably fix that but it could also increase latency. |
Many thanks for all the assistance @xoseperez |
Originally reported by: Phil Elson (Bitbucket: pelson, GitHub: pelson)
I've got v1.12.0 on my sonoff rf 433 bridge and am using it as a generic MQTT<>RF interface. Essentially, I have many lights configured with home assistant that, when switched, publish the appropriate rf code via the
{identifier}/rfout/set
MQTT channel.This works really well for individual commands, but ends up jamming when there are multiple commands being sent at the approximately the same time. I know there is a Ticker being used to allow repeated commands (defined by passing the
{command},{repeats}
as the data payload to the topic), but I don't see that there is anything preventing the situation where many commands are submitted becoming an RF jammer.Steps to reproduce:
To confirm, modifying the payloads to include the repeat count (e.g.
2ABC017C042E500551,2
) does have an effect (more likely to succeed) but also queues them up such that there is a terrible disco effect if the same switch is turned on and off in a short period of time.Looking at the codebase, would doing something like the following have the desired effect? (Note: completely untested, and with very little understanding of the codebase)
I've been struggling to build my own images of espurna (well, technically it is the upload phase that I've had problems with in platformio...), and have had to rely on the on pre-build ones so far, so might struggle to test any proposed changes.
The text was updated successfully, but these errors were encountered: