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
Control homebridge with the command line (without an iPhone) #506
Comments
Why don't you just test the homebridge with a HomeKit app...? |
…oh, right. In fact I want to send commands to homebridge without an iPhone/iOS device. Is there a way to do so from a Mac running OS X? |
Thank you, I am currently testing homebridge-punt. As of yet I wasn't able to see my other devices in the punt simulator. Other hints to control homebridge are welcome as well. |
You can run the apple example app in Simulator. https://developer.apple.com/library/ios/samplecode/HomeKitCatalog/Introduction/Intro.html |
@oa- that's right, the punt simulator is only for the accessories defined in config-punt.json but that's good point. However I'm not sure whether I can access all the homebridge accessories in my plugin. I've to investigate. |
@KhaosT the simulation of a homekit request sounds interesting. However, the link you included is not accessible without a login. Do you have another link or know how I can get it another way? Thanks! |
@rooi You can join the homebridge channel from the README.
And if you're using homebridge 0.2.16, you may need to manually edit the hap-nodejs and comment out this part (https://github.com/KhaosT/HAP-NodeJS/blob/3733e7d7274a656c71fe02fd3df4af170dd33c3b/lib/HAPServer.js#L700) |
Hi @KhaosT I tried to look at the homebridgeteam.slack but it seems you need to be invited ... could you invite me? Thx ! |
Check the project's GitHub page, there is a slack button. Click that and you'll get invitation to the channel ^^ Sent from my iPhone
|
@KhaosT Thanks for the hint ! I missed the link the first time... |
@KhaosT This has changed in the latest HAP-NodeJS version right? If I understand the code correctly you should be able to set the auth en get a response. If this is correct, could you please indicate what the commands are? I get Insufficient privileges with something like (with different pincode ""' variations and other options): curl -X PUT http://mac-mini.local:51828/accessories --header "Content-Type:Application/json" --header "authentication: "031-45-154"" -s Thanks! |
Make sure you're on latest homebridge (0.2.18). Launch homebridge with flag |
It works, thanks! |
Also, you could try this: |
@KhaosT I'd like to set a value of an accessory within a bash script. I got the aai/iid for my accessory as discribed above. However, I'm struggling with the correct syntax of the curl command for PUTing a value to the accessory. Could you please indicate how to do this? My (not working) command is: |
@Samfox2 You missed the "characteristics" part that surrounds your data, see khaosT's post |
Added it now but still no change:
|
@Samfox2 you need to post what's the error you get... |
The error is:
|
Hmm, strange, I thought I did as it was working with the accessories-method |
No, it's not working 😔
Would you mind checking it with your config and posting the whole command? Maybe there is a syntax error in my command? |
It looks right to me... Try add stuff to print out the header and see if it actually getting the correct header?
|
Looks like there are a few spelling errors in (my) HAPServer.js, no idea where they come from. |
After a long debug session the following command deliveres the correct header incl. pin but characteristics is empty {}:
Any idea? |
I found that link by chance, as there isn't any documentation about that. So in my script I have a GET request to Homebridge, then analyze the response (value filed) and turn on or off the lamp! :) |
For people having issues with suggested commands, here is how i got it to work: I ran homebridge using: Then i clicked in my Home app on my iPhone to turn a light on or off In the console it showed me: Which is the right iid to use. Then i used Which turns it on! And to get a list of all lights |
For anybody wondering, why the curl statement above doesn't work for you, please check:
To get all of the available AID and IID values, execute following script:
|
Another way to get all the devices, is just use the GET /accessories command in your curl instead, it will return all devices including a lot more details.
…Sent from my iPad
On Aug 23, 2017, at 2:57 AM, qudarr ***@***.***> wrote:
For anybody wondering, why the curl statement above doesn't work for you, please check:
Don't blindly copy & paste the above curl statement, as the apostrophes will not work correctly. You will need to re-type them. In my case: using chrome on windows as well as safari on mac.
Do you have the same homebridge port? Mine was 51826.
Check your authorization code
I didn't need the "-s" parameter at the end of the curl GET statement
To get all of the available AID and IID values, execute following script:
#!/bin/bash
for ((i = 0; i < 100; i++))
do
for ((j = 0; j < 100; j++))
do
echo "$i $j"
curl --silent -X GET http://127.0.0.1:51826/characteristics?id=$i.$j --header "Content-Type:Application/json" --header 'authorization: XXX-YY-ZZZ'
done
done
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Thanks, this is much better. But harder to parse as a human ^_^ |
Hi, i want make script that change device status to opposite when detect especific infrared signal (Hex code), i already am able to get device status, for example: TV The problem is that it stop learn few seconds latter.. Also i would like get this hex code (i can see it on homebridge debug but cant get it running command), another problem is that if it read same remote button, it aways is different hex code, its similar, but hard be exactly same.. I think will be hard somebody here with experience in rm pro devices (their git is stoped, no updates long time, so is hard discuss with guys in issues list) But at least could help with that:
How make script to read it result, change value to opposite ? if its true, change to false, if is false, change to true..
|
To summ up:
Also here's another version of the script, using only native 'sed' & 'awk' parser from here: Bash only (should work in Shell when you rewrite For loop with While)#!/bin/bash aid=2 iid=10 IP=192.168.1.128 PORT=51826 KEY=031-45-154function jsonValue() { result=$( curl -s -X GET http://$IP:$PORT/characteristics?id=$aid.$iid | jsonValue value ) case $result in data={"characteristics":[{"aid":$aid,"iid":$iid,"value":$state,"status":0}]} curl -s -X PUT http://$IP:$PORT/characteristics --data $data --header "Content-Type:Application/json" --header "authorization: $KEY" |
Sorry but |
Seems so) mine device had aid=2, and state value was contained in string iid=10. |
They're like index numbers for the accessory (aid) and service/characteristic (iid), within the accessory. I suppose to avoid having to pass lengthy UUIDs with every HAP call. They're mapped to the UUIDs, see |
Thank you very much, and sorry for this message, but what discovery script can I run to figure out my values? |
Thanks, I find the file but, into the file, there is so much number :-( |
It's an object with key/values pairs, where
See https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js for the UUIDs of the standard services and characteristics. |
Thanks, I suppose to find my data
but onece aid
Is correct? |
I update my string: |
No, these are just references to the next aid to be assigned and to the next iid to be assigned for the accessory. You need to look for your accessory UUID (I wouldn't know how to retrieve that) and the service and characteristic UUIDs. If you run For example, here's one of my Hue dimmer switches, as exposed by homebridge-hue:
Parsing this (note that standard services and characteristics have UUID 00000xxx-0000-1000-8000-0026BB765291):
|
Did you run |
Yes, but there is an error: `Or enter this code with your HomeKit app on your iOS device to pair with Homebridge:
events.js:183 Error: listen EADDRINUSE :::51826 |
I suppose because I use this for a quick install of Homebridge server: https://itunes.apple.com/it/app/homebridge-for-raspberrypi/id1123183713?mt=8 I think the structure of the directory is different :-( |
You're already/still running homebridge. Make sure to stop any service before starting homebridge manually from the command line. |
The discovery script by @qudarr, which I posted in step 2, provides a very clear aid/uid output. {"status":-70401} means you’re not running InSecure mode. |
IMHO, HomeBridge developers should publish some straightforward CLI script or more simplified HTTP API for this Topic (listing devices and switching their state). Currently, I’m not using HomeBridge to toggle.
By the way, jq isn't really necessary (not available for arm64). Without jq case with wildcard substring still works fine:
|
My values doesn't follow toggle state anymore - they are just 0, not false or true. Probably, there were some changes in HomeBridge recently.. or in HAP-NodeJS. |
@i3laze I’m a big user of insecure mode and have not noticed anything recently. It is the backbone of my Alexa plugin, and has been working for over a year. Can you elaborate further on your issue? |
My fault.. looks like every device has own unique aid.
Current walk through /characteristics might take several minutes. Even better if we get a better HomeBridge API. |
If your playing with this interface, I have a couple of projects that use it heavily. Take a look at my homebridge-Alexa plugin and Hap-NodeRed repo’s.
… On Mar 12, 2019, at 11:31 PM, i3laze ***@***.***> wrote:
My fault.. seems every device has own aid -
A year ago I thought devices are placed under single aid (between 1 and 3)..
14 9; {"characteristics":[{"aid":14,"iid":9,"value":"Kodi Playback","status":0}]}
14 10; {"characteristics":[{"aid":14,"iid":10,"value":true,"status":0}]}
Seems, parsing curl -s -X GET http://localhost:51826/accessories is the only reliable solution.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
When setting up a new configuration I'd like to test it without using Siri all the time.
How can I simulate the command Siri is sending to homebridge simply using the terminal? Thanks.
The text was updated successfully, but these errors were encountered: