anthonywebb / homebridge-cbus

CBus plugin for homebridge
MIT License
35 stars 20 forks source link

Help with CBUS and homekit Integration #58

Closed peterconn closed 7 years ago

peterconn commented 7 years ago

Hi Guys,

Can you please assist and let me know whether i have this setup correctly? I am having troubles setting up accessories, can you assist. Should the username and port be the details of my CNI?

MacBook-Pro-3:~ peterconstantopedos$ homebridge [6/25/2017, 1:56:46 PM] Loaded plugin: homebridge-cbus [6/25/2017, 1:56:46 PM] Registering platform 'homebridge-cbus.CBus' [6/25/2017, 1:56:46 PM] --- [6/25/2017, 1:56:46 PM] Loaded config.json with 0 accessories and 1 platforms. [6/25/2017, 1:56:46 PM] --- [6/25/2017, 1:56:46 PM] Loading 1 platforms... [6/25/2017, 1:56:46 PM] [CBus] Initializing homebridge-cbus.CBus platform... cbus:client Opening connection to C-Gate… +0ms [6/25/2017, 1:56:47 PM] Loading 0 accessories... cbus:client C-Gate connection open. +14ms

This is what my config.json looks like, { "bridge": { "name": "My Home", "username": "CC:22:3D:E3:CE:30", "port": 51826, "pin": "031-45-154" },

"description": "My home HomeKit API configuration file",

"platforms": [ { "platform": "homebridge-cbus.CBus", "name": "CBus", "client_ip_address": "192.168.1.61", "client_controlport": 10010, "client_contolport": 10010, "client_cbusname": "101SPARK", "client_network": 254, "client_application": 56, "client_debug": true,

 "platform_export": "my-platform.json",

 "accessories": [
    { "type": "dimmer", "id": 27, "name": "light" },
    { "type": "light", "network": "254", "id": 40, "name": "Outside Light" }
  ]
}

], "accessories": [] }

ElphaX commented 7 years ago

Firstly you dont need a contol port, only a control port.

Now to explain how the config connects to your cbus system, homebridge is essentially connecting to a cgate server running on a device that in turn has the connection to the cni, the ip and port should be the ip of the devicr running cgate and port 20023 if you havent changed anything.

I am happy to help you set it up, where is your cgate server located? And have you in the past tinkered with ports?

peterconn commented 7 years ago

c gate is on my windows PC, im currently configuring the .config via my apple mac laptop using ATOM. If i delete the contol port line i cant connect to Cgate. Im happy you can help me, thank you

peterconn commented 7 years ago

i changed my IP to my CNI as i have port forwarded so i can remotely connect using touch soft APP. Im happy to set to another port number if necessary.

ElphaX commented 7 years ago

Of course, so I'll give you a step by step guide, follow these in order, if one step doesn't work let me know.

  1. Find out the IP Address of the Windows Machine which has CBUS Toolkit or CGATE running on it, we'll use "WIN.IP.ADDRESS" for this guide, your ip may be something like 192.168.1.10.

  2. Find out the IP Address of the Mac Laptop that is hosting the homebridge instance, let's use "MAC.IP.ADDRESS" for this.

  3. Open CBUS Toolkit on your windows machine and write down your project name. If you have not changed ports or configured anything yourself - everything else should still be default. So find out your project name - it may be something like HOME or "101SPARK" as you mentioned before.

  4. Next, navigate yourself to this text file, C:\Clipsal\C-Gate2\config\access.txt, using windows explorer to go through each folder may help you also understand the folder structure of CGATE. In this text file you will see lines of text like this:

    • interface 127.0.0.1 Program Now, you will be adding a new line under the line above but like this:
    • remote MAC.IP.ADDRESS Operate What this does is, tell the cgate server that the MAC has permission to access the CBUS Network and its connected devices for operation.
  5. Disconnect from your cbus network and restart CBUS Toolkit - this will update the access permissions that you just added in.

  6. Now the windows PC is ready and doesn't need any more changes, the MAC is not ready yet. Open ATOM or your text editor and open the config.json. Coming from what you mentioned before this is what you currently have in the config.json:

"platforms": [ { "platform": "homebridge-cbus.CBus", "name": "CBus", "client_ip_address": "192.168.1.61", "client_controlport": 10010, "client_contolport": 10010, "client_cbusname": "101SPARK", "client_network": 254, "client_application": 56, "client_debug": true,

This will now be edited into this:

"platforms": [ { "platform": "homebridge-cbus.CBus", "name": "CBus", "client_ip_address": "WIN.IP.ADDRESS", "client_controlport": 20023, "client_cbusname": "PROJECTNAME", - could still be SPARK101, depends on your project's name. "client_network": 254, "client_application": 56, "client_debug": true,

Now, making sure that no other homebridge instance is currently running, start up homebridge and watch the lights and other devices start syncing up. I don't think I've missed anything, let me know of your progress - I'll be here all night. 👍

peterconn commented 7 years ago

ok ill try now

ElphaX commented 7 years ago

Once your done, another question to you. I saw that you have ported your CNI for the TouchSoft app, it is currently $150 on my app store, was it worth the cost and how long have you used it for?

I have been using homebridge for about a month now and the home app does everything for me and my CBUS Home with over 200 devices, lighting, fans, heating/cooling, curtains, gate and garage. Is TouchSoft a worthy investment?

I mean, we have all seen Anthony's videos of controlling his home, do we want an updated and in depth display/review. I'd be happy to video myself pressing buttons and talking exaggeratedly.. like every other youtuber. Let me know :)

peterconn commented 7 years ago

in regards to touch soft it is a great program but at times you have to restart the program around 10 times before it connects to your CNI, a little annoying at times.

I have configured my own GUI using a program called icontrol. This is very user friendly. it also costs around $100aud a year for a licence. This is done through iriduim. It is a great app but you have to build the GUI from scratch.

http://www.iridiummobile.net/

peterconn commented 7 years ago

homebridge [6/25/2017, 6:17:51 PM] Loaded plugin: homebridge-cbus [6/25/2017, 6:17:51 PM] Registering platform 'homebridge-cbus.CBus' [6/25/2017, 6:17:51 PM] --- [6/25/2017, 6:17:51 PM] Loaded config.json with 0 accessories and 1 platforms. [6/25/2017, 6:17:51 PM] --- [6/25/2017, 6:17:51 PM] Loading 1 platforms... [6/25/2017, 6:17:51 PM] [CBus] Initializing homebridge-cbus.CBus platform... cbus:client Opening connection to C-Gate… +0ms [6/25/2017, 6:17:51 PM] Loading 0 accessories... cbus:client C-Gate connection open. +16ms cbus:client C-Gate session not ready -- unexpected message: 421 Connection refused. +11ms cbus:client C-Gate socket terminated. +2ms

peterconn commented 7 years ago

This is what my config file looks like, do i have to manually start the CGATE on windows PC?

{ "bridge": { "name": "My Home", "username": "CC:22:3D:E3:CE:30", "port": 51826, "pin": "031-45-154" },

"description": "My home HomeKit API configuration file",

"platforms": [ { "platform": "homebridge-cbus.CBus", "name": "CBus", "client_ip_address": "192.168.1.30", "client_controlport": 20023, "client_cbusname": "101SPARK", "client_network": 254, "client_application": 56, "client_debug": true,

 "platform_export": "my-platform.json",

 "accessories": [
    { "type": "dimmer", "id": 27, "name": "light" },
    { "type": "light", "network": "254", "id": 40, "name": "Outside Light" }
  ]
}

], "accessories": [] }

ElphaX commented 7 years ago

Starting CGATE manually will mean you need to specify the default project in the cgate config file. The easier option will be to open toolkit and toolkit opens a cgate instance in the background. Which method would you prefer, either way the windows PC must be switched on 24/7 for 24/7 access

peterconn commented 7 years ago

do i have to open all networks? I have tried this with all networks open and closed and i still get same error. homebridge [6/25/2017, 6:26:22 PM] Loaded plugin: homebridge-cbus [6/25/2017, 6:26:22 PM] Registering platform 'homebridge-cbus.CBus' [6/25/2017, 6:26:22 PM] --- [6/25/2017, 6:26:22 PM] Loaded config.json with 0 accessories and 1 platforms. [6/25/2017, 6:26:22 PM] --- [6/25/2017, 6:26:22 PM] Loading 1 platforms... [6/25/2017, 6:26:22 PM] [CBus] Initializing homebridge-cbus.CBus platform... cbus:client Opening connection to C-Gate… +0ms [6/25/2017, 6:26:22 PM] Loading 0 accessories... cbus:client C-Gate connection open. +13ms cbus:client C-Gate session not ready -- unexpected message: 421 Connection refused. +8ms cbus:client C-Gate socket terminated. +3ms

ElphaX commented 7 years ago

This is suggesting that the windows PC is not allowing the mac to connect. Make sure there is the like

remote MAC.IP.ADDRESS Operate

In the access.txt. Have you already done this?

peterconn commented 7 years ago

yes i have done that

peterconn commented 7 years ago

C-Gate Server Access Control File

This file was written automatically by a command issued to the server

Created:Tue Oct 05 16:22:26 CST 2004

File name: C:\clipsal\c-gate\config\access.txt

interface 0:0:0:0:0:0:0:1 Program interface 127.0.0.1 Program remote 192.168.1.7 Operate interface localhost Program

End of access control file

ElphaX commented 7 years ago

Okay, open the java CMD prompt that starts with toolkit and check if a connection was attempted from the MAC. Make sure you restart CGATE so it updates the new permissions. If all that doesnt work, change the line I mentioned above to this:

Interface MAC.IP.ADDRESS Program

peterconn commented 7 years ago

how do i open the java cmd?

peterconn commented 7 years ago

untitled

ElphaX commented 7 years ago

Mine usually opens it when toolkit opens, try this: In toolkit go: File, Disconnect Cgate. Then again, File, connect to local cgate. Did a command prompt-like window pop up in your start menu?

peterconn commented 7 years ago

ok done that still get,

homebridge [6/25/2017, 6:59:05 PM] Loaded plugin: homebridge-cbus [6/25/2017, 6:59:05 PM] Registering platform 'homebridge-cbus.CBus' [6/25/2017, 6:59:05 PM] --- [6/25/2017, 6:59:05 PM] Loaded config.json with 0 accessories and 1 platforms. [6/25/2017, 6:59:05 PM] --- [6/25/2017, 6:59:05 PM] Loading 1 platforms... [6/25/2017, 6:59:05 PM] [CBus] Initializing homebridge-cbus.CBus platform... cbus:client Opening connection to C-Gate… +0ms [6/25/2017, 6:59:05 PM] Loading 0 accessories... cbus:client C-Gate connection open. +79ms cbus:client C-Gate session not ready -- unexpected message: 421 Connection refused. +15ms cbus:client C-Gate socket terminated. +2ms

ElphaX commented 7 years ago

In the cmd window on the pc, check if a connection message is made when the mac starts homebridge.

peterconn commented 7 years ago

how do i bring up the Cgate cmd window, it shows for 1 seconds thens disappears.

peterconn commented 7 years ago

ok success i think, i had to change the port to the port shown on the current cgate client settings. It seems to change every time i restart cgate.

homebridge [6/25/2017, 7:05:14 PM] Loaded plugin: homebridge-cbus [6/25/2017, 7:05:14 PM] Registering platform 'homebridge-cbus.CBus' [6/25/2017, 7:05:14 PM] --- [6/25/2017, 7:05:14 PM] Loaded config.json with 0 accessories and 1 platforms. [6/25/2017, 7:05:14 PM] --- [6/25/2017, 7:05:14 PM] Loading 1 platforms... [6/25/2017, 7:05:14 PM] [CBus] Initializing homebridge-cbus.CBus platform... cbus:client Opening connection to C-Gate… +0ms [6/25/2017, 7:05:14 PM] Loading 0 accessories... cbus:client C-Gate connection open. +89ms cbus:client Connected to C-Gate server v2.11.1 (build 3240), syntax v1.0 +16ms cbus:client Configuring C-Gate session… +0ms cbus:client C-Gate session estabished and configured at 20023:192.168.1.30 +7ms cbus:platform Loading the accessories list… +1ms cbus:platform Registering the accessories list… +6ms [6/25/2017, 7:05:14 PM] [CBus] Initializing platform accessory 'light'... [6/25/2017, 7:05:14 PM] [CBus] Initializing platform accessory 'Outside Light'... Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

┌────────────┐     
│ 031-45-154 │     
└────────────┘     

cbus:client sent command '[100] dbgetxml //101SPARK' +32ms [6/25/2017, 7:05:14 PM] Homebridge is running on port 51826. cbus:client rx response { commandId: 100, code: 440, matched: false, processed: false, type: 'response', raw: '[100] 440 There is no tag database to perform this operation on' } +10ms cbus:client matched request '[100] dbgetxml //101SPARK' with response '[100] 440 There is no tag database to perform this operation on' (0 pending requests) +1ms cbus:client rx unparsable line: '[100] 440 There is no tag database to perform this operation on', error: TypeError: Cannot read property 'content' of undefined cbus:client at Object.client.getDB.result [as callback] (/usr/local/lib/node_modules/homebridge-cbus/lib/cgate-database.js:58:31) cbus:client at CBusClient._resolveResponse (/usr/local/lib/node_modules/homebridge-cbus/lib/cgate-client.js:587:12) cbus:client at CBusClient._socketReceivedLine (/usr/local/lib/node_modules/homebridge-cbus/lib/cgate-client.js:628:10) cbus:client at Carrier. (/usr/local/lib/node_modules/homebridge-cbus/lib/cgate-client.js:175:9) cbus:client at emitOne (events.js:96:13) cbus:client at Carrier.emit (events.js:188:7) cbus:client at /usr/local/lib/node_modules/homebridge-cbus/node_modules/carrier/lib/carrier.js:24:12 cbus:client at _combinedTickCallback (internal/process/next_tick.js:73:7) cbus:client at process._tickCallback (internal/process/next_tick.js:104:9) +1ms

peterconn commented 7 years ago

cbus:client matched request '[125] ramp //101SPARK/254/56/27 100% # setOn (on)' with response '[125] 408 Operation failed: //101SPARK/254/56/27' (0 pending requests) +0ms

peterconn commented 7 years ago

this is the fault upon activating the lights on 1 dimming channel. On a good note, it has updated the home app with the 2 inputs i have installed. do i have to put details of the dimming unit (output unit )for this to respond?

ElphaX commented 7 years ago

Never come across that error before, after googling it may mean the cgate server is connected but the cgate server is not connected to the network. This may have something to do with the way your network was set up, I wouldn't know too much about this error, anyone else?

peterconn commented 7 years ago

ok i got it to work, i had to open all networks. Its now responding to commands via the app.

ElphaX commented 7 years ago

Perfect, now just add all your devices on the network and watch siri control your home.

Also, close the issue when everything is good to go! 👍🏼

peterconn commented 7 years ago

Sure I'll add more inputs and see how I go. Thank you so much for your assistance.

peterconn commented 7 years ago

@EdwinJS does the network actually need to be open for homekit to talk to cbus or just Cgate needs to be connected?

ElphaX commented 7 years ago

My setup is different because I'm running the cgate and homebridge all on the Raspberry Pi 3; however, you may be able to have the network closed if you specify the default prpject in the config, in the same folder as the access.txt is the config txt, in there search for Project.default and project.start and make then = to 101SPARK.

That might work but im unsure.

ElphaX commented 7 years ago

I might recommend the pi if you are planning to want 24/7 access as using a pc turned on 24/7 and a mac turned on 24/7 to run both instances you might be looking at power consumption problems, plus the life of the pc/mac itself. The pi 3 is $35 and the pi zero (wireless) is $5 and it's pretty much all you need for homebridge and home automation to run efficiently and effectively. Just my 5 cents

peterconn commented 7 years ago

ill look into the pi is it easy to program?

DarylMc commented 7 years ago

Hi I think Pi is the only way to do it. I've had Homebridge set up on Pi3 since Christmas. For about 4 months I used it with CGate running on a Windowes PC. It works great and is really stable. About a month ago I put CGate on the Pi as well and I think it is awesome. It has taken me 4 years to get around to using Pi with CBus but setting up CGate on Pi is about as easy as it gets. If you would like to do that I can send a link with instructions.

peterconn commented 7 years ago

That would be great Daryl. Question: when running cgate on your pc did your networks have to be opened 24/7?

DarylMc commented 7 years ago

Yes CGate has to be running somewhere. Unlike many people I actually trust my Windows PC's to be reliable but running CGate on Raspberry pi has been even more reliable and convenient for me.

DarylMc commented 7 years ago

It is a bit of a muck around if you are not familiar with Linux but I really think running Homebridge and CGate on a raspberry pi is a good way to do it.

DarylMc commented 7 years ago

And that is coming from someone who really would rather do everything in the Windows world

peterconn commented 7 years ago

problem i have is, i have cgate running but without hitting the open all networks button i cant actually control inputs. i want to try what @EdwinJS said about adding some info in the cgate config file

DarylMc commented 7 years ago

Once CGate is running and open As long as your Windows PC is running it will stay that way. It's nice to use Toolkit to open the network. It's kind of easy That is what I was doing since Christmas. It's better once you can get it all to run automatically Running CGate on a raspberry pi takes your pc out of the equation and can be set up to do it all automatically from reboot Your PC can be set up to start CGate open the project and connect too but if you have a raspberry pi I think it is easier and better to do it there.

peterconn commented 7 years ago

Ok, I'll buy a Pi tomorrow, your setup instructions would be really helpful.

DarylMc commented 7 years ago

Just a sec I will make a link

DarylMc commented 7 years ago

https://1drv.ms/f/s!AminzOc-NC4UgZkT2UPvhaDRGwe_3w

DarylMc commented 7 years ago

Let me know if the link doesn't work. Have a look at it and me know if you run into any problems. The spreadsheet has everything I have done over and over again to set up raspberry pi with Homebridge and CGate. In the notes I added a timer to delay the startup of Homebridbge on reboot. That is required. I hope it is all easy to follow

DarylMc commented 7 years ago

It is a compilation of all the stuff I googled and the results of work people who actually know what they are doing have provided.

peterconn commented 7 years ago

@DarylMc when you say install putty on PC, does this mean raspberry pi or my windows pc?

peterconn commented 7 years ago

@DarylMc dont answer that i worked that part out,sorry

peterconn commented 7 years ago

@DarylMc hey mate, im stuck at the nano section. Not sure where to go from here nano

DarylMc commented 7 years ago

"using nano from your windows pc via putty" Using your windows PC copy some text. Ctrl c or however you normally copy things on windows. Go to Nano right click will do the paste action. Ctrl x to save y enter to confirm It's not at all like windows text editors Persevere you will get the hang of it. Use the help files to learn

DarylMc commented 7 years ago

@peterconn If you send me a PM I will give my email address. Maybe a quick talk on Skype if we can work a time.

There is a disk image CBus.zip at that link. 850mb or so You could just install that if you are familiar with installing an image to pi. That would be the easiest. Still a few text files and ip addresses would need to be changed. The things highlighted in yellow. And one other thing which is not described in the spreadsheet to install a delay start for homebridge service. I'd get a kick to see someone follow the instructions and get it all going.

peterconn commented 7 years ago

@DarylMc i was going well till i saw nano, what do i past in nano? Thats were im stuck