lakhank295 / homebridge-inception-panel

3 stars 0 forks source link

Hi there, question please #2

Open paulvivian opened 2 years ago

paulvivian commented 2 years ago

G'Day,

I love the concept of the app, I have an Inner Range Inception system that I would like to link to my Homebridge system, however the only way seems to be via Rest API which is driving me batty.. You seem to be on the right path, do you have more information on how this works?? Any updates coming??

Your help is appreciated.. Happy to contribute $$ if it needs to get it working

Cheers

davidvlasic commented 1 year ago

Hi Paul,

I got this working after a bit of mucking around. I assume you have access to the web portal where you setup users etc.

Create a user for the API - allow web login and give the user permissions to the locks you want to control.

In your homebridge settings - the Login API URL is http://xxx.xxx.xxx.xxx/api/v1/authentication/login (replace with your inception device IP)

The Control Area API URL is http://xxx.xxx.xxx.xxx/api/v1/control/area/YOUR_API_AREA_STRING (see attached image)

This got me to a stage where I can the plugin loads successfully and shows up in my accessories and homekit.

Screenshot 2022-12-20 at 14 56 09 Screenshot 2022-12-20 at 14 52 29

Good luck, David

paulvivian commented 1 year ago

Thanks for this..

This is the error I am getting

ERR IF ====> TypeError: Cannot read properties of undefined (reading 'ID') at /usr/lib/node_modules/homebridge-inception/index.js:85:55 at new Promise () at InceptionSwitch.armArea (/usr/lib/node_modules/homebridge-inception/index.js:82:12) at InceptionSwitch.setLockCharacteristicHandler (/usr/lib/node_modules/homebridge-inception/index.js:167:12) at LockTargetState.emit (node:events:513:28) at /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2596:16 at new Promise () at LockTargetState. (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2594:14) at step (/usr/lib/node_modules/homebridge/node_modules/tslib/tslib.js:144:27) at Object.next (/usr/lib/node_modules/homebridge/node_modules/tslib/tslib.js:125:57)

As I am running the latest version of Inception, and I know the API system has changed (I thought v3) perhaps this is no longer able to communicate correctly. ??

I am no Guru at this..

Paul

On 20 Dec 2022, at 14:03, davidvlasic @.***> wrote:

Hi Paul,

I got this working after a bit of mucking around. I assume you have access to the web portal where you setup users etc.

Create a user for the API - allow web login and give the user permissions to the locks you want to control.

In your homebridge settings - the Login API URL is http://xxx.xxx.xxx.xxx/api/v1/authentication/login http://xxx.xxx.xxx.xxx/api/v1/authentication/login (replace with your inception device IP)

The Control Area API URL is http://xxx.xxx.xxx.xxx/api/v1/control/area/YOUR_API_AREA_STRING http://xxx.xxx.xxx.xxx/api/v1/control/area/YOUR_API_AREA_STRING (see attached image)

This got me to a stage where I can the plugin loads successfully and shows up in my accessories and homekit.

https://user-images.githubusercontent.com/19275989/208580985-595472aa-9310-4012-b574-e4d73d3b420b.png https://user-images.githubusercontent.com/19275989/208580988-b9bbebb1-daff-4266-979e-3248564bbe4c.png Good luck, David

— Reply to this email directly, view it on GitHub https://github.com/lakhank295/homebridge-inception-panel/issues/2#issuecomment-1358811919, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUMIQ3SJO2DQV2I6AFIDTY3WOEVY7ANCNFSM5MXOH2VQ. You are receiving this because you authored the thread.

davidvlasic commented 1 year ago

I'm getting the same actually, I'll keep mucking around with it - believe me, I'm a hack. If I get anywhere I'll let you know.

davidvlasic commented 1 year ago

Hi Paul, I've ended up just using homebridge-http-switch and dropped a php file on the Synology web server to trigger doors remotely and check the status. You'll need to make sure that curl is enabled. door.php.zip

paulvivian commented 1 year ago

OK, that sounds easy enough, BUT..

I am using Homebridge out of a Pi. could I get some guidance if possible please

On 22 Dec 2022, at 13:38, davidvlasic @.***> wrote:

Hi Paul, I've ended up just using homebridge-http-switch and dropped a php file on the Synology web server to trigger doors remotely and check the status. You'll need to make sure that curl is enabled. door.php.zip https://github.com/lakhank295/homebridge-inception-panel/files/10283539/door.php.zip — Reply to this email directly, view it on GitHub https://github.com/lakhank295/homebridge-inception-panel/issues/2#issuecomment-1362367850, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUMIQ3VWTMVRBCCAYI4AM3LWOPEJ7ANCNFSM5MXOH2VQ. You are receiving this because you authored the thread.

davidvlasic commented 1 year ago

If your inception box accessible from outside your home network, you could drop this on some web hosting space somewhere - as long as it has php installed. Having everything running from within your home network keeps it locked down a bit more. You could also potentially restrict access to the file by referring IP (your network IP).

woodgieboodgie commented 1 year ago

Hi, did you manage to get this going on a Pi? @davidvlasic are you suggesting a web server be installed on the Pi and Curl enabled..? I'm not sure I follow your hint.

Keen to know whether the solution you have come up with will allow me to control strike plates (that are connected to an Inception panel) via Apple HomeKit?

davidvlasic commented 1 year ago

I haven't used a Pi before - It's just a web request through the Inception API which is triggered by an Apple Shortcut.

woodgieboodgie commented 1 year ago

Thanks. re my qn about strike plates/door releases... is that possible via the plugin?

davidvlasic commented 1 year ago

If by plugin, you mean the Inception API - any lock that is configured in the Inception system is controllable by the access you've granted the API user.

woodgieboodgie commented 1 year ago

Excellent.

When you say “dropped a php file on the Synology web server” do you mean that you are using Web Station on a Synology NAS and have uploaded the php file onto that server? I don’t quite understand the connection process

From: @.> Sent: Monday, 6 March 2023 11:50 AM To: @.> Cc: @.>; @.> Subject: Re: [lakhank295/homebridge-inception-panel] Hi there, question please (Issue #2)

If by plugin, you mean the Inception API - any lock that is configured in the Inception system is controllable by the access you've granted the API user.

— Reply to this email directly, view it on GitHubhttps://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Flakhank295%2Fhomebridge-inception-panel%2Fissues%2F2%23issuecomment-1455273972&data=05%7C01%7C%7C30678c95b2164e12550108db1ddccb25%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638136606364115430%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Md0H%2FrUvE8nX3Ae2%2B2Vmj1ocOxL0RvpfNL4W9Q20Agg%3D&reserved=0, or unsubscribehttps://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMQK3Z7RRUOTBVT6S7LQR2LW2UYFTANCNFSM5MXOH2VQ&data=05%7C01%7C%7C30678c95b2164e12550108db1ddccb25%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638136606364115430%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=74hYNG6T%2Bfe8MPefJPQJVDUxn1JGL0UwYjMS1N52Gkw%3D&reserved=0. You are receiving this because you commented.Message ID: @.***>

davidvlasic commented 1 year ago

Here is what you need

A webserver that handles PHP to server the page If you are putting this file on an external webserver - it needs to be able to reach your inception box which will be inside your local network. If you're accessing the door url from within your network (on a server inside your network) this remove one barrier

Update your file with the URL to access your Inception Box, API username/password and door/lock ID's.

When you want to Unlock a door you'd use the following URL structure in your browser or Apple Shortcut

http://####WEB IP OR DOMAIN####/door.php?action=Unlock&whichdoor=fire

The "Unlock" and "fire", you'd change to match what you want to do and door names you have setup in the door.php file.

When you hit that URL, it will go to the Inception box and perform that action you've requested on the door set.

Make sure your API user (within Inception) has the right access for the door you're trying to control

woodgieboodgie commented 1 year ago

Great explanation. Got it. Re Inception hardware, is the base controller capable of delivering this information or a more accessories/software required? my test bench is an Inception controller and a single lock connected directly to it.

davidvlasic commented 1 year ago

The base controller can handle the API requests - I have this unit https://cctvmasters.com.au/products/inception-controller

woodgieboodgie commented 1 year ago

OK, can see the API keys for the door locks.

Still at a loss how to build this PHP web server on a spare Pi. Links to such installs vary from v5 to v8 and dont seem to work.

woodgieboodgie commented 1 year ago

Have successfully installed apache, php... and curl.

Downloaded your sample file, edited it to include my 'area' API key. as well as 'door' API key. i have kept the label as "fire" and removed the second door from the newly created "door.php" file. The file has been uploaded to the root folder of the web server.

Do I need to install "http-switch" plugin into Homebridge?

inception

dseeva commented 1 year ago

Have successfully installed apache, php... and curl.

Downloaded your sample file, edited it to include my 'area' API key. as well as 'door' API key. i have kept the label as "fire" and removed the second door from the newly created "door.php" file. The file has been uploaded to the root folder of the web server.

Do I need to install "http-switch" plugin into Homebridge?

inception

Hi woodgieboodgie,

I'm not sure how your home automation setup is but if you use HomeAssistant for anything there is a MQTT based plugin for HomeAssistant that will expose all areas, inputs, outputs and locks to HomeAssistant which you can then forward to iOS through homeassistants HomeKit add on, its not a 1-to-1 replacement for this project but it may achieve what you want with a slightly more beginner friendly approach (I don't mean any disrespect by that, I've not used this project, just stumbled across it a while ago when trying to integrate my home panel)

woodgieboodgie commented 1 year ago

Thanks @dseeva dseeva, I am running Homebridge on a Pi. @davidvlasic i have installed http-switch onto Homebridge and placed the following config within it (.14 is the web server running php on the Pi). I tested it and got the "hello world" on a dummy php so that part is working, its just the urls that need some work:

{ "accessory": "HTTP-SWITCH", "name": "http Switch", "switchType": "stateful", "onUrl": "http://192.168.xx.14/door.php?action=Lock&whichdoor=fire", "offUrl": "http://192.168.xx.14/door.php?action=Unlock&whichdoor=fire", "statusUrl": "http://192.168.xx.14/door.php?action=State&whichdoor=fire" }

woodgieboodgie commented 1 year ago

Error received when placing one of the above into a browser:

Fatal error: Uncaught Error: Call to undefined function curl_init() in /var/www/html/door.php:31 Stack trace: #0 {main} thrown in /var/www/html/door.php on line 31

davidvlasic commented 1 year ago

This error means you don't have the PHP Curl Extension installed within PHP

woodgieboodgie commented 1 year ago

I opened php. ini (it's in /etc/php folder on the server). Search for extension=php_curl. dll. Uncomment it by removing the semi-colon( ; ) in front of it. Restarted the Apache Server. Same error :(

davidvlasic commented 1 year ago

The function curl_init() is part of the curl extension - if that is undefined it means you don't have curl installed (or potentially running) within PHP. Try creating a test.php file which contains <?php phpinfo();?> to list all the extension modules you have running at this time.

woodgieboodgie commented 1 year ago

Ah.. not sure how to do that sorry. Articles suggest that finding the curl extension within the .ini file and removing the semi colon ought to do it.

davidvlasic commented 1 year ago

If you unzip this file, you'll be left with test.php - place this in your document root folder and then view it in your browser

http://YOUR IP OR DOMAIN/test.php

Look for CURL

test.php.zip

woodgieboodgie commented 1 year ago

when i enter 'sudo apt install -y curl" i get a response stating the newest version is already installed (7.74.0-1.3+deb11u7)

woodgieboodgie commented 1 year ago

I have uploaded the test file and the result is a long page of data. i search for curl and find the name of the author.

davidvlasic commented 1 year ago

Can you screen shot that part of the page when it mentions curl

woodgieboodgie commented 1 year ago

curl screenshot

davidvlasic commented 1 year ago

You should have a section like this

Screenshot 2023-03-07 at 09 43 06
woodgieboodgie commented 1 year ago

Progress. i had installed curl, but not curl for php (sudo apt-get install php-curl). i now see the extract like you have embedded above. however, not out of the woods yet as i enter the url to get status of the lock and the browser returns "Failed"

davidvlasic commented 1 year ago

Unless you have an SSL certificate installed, this will be the case, you can ignore/bypass the warnings

woodgieboodgie commented 1 year ago

ok, but all three links above when entered into the browser return "failed".. and i cant seem to open or close the lock using the browser url. shouldnt the lock open and close depending on the url i enter?

woodgieboodgie commented 1 year ago

could the status codes in my Inception be different to yours? i noticed in your door.php you are expecting to see 768, 513. how do i expose my codes? not sure where to put the command //print_r($response)

davidvlasic commented 1 year ago

Sorry - misunderstood the issue.

You'll notice some lines in the file like //print_r($response); remove the // to see what the result is (line 152 & 157).

The issue will either be

your api username/password is wrong your ID for your locks is not set correctly the api user created in inception doesn't have permissions to that lock (that's all I can think of). Unlikely the status codes are different - but possible.

Expose the $response content and that will give more info

woodgieboodgie commented 1 year ago

This is the current door.php file

TROUBLESHOOT DOOR PHP.zip

woodgieboodgie commented 1 year ago

to clarify .. in the door.php where you request the following:

"Username": "######API USERNAME#######", "Password": "######API PASSWORD#######"

Is that the API key I generate from 'manage users' within Inception GUI? (As opposed to the Inception username and password which has admin privileges). I can confirm that from within the GUI I can see the lock and operate it

user details door php

davidvlasic commented 1 year ago

Try adding

print_r($response);

at Line 62 to confirm you are connecting ok, you should get something like

Array ( [Response] => Array ( [Result] => Success [Message] => OK [FailureReason] => 0 ) [UserID] => ###someuseridstringhere### )

If you don't see " Success [Message] => OK" - it means you are not connecting successfully to inception and you will have a "FailureReason" which you would troubleshoot.

If you do get a success OK - then changing add

echo "\

";
print_r($response);
echo "\
";

just above these lines (around line 160).

$state['768'] = 0; $state['513'] = 1; $state['Lock'] = 0; $state['Unlock'] = 1;

This will tell you what's happening when trying to change the lock status.

davidvlasic commented 1 year ago

You will create a user (as normal) e.g. give it a name of API

Enable web login, give it a usernmame / password and then make sure it has permissions to the locks/doors

The username and password are the details you'll use for the credentials.

woodgieboodgie commented 1 year ago

OK, user is admin and I have set a password, confirmed it has web login and permissions to locks.

davidvlasic commented 1 year ago

This error means that your door/lock ID is not correct

woodgieboodgie commented 1 year ago

Array ( [Response] => Array ( [Result] => Success [Message] => OK [FailureReason] => 0 ) [UserID] => df6faf24-06c3-XXXXX-80b1-XXXXXXXXXXX ) Array ( [ErrorMessage] => Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). ) Failed

Shall double check Door ID and retest

woodgieboodgie commented 1 year ago

I can confirm the key embedded into door.php is the same as the one in the Inception GUI

door lock api key

woodgieboodgie commented 1 year ago

does the user need to be called API or is admin sufficient? and should there be an API key setup against that user within the gui? currently there is a key for that user. i could blank it out if not needed?

woodgieboodgie commented 1 year ago

be good to speak, let me know if you are ok with a convo to accelerate things. i am happy to cover you for your time

davidvlasic commented 1 year ago

The use you create could be any name and username. I've given my API user a name of API and then it has it's credentials username/password which are set within the user. It looks like your user credentials are being accepted

Array ( [Response] => Array ( [Result] => Success [Message] => OK [FailureReason] => 0 ) [UserID] => df6faf24-06c3-XXXXX-80b1-XXXXXXXXXXX )

The second array is when the door is being locked/unlocked etc.

When I replace one digitit within the ID with a non HEX alpha character (e.g. x), I get [ErrorMessage] => Guid string should only contain hexadecimal characters.

If I add an extra hex character to the ID, I get the same error message as you. Array ( [ErrorMessage] => Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). )

If I swap a character in the ID with a valid hex character I get Failed

Let me check on thing about the user password - it needs to be hashed. Let me just check this

davidvlasic commented 1 year ago

At around line 17, can you change

if($_GET['action'] == '' OR $_GET['whichdoor'] == ''){

die();

}

to

if($_GET['action'] == '' OR $_GET['whichdoor'] == ''){

die();

} else {

$whichdoor = $_GET['whichdoor'];

}

davidvlasic commented 1 year ago

Happy to chat, best if I send some details through to house mate?

woodgieboodgie commented 1 year ago

Pls do