homebridge-rm-mini3 icon indicating copy to clipboard operation
homebridge-rm-mini3 copied to clipboard

Dummy data after sent command?

Open joq3 opened this issue 8 years ago • 12 comments

Hi,

I have added two IR codes to this plugin, and they work fine. But not if I send the same command after each other. So if I turn on my TV and then turn it off (uses the same IR code) it won't work. If I send another command in between it will work. I have found out that the Broadlink RM 3 Mini does not accept to send the same command after just being sent. So is it possible to add another "dummy command" to solve this?

This application has solved this using this solution I think: https://github.com/davorf/BlackBeanControl

Thank you!

joq3 avatar Dec 16 '16 17:12 joq3

I have now spoke with the developer of BlackBeanControl, and they used to use a Dummy command to send in between the normal commands. Explained here: https://community.openhab.org/t/broadlink-black-bean-rm-3-mini-ir-controller-integration-in-openhab/11453/102

Is this something you can integrate? Because right now I can't send the same command multiple times, which means I can start my TV but not turn it off?

joq3 avatar Dec 19 '16 09:12 joq3

@tattn Is it possible to fix this issue? I love the plugin, and it seems to work perfect as long as I don't send the same command more than once in a row. But it is quite unusable right now, as I can turn on my TV and not turn it off without turning on or off a light first.

Could you add an automatic dummy command that will be sent?

Thanks a lot!

joq3 avatar Dec 22 '16 13:12 joq3

Could you add an automatic dummy command that will be sent?

Actually, this plugin also sends a dummy command before sending IR codes. https://github.com/tattn/homebridge-rm-mini3/blob/master/sender.js#L5

Since this plugin does not send the same commands in succession, it may be another cause.

Umm...

tattn avatar Dec 25 '16 11:12 tattn

@tattn Great, but weird that it doesn't work. This is what my config looks like: http://pastebin.com/hp9i1Q23

The IR-code is captured using an Android phone with Broadlink app, and it always works if I send one of the IR codes and then the other. But never when using the same code twice.

What can I try to debug?

joq3 avatar Dec 25 '16 15:12 joq3

@tattn Now I am closer to a solution. I have read a dummy code from a remote I don't use to the RM3. And if I use this code in between my real codes when using Packet Sender (UDP / Port 80) it works amazing every time. So I went into /usr/lib/node_modules/homebridge-rm-mini3/sender.js and edited the IR code with mine: var broadcast = '5aa5aa555aa5aa55000000000000000000000000000000000000000000000000a2f3000037276a00528022a2f00d43b40100000090c80000178a382be0b953f51e066fa79407190dfec18c688af01de0dc428a1f11ace75a10dacb9050c542110e29cc734468d0ae6c476c87c99544bbd0587d14182256eb3b23c674c57d8a2852412c1c335003d6a5fa1d3080c9d1b6210983b3879657a6'

But it still doesn't work even though this works with Packet sender.

joq3 avatar Jan 02 '17 11:01 joq3

Thank you for trying a variety of ways.

I have no confidence, but maybe you need a waiting time. Please edit sender.js as following and retry.

module.exports = function (host, payload, callback) {
  var PORT = 80;

  var broadcast = '5aa5aa555aa5aa55000000000000000000000000000000000000000000000000a2f3000037276a00528022a2f00d43b40100000090c80000178a382be0b953f51e066fa79407190dfec18c688af01de0dc428a1f11ace75a10dacb9050c542110e29cc734468d0ae6c476c87c99544bbd0587d14182256eb3b23c674c57d8a2852412c1c335003d6a5fa1d3080c9d1b6210983b3879657a6'

  var message = new Buffer(payload, 'hex');

  var dgram = require('dgram');
  var client = dgram.createSocket('udp4');

  client.send(broadcast, 0, broadcast.length, PORT, host, function(err, bytes) {
    if (err) throw err;
    console.log('UDP message sent to ' + host +':'+ PORT);

    setTimeout(function () {
      client.send(message, 0, message.length, PORT, host, function(err, bytes) {
        if (err) throw err;
        console.log('UDP message sent to ' + host +':'+ PORT);
        client.close();

        callback(err);
      });
    }, 100) // wait for 100ms
  });
}

tattn avatar Jan 03 '17 02:01 tattn

@tattn Of course, thank you for helping me! That doesn't seem to make any difference. Do I need to remove the persist folder or cached folder from Homebridge after editing sender.js?

joq3 avatar Jan 03 '17 06:01 joq3

Hmm..I think that it's not necessary to remove the cache. Adding console.log('updated');, you can check whether it has been updated.

tattn avatar Jan 03 '17 09:01 tattn

Yey, I solved it, the wait time didn't matter but I kept the 20ms wait anyway. This was the solution, adding "new Buffer and () and 'hex'. That way I think the dummy code is sent as a hex code, and now it works perfect every time. var broadcast = new Buffer('5aa5aa555aa5aa55000000000000000000000000000000000000000000000000a2f3000037276a00528022a2f00d43b40100000090c80000178a382be0b953f51e066fa79407190dfec18c688af01de0dc428a1f11ace75a10dacb9050c542110e29cc734468d0ae6c476c87c99544bbd0587d14182256eb3b23c674c57d8a2852412c1c335003d6a5fa1d3080c9d1b6210983b3879657a6', 'hex');

joq3 avatar Jan 03 '17 20:01 joq3

@joq3 Wow! I had overlooked the bug :cry: Thank you very much! 🎉

I updated this plugin for the bug.

tattn avatar Jan 04 '17 03:01 tattn

Is the bug fixed? The command worked only first time for me...

ageorgios avatar Mar 01 '17 22:03 ageorgios

I'm still experiencing this bug on the latest version (0.1.7). When I send a command I can see that 2 UDP signals are being broadcasted, I'm assuming the second is the dummy command, however it has no effect and the only way to turn a device back off is to send a different command before going back to sending the original off command.

fairshare avatar Mar 30 '17 21:03 fairshare