homebridge-cbus icon indicating copy to clipboard operation
homebridge-cbus copied to clipboard

CLI tool for generating config.json file

Open simonhac opened this issue 7 years ago • 4 comments

it should be pretty straightforward (and mightily helpful for noobs) to create a CLI tool that asks the user as few questions as possible, tests the connection and then creates / modifies config.json automagically.

  • ask the user if cgate is operating on the local machine, if not,
    • ask for client_ip_address, default to 127.0.0.1
    • ask for client_controlport, default to 20023
  • open client connection and download the project list (a great test of the connection details)
  • ask the user which project to load, default to the first running project, set client_cbusname accordingly, then load and open it, and download accessories
  • (no need to ask for default client_network, default to 254)
  • (no need to ask for default client_application, default to 56)
  • ask for location of homebridge folder, provide default (~/.homebridge on mac/linux, but where on windoze?)
  • if config.json doesn't exist, create it
  • if config.json doesn't include a homebridge-cbus platform section, create one
  • ask if user would like all found accessories to be added to config file, if yes, auto-add everything using the inferred accessory type, advising the user to verif config.json, and hand-edit if necessary.

before making any changes to config.json:

  • do all work on a temporary file
  • ask use whether they want to actually replace the old config.json file, keeping a timestamped backup

simonhac avatar Mar 12 '17 12:03 simonhac

I like this flow, sounds reasonable.

On Sun, Mar 12, 2017 at 5:31 AM, simonhac [email protected] wrote:

it should be pretty easy and mightily helpful to create a CLI tool that asks the user a few questions, tests the connection and then creates / modifies the config.json file automagically.

  • ask for client_ip_address, default to 127.0.0.1
  • ask for client_controlport, default to 20023
  • ask for client_cbusname
  • test client connection, if operational, download accessories
  • ask for default client_network, default to 254
  • ask for default client_application, default to 56
  • if config.json doesn't exist, create one
  • if config.json doesn't include a homebridge-cbus platform section, create one
  • ask if user would like all found accessories to be added to config file, if yes, do so.

before making any changes to config.json:

  • create a backup (making sure not to override any existing backups)
  • advise the user of the change and give them the option to leave the CLI without modifying the file

if any error is encountered, restore config.json from the backup.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/anthonywebb/homebridge-cbus/issues/32, or mute the thread https://github.com/notifications/unsubscribe-auth/AAARLfR8pBD__DjYPTUKj2_TQs8xNrUqks5rk-W1gaJpZM4Mahm6 .

anthonywebb avatar Mar 12 '17 17:03 anthonywebb

i just updated the first comment.

it might be a bit of a pain to support multiple projects running in the same 'cgate` instance, so i'll assume that there's only one project running. (i'm not sure whether this will limit anyone, but interested to hear otherwise.)

simonhac avatar Apr 30 '17 08:04 simonhac

Any updates on this tool? If any help is needed hmu :)

ElphaX avatar Jun 24 '17 15:06 ElphaX

I've just published a bash script that builds your entire Pi, and it even creates and edits the config.json, copying the groups across from my-platform.json, one by one, at your direction.

This link jumps directly to the json editing steps, and if you scroll there's an image of it in action.

I think this goes a long way to addressing the requirements above.

All credit to @anthonywebb for the project in the first place, plus all the contributors who've helped built it to what it is today, and to @darylmc whose XLS setup process is the one I've based my script on.

Please let me know if it gives any grief, or if you think it can be improved upon.

- Greig.

greiginsydney avatar Dec 30 '19 00:12 greiginsydney