Homebridge troubleshooting

Thanks @makerken!
I will try to continue as soon as I can make some time…
:+1:

1 Like

Thanks for guiding me till here @makerken!
At first, Homebridge did not appear in the Home App on my iPhone, but after I restarted it, it appeared and paired with the PIN as given (031-45-154)
Then the three items from the example sketch appeared one by one.

Here’s a screenshot:

The sketch is running on the RPi, with “Particle-Pi” but that does not react as intended.
One of the actions I used is the “D7” led on the Pi: The green LED next to the red power led. It blinked very briefly every time that I switched it on using the home app, but basically it should stay lit…

No problem, tomorrow I will experiment with a Photon to see if it all works…

:clap::older_man:

1 Like

Just wanted to chime in to let you know there are homebridge GUIs out there that make it a lot easier to manage plug-ins and edit your config file. A quick google should show you a couple :slight_smile:

2 Likes

Thanks for the tip @Moors7 , Sounds very promising!
Did you test one yourself?

How about this one?

Again, I’ll have to learn a lot about installing those plugins…
I am running Homebridge on a RPi but for most of these plugins they talk about installing on OS-X…

:wave::sleeping:

1 Like

Looks like the same one I have :slight_smile: Installing it is just another NPM command :wink:

1 Like

Just installed it:

sudo npm install -g --unsafe-perm homebridge-config-ui-x
/usr/bin/homebridge-config-ui-x -> /usr/lib/node_modules/homebridge-config-ui-x/bin/standalone.js

> node-pty@0.7.4 install /usr/lib/node_modules/homebridge-config-ui-x/node_modules/node-pty
> node scripts/install.js

make: Entering directory '/usr/lib/node_modules/homebridge-config-ui-x/node_modules/node-pty/build'
  CXX(target) Release/obj.target/pty/src/unix/pty.o
../src/unix/pty.cc: In function ‘void pty_after_waitpid(uv_async_t*)’:
../src/unix/pty.cc:489:69: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(v8::Local<v8::Object>, int, v8::Local<v8::Value>*) const’ is deprecated [-Wdeprecated-declarations]
   Nan::Callback(cb).Call(Nan::GetCurrentContext()->Global(), 2, argv);
                                                                     ^
In file included from ../src/unix/pty.cc:20:0:
../../nan/nan.h:1596:3: note: declared here
   Call(v8::Local<v8::Object> target
   ^~~~
  SOLINK_MODULE(target) Release/obj.target/pty.node
  COPY Release/pty.node
make: Leaving directory '/usr/lib/node_modules/homebridge-config-ui-x/node_modules/node-pty/build'

> node-pty@0.7.4 postinstall /usr/lib/node_modules/homebridge-config-ui-x/node_modules/node-pty
> node scripts/post-install.js

+ homebridge-config-ui-x@3.4.0
added 256 packages in 122.783s

But I can’t start it with http://localhost:8080

Have you added the relevant bits to your config file?

1 Like

Yes, I added it before the Particle platform:

    "platforms": [
        {
	"platform": "config",
      	"name": "Config",
      	"port": 8080,
      	"sudo": false,
        "platform": "Particle",
	"name": "Particle Devices",
	"access_token": "mytoken",
	"cloudurl": "https://api.spark.io/v1/devices/",
	"devices": [

As all lines end with a “,” I added a “,” after sudo": false as it wasn’t there…
This is all totally new ground for me and as I don’t know what I’m doing exactly, I must guess…

You’ve made a mistake in the configuration file :speak_no_evil:

The platforms array holds various platform JSON objects, and should look something like this:

"Platforms" : [
  {
    "Platform": "configuration",
    "setting2": "Yada Yada",
  },
  {
    "Platform":"Particle",
    "setting2": "lorum ipsum"
  }
]

Notice how each platform is its own JSON object (inbetween the { } brackets.)

1 Like

Oh, I see! :rofl:

This is my config.json file:

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:39",
        "port": 51826,
        "pin": "031-45-154"
    },
    
    "description": "Configuration file with one Particle platform with 3 accessories: 2 lights, 1 temperature sensor. Access token = Filip's, device id = Particle",

    "platforms":
    [
        {
		"platform": "config",
      	"name": "Config",
      	"port": 8080,
      	"sudo": true
		},
        {
        "platform": "Particle",
		"name": "Particle Devices",
		"access_token": "mytoken",
		"cloudurl": "https://api.spark.io/v1/devices/",
		"devices":
			[
				{
				"accessory": "ParticleLight",
				"name": "D7",
				"deviceid": "mydevice",
				"type": "LIGHT",
				"function_name": "onoff",
				"args": "0={STATE}"
				},
				{
				"accessory": "ParticleLight",
				"name": "D1",
				"deviceid": "mydevice",
				"type": "LIGHT",
				"function_name": "onoff",
				"args": "1={STATE}"
				},
				{
				"accessory": "ParticleTemperature",
				"name": "Temperature",
				"deviceid": "mydevice",
				"type": "SENSOR",
				"sensorType": "temperature",
				"key": "temperature",
				"event_name": "tvalue"
				}
			]
        }
    ]
}

I suppose that’s OK now?

Remark that I changed in the above config.json to:
“port”: 8080,
“sudo”: true

That was a tip in the installation instructions… and it connects now!
This is what I get on the RPi:

Tonight I will discover how it works…

Thanks Jordy!
:clap::older_man:

1 Like

Great! Homebridge works very stable and reliable now,
and the graphical UI for controlling the server is also very handy!

Thanks @makerken and @Moors7 for your fantastic guidance. I could not have done it without this great community…

Switching lights ON and OFF with Siri has no secrets for me anymore.
But now I’m trying to explore the communication possibilities in the other direction:

Reading sensors

From the sample “config.json” file, I kept this “device”:

               {
                    "accessory": "ParticleTemperature",
                    "name": "Room Temperature",
                    "deviceid": "222042000b47348882313031999",
                    "type": "SENSOR",
                    "sensorType": "temperature",
                    "key": "temperature",
                    "event_name": "tvalue"
                }

And I read @krvarma’s explanation:

Based on this, I tried various combinations of Particle.publish commands, such as:

Particle.publish("tvalue", "key=37",60,PRIVATE);

But the value shown in the Apple HOME App does not change: It shows 20° continuously…
Any experience with this somebody?

Edit: Applying the bold text above, I found the correct syntax for the event to publish:

Particle.publish("tvalue", "temperature=37",60,PRIVATE);

All works now! Thanks @krvarma

:wave::older_man:

Beyond me. I’ll have to checkout the GUI, looks like things have come a long way since I did it. I don’t have any experience with sensor types, just controlling on/off, and my sketch would have a state variable so I could cycle through light patterns.

I have a project upcoming that I want temperature/humidity readings from so I could be learning it.

1 Like

I’ve been studying an interesting add-on to this UI:


Till now I could not make that work…


Interesting!
That’s what I was also looking for…

How do you achieve this?

Looking at code 2 or 3 years old.

It looks like I just did the normal toggle sketch but added a state variable. Abridged, I haven’t run this code:

int toggle = 0;  // controls on/off
int state = 0;   // controls which pattern

void loop() {

    if(toggle == 1) {

        if(state == 3) {  // resets the state to the number of patterns you have
           state = 0
        }

        if(state == 0) {
          patternPart();
          strip.show();
        }

        if(state == 1) {
          pattern2Part();
          strip.show();
        }

        if(state == 2) {
          pattern3Part();
          strip.show();
        }

        delay(1000);

    } else {
        strip.clear();
        strip.show();
    }

}

int onoffLight(String command)
{
    toggle = command.toInt();
    if(toggle == 1) {
       state += 1;
    }
    return 0;
}

Remember to not block your code in a loop playing one single pattern in a loop, it needs to do the part and then delay to connect to the cloud.

Thanks for looking up your old sketch @makerken!
That’s clear, but what I really like to understand is: How does your device / accessory look in the config.json file for the Homebridge server to give you 2 variables?
And which device is visible in the Home App?
:thinking:

@Moors7: Do you use also these “Accessories” with the UI?
I tried to activate them by running Homebridge in -I (insecure) mode but no visible result yet…

That would be a solution also for my previous question to @makerken
:wave::older_man:

Homebridge just gives an on/off, the other dumb state logic is in my sketch. Toggle turns on/off, state controls which pattern is showing.

Start:
Toggle = 0 // off
State = 0 // pattern

First switch:
Toggle = 1 // on
State = 1

Second switch:
Toggle = 0 // off
State = 1

Third switch:
Toggle = 1 // on
State = 2

Keep following the logic, I’ve had three patterns, it only changes what pattern when I turn it on/off, no directly controlling which pattern. It only is ever controlling a single bool (int above makes it seem like more than it is, it should be bool). Haven’t looked at it in forever.

OK, got it!
But it must be possible to get different states from other accessories in Homebridge. I’m surprised this is not documented…

I hope to find out with that wonderful graphical UI found by @Moors7

I think it depends on the relevant plug-in what the capabilities are. The Yeelights I have do report their status (when changed with something other than Homebridge). It’s all in the coding. Fortunately, you can make/edit plug-ins to your heart’s contempt, though that might not be the easiest thing to do, admittedly.

1 Like

OK, understood…
So, I suppose the only person who could answer these questions is @krvarma, the maker of the Homebridge plugin for Particle.

@Moors7: Did you manage to see the “accessories” in that Homebridge Graphic UI?
:wave::older_man: