luisiam / homebridge-cmdswitch2

CMD Plugin for HomeBridge (API 2.0): https://github.com/nfarina/homebridge
Apache License 2.0
176 stars 29 forks source link

Individual on/off work. Group on/off don't #7

Open ehusar opened 7 years ago

ehusar commented 7 years ago

I am having an issue that I hope you can help me with. Or at least confirm it should work. I am using cmdswitch2 with 5 RF outlets to turn lamps and other stuff on/off. Everything works great as long as I I on/off them individually. If I create a group in the Home app then no switches get set to on/off. Nothing happens.

Here is my config file. You can tell I am using rfoutlet example and the codesend to perform the calls.

{
"bridge":{
      "name":"House",
      "username":"A1:B2:C3:E3:CE:AB",
      "port":36631,
      "pin":"031-45-154"
   },
   "description":"iHome",
   "accessories":[

   ],
   "platforms":[
      {
         "platform":"cmdSwitch2",
         "switches":[
            {
               "name":"1",
               "on_cmd":"/var/www/html/rfoutlet/codesend 1056003",
               "off_cmd":"/var/www/html/rfoutlet/codesend 1056012"
            },
            {
               "name":"2",
               "on_cmd":"/var/www/html/rfoutlet/codesend 1062147",
               "off_cmd":"/var/www/html/rfoutlet/codesend 1062156"
            },
            {
               "name":"3",
               "on_cmd":"/var/www/html/rfoutlet/codesend 1054147",
               "off_cmd":"/var/www/html/rfoutlet/codesend 1054156"
            },
            {
               "name":"4",
               "on_cmd":"/var/www/html/rfoutlet/codesend 1054467",
               "off_cmd":"/var/www/html/rfoutlet/codesend 1054476"
            },
            {
               "name":"5",
               "on_cmd":"/var/www/html/rfoutlet/codesend 1054003",
               "off_cmd":"/var/www/html/rfoutlet/codesend 1054012"
            }
         ]
      }

   ]
{
luisiam commented 7 years ago

There's nothing the plugin can do regarding group configuration. Group is something inside HomeKit which we have no control over it from homebridge.

ehusar commented 7 years ago

I figured out what the issue was about a hour ago. When you click on each accessory to executer it there is a delay in the time it take to move from one button to other. When a Group, Scene, or Automation is created it executes everyone in one sweep. In my cases that means that Homebridge or the Home app, I am not sure which, send all the RF commends for the On and Off states. All of my RF is going through the RPi with a RF Transmitter attached to it. Well, all the commands hit the transmitter at the same time using codesend. The transmitter can only transmit one code at a time. This is what breaks it when you have more than one RF device in your Group, Scene, or Automation.

Here is what I had to end up doing in the config file. I added the sleep to the command. In my case I a testing with 5 outlet switches. The first two are in the living room. The other 3 are in a home theater. I had to offset the sleep commands to add a delay so codesend wasn't getting fed them all at the same time.

I am not going to be able to have 30 RF accessories being controlled over one RPi. I will have one RPi per floor in my house setup. That should allow me to void this issue.

Another option might be multiple transmitters on one RPi. I am not sure if that is possible or not but I think that would be too hard to manage.

Now that you know the issue I wonder if there is anything that cdmswitch2 could do for us. I am guessing nothing but it doesn't hurt to have other people thinking about options to delay the sends. It would cool to send all commands to an array then fire them off one at a time. Maybe not, I am not sure. That is getting pretty specific to RF stuff and that is not cdmswitch2 purpose.

      {
           "name":"1",
           "on_cmd": "/var/www/html/rfoutlet/codesend 1056003",
           "off_cmd": "/var/www/html/rfoutlet/codesend 1056012"
        },`{
           "name":"2",
           "on_cmd": "sleep .2 && /var/www/html/rfoutlet/codesend 1062147",
           "off_cmd": "sleep .2 && /var/www/html/rfoutlet/codesend 1062156"
        },
        {
           "name":"3",
           "on_cmd": "/var/www/html/rfoutlet/codesend 1054147",
           "off_cmd": "/var/www/html/rfoutlet/codesend 1054156"
        },
        {
           "name":"4",
           "on_cmd": "sleep .2 && /var/www/html/rfoutlet/codesend 1054467",
           "off_cmd": "sleep .2 && /var/www/html/rfoutlet/codesend 1054476"
        },
        {
           "name":"5",
           "on_cmd": "sleep .4 && /var/www/html/rfoutlet/codesend 1054003",
           "off_cmd": "sleep .4 && /var/www/html/rfoutlet/codesend 1054012"
        }
luisiam commented 7 years ago

I believe adding a sleep is the best solution. Inside the plugin, all the switches are actually handled independently.