Add Binding through command line

Hi all, i want to create a bash script containing all the installation commands and the addons which i think my application would be using ( network, persistence etc ). Please i need your assistance.

It is probably more appropriate to edit the conf/services/addons.cfg (on Linux installed OH that is in /etc/openhab2/services/addons.cfg) file and list all the bindings you want to have installed. OH will read that file and install all the add-ons listed. You can see an example and further information here.

1 Like

@rlkoshak thanks for your reply, i think i have understand you point, I have one more thing to ask if you could answer. I am working on a home automation solution, i have chosen openhab for this. For each new customer i have to develop items, sitemaps and rules scripts etc. Is there any way to minimize my customization effort. please if you suggest me better solution.

As rich said use the text files for standard install stuff as soon as you load a new install of OH it will read the files and add this stuff straight away just like items

Maby setting up an FTP server is the way too go or remote ssh terminals you could then push new files too your new openhabs

dear rich when i tried to edit the addons.cfg, it gives permission denied error

There is the Home Builder Addon which might be useful for you. But like Aaron suggests, you will probably want to develop a skeleton set of Items and Rules and configs to start from and customize this for each home. As you build more and more you will end up with a library of parts that you can use to quickly build up the configurations.

I strongly recommend using some sort of source control and keep the skeleton and each home you build in a controlled manner. I like git but use whatever you are comfortable with.

Operating System?
How did you install OH?
How are you attempting to edit the file?
Are you on the same machine that OH is running or trying to edit across the network?
What user are you running as to edit the file?

my OS is raspbian,
i install snapshot version,
=> echo ‘deb unstable main’ | sudo tee /etc/apt/sources.list.d/openhab2.list
=>sudo apt-get update
=>sudo apt-get install openhab2
=>sudo apt-get install openhab2-addons

I am using echo to edit addons.cfg file, actually adding comma separated list of addons.
I tried to edit the file through putty and also on the same machine
“echo ‘binding=mqtt1’ >> /etc/openhab2/services/add”

Then what ever user the echo is running as doesn’t have permission to write to that file. By default the files are owned by openhab:openhab. You will either need to add whatever user you are running as to the openhab group or run the command using sudo.

can you write one line command

Usage of sudo: