suda / homebridge-platform-energenie

4 stars 4 forks source link

Can't control via homebridge.... #4

Open jaquesp opened 8 years ago

jaquesp commented 8 years ago

Good evening, i've followed the instructions i can find to install home bridge (successfully controlling nest and various wemo switches) I installed the Energenie Platform and am unable to control the switches (which I have programmed and can successfully control with the ENER002.py sample program provided by Energenie). When I start home bridge I get the following:

Jul 27 20:03:55 raspberrypi homebridge[3747]: [7/27/2016, 8:03:55 PM] [Energenie Platform] Initializing Energenie platform... Jul 27 20:03:55 raspberrypi homebridge[3747]: [7/27/2016, 8:03:55 PM] [Energenie Platform] Initializing platform accessory 'Zap Plug Port 1'... Jul 27 20:03:55 raspberrypi homebridge[3747]: [7/27/2016, 8:03:55 PM] [Energenie Platform] Initializing platform accessory 'Zap Plug Port 2'...

and my config.json is pasted at the bottom follows. Despite HomeKit maintaining the status of the switches (on/off) it doesn't control the switches themselves (the pi is within inches of the switch itself).

Any help / troubleshooting you can provide would be grateful received!

        {
            "platform": "Energenie",
            "name": "Energenie Platform",
            "delay": 500,
            "switches": [
                  {
                       "name" : "Zap Plug Port 1",
                       "on": {
                               "command": "on",
                               "socket": 1
                       },
                       "off": {
                               "command": "off",
                               "socket": 1
                       }
                  },
                  {
                       "name" : "Zap Plug Port 2",
                       "on": {
                               "command": "on",
                               "socket": 2
                       },
                       "off": {
                               "command": "off",
                               "socket": 2
                       }                  
            }
            ]
        }
ghost commented 8 years ago

Sorry to hear you are having problems.

Some ideas: Are your plugs connected to separate wall sockets? Try separating them with a distance of 2 metres.

What is the status of the led light when your plugs are on? Flashing or still?

jaquesp commented 8 years ago

Thanks for getting back to me! The plugs are both solid red when they're on and they're separated by more than 2 metres. Controlling them is fine via the python method RPio but not via homebridge-energenie. Do you know what I should expect to see in the syslog? Do you have an example (working) configuration file I could take a look at? Thanks again!

ghost commented 8 years ago

My config.json file.

{
   "bridge": {
       "name": "#####",
       "username": "CC:22:3D:E3:CE:30",
       "port": 51826,
       "pin": "031-45-154"
   },
   "description": "",
   "platforms": [
       {
         "platform": "Energenie",
         "name": "Energenie Platform",
         "delay": 500,
         "switches": [
               {
                       "name" : "Living Room Lights",
                       "on": {
                               "command": "on",
                               "socket": 1
                       },
                       "off": {
                               "command": "off",
                               "socket": 1
                       }
               }
         ]
       }
   ]
}
jaquesp commented 8 years ago

Thanks for that! I tried your configuration with no effect. Do you know how I go about completely uninstalling homebridge-energenie (and all dependencies) with a view to re-installing? As I say, I know the lights work and respond to the RF signals from the Pi, just not via home bridge!

Thanks again!

jaquesp commented 8 years ago

Would be really interested to see what you see in your log file. Do you see anything more than this?

Jul 28 14:15:57 raspberrypi homebridge[17618]: [7/28/2016, 2:15:57 PM] Loaded plugin: homebridge-platform-energenie Jul 28 14:15:57 raspberrypi homebridge[17618]: [7/28/2016, 2:15:57 PM] Registering platform 'homebridge-platform-energenie.Energenie' Jul 28 14:15:57 raspberrypi homebridge[17618]: [7/28/2016, 2:15:57 PM] ---

Jul 28 14:16:03 raspberrypi homebridge[17618]: [7/28/2016, 2:16:03 PM] Loaded config.json with 1 accessories and 2 platforms.

Jul 28 14:16:03 raspberrypi homebridge[17618]: [7/28/2016, 2:16:03 PM] [Energenie Platform] Initializing Energenie platform... Jul 28 14:16:03 raspberrypi homebridge[17618]: [7/28/2016, 2:16:03 PM] [Energenie Platform] Initializing platform accessory 'Lamp 1'... Jul 28 14:16:03 raspberrypi homebridge[17618]: [7/28/2016, 2:16:03 PM] Loading 1 accessories...

jaquesp commented 8 years ago

ok - a bit of further digging. I can get the switches to come on and off using the switch.py code in:

/usr/local/lib/node_modules/homebridge-platform-energenie/node_modules/energenie

so I know the code works to get the switches on and off. I don't know enough about how the index.js works to call the python, but I still don't get any notification in the logs that energenie is doing anything after startup. odd.

Help!

jaquesp commented 8 years ago

OK, for some reason the spawn process wasn't working, so I re-wrote the index.js to use exec instead and the switches work as expected - example:

`    switchOn: function(socket, callback) {

        if (socket == null) socket = 0;
        else socket = parseInt(socket, 10);

child = exec("python " + __dirname + "/switch.py on " + socket, function (error, stdout, stderr) {
  if (error !== null) {
    console.log('exec error: ' + error);
  }
});`

But the switches don't maintain / persist state when homebridge is reset. Would anyone be able to point me in the direction of how this is achieved so that the correct state can be rstored when homebridge is restarted? Is this even possible?

Thanks, Paul

ghost commented 8 years ago

Hello,

I am happy to hear you got it somewhat working.

Regarding your fixes. I do not maintain this project but why not submit a pull request? Fixes submitted could help others in future!

Thanks.

chrisrichards commented 7 years ago

I just had the same issue and found it was caused by the homebridge user not being in the gpio group, running

sudo adduser homebridge gpio

fixed it.

jaquesp commented 7 years ago

@chrisrichards Chris - apologies for the slow response. Did this resolve the persistence issue for you if homebridge is reset? The changes I made (hacked - see above) effectively automatically switch off the energenie plugs at startup to ensure the state is at a known point when homebridge starts. It's annoying but it works.

chrisrichards commented 7 years ago

@jaquesp nope, this just removes the need to rewrite the spawn process, it doesn't fix the persistence problem

TheChallinor commented 5 years ago

How does this actually work then & link to Energenie?

Do you just replace the "name" : "Zap Plug Port 1", with the actual name from the Energenie app then?

So for example

"name" : "Cinema Lights",

girishkumarkh commented 4 years ago

did you try pip install energenie it worked for me -- for some reason energenie python library wasn't installed on mine.