"interactive mode"...how, where?

This article ( http://docs.openhab.org/administration/console.html#accessing-the-console ) in the user manual mentions “When started in interactive mode using the provided command line scripts, openHAB naturally transitions directly to the console prompt.” Where are these “provided command line scripts”, I cannot seem to locate them?

To be specific, I want to run openhab console directly from Linux command prompt with no SSH.

I would really like to be able to run specific openhab commands from a bash script, so I can cron things like lights turning on or off. Searching for such solution is leading me nowhere. Everything I find seems to be the reverse, ie running a bash script from w/in Openhab rule etc, which I dont need.

I don’t really understand what you are trying to achieve. I understand the words; but you should be using one of the APIs (Web, MQTT, OH Rule engine) to turn lights on or off.

Anyways, here are several different answers :

  • Use the OH rule engine (you can use cron expressions as triggers)
  • You should be able to run commands on the keraf console via ssh (ssh -p8101 openhab@localhost yourCommandHere).
  • Change the running state of OH. (It is a daemon from what you seem to say, so stop the daemon and run it in the foreground = interactive mode.)

I probably dont understand the right way to do this. But I cannot for the life of me understand how to cron something within OH. Every mention of scripting seems to be writing scripts within openhab, and to me that’s going off to learn another language, which I dont want to do. And there seems to be no scheduler within OH, which is pretty surprising to me, that would seem like a huge oversight.

So what is the simplest way for me to automate/schedule or script turning something on and off in OH?

I can do it through interactively Paperui (things are already setup, commo works etc), but I can’t think of any simple way to script that.

I can’t seem to script a SSH login followed by OH commands. It seems like the simplest solution would be to run some kind of a command in bash, like openhab set thing1 on, then throw that in a bash script in crontab, but I cannot seem to figure out how to do it.

Am I missing a major concept here?

This is the sort of job to tackle with rules.
http://docs.openhab.org/configuration/rules-dsl.html

Thanks, I am figuring this out. Whoever designed this seems to have intentionally set out to create the most complicated and obtuse method imaginable to do something. I would never have designed it (Openhab) this way. Why on earth build a whole rule interpretation system? For heavens sake, why not use the existing cron capabilities, and just expose the control commands to a simple text interface, and let me script whatever I want?

I really dont understand why openhab is so needlessly complicated. Why does it have its own SSH? (Linux already has it) Why does it have its own webserver? (Im already running apache for other purposes, but of course I cant use it for OH.) Why does it have its own rules interpreter? (I should be able to simply use cron and bash scripts.) Why does it prevent use of a single folder approach under a web proxy so any proxy could be used? All of these things seem only to complicate its use and add to its overall security risk, not make it better. And all of these are additional attack surfaces for me to worry about. Its pretty worrisome that anyone would think creating a web application with no authentication mechanism whatsoever is a good design.

Regardless, I am learning how to use the rules engine. Sorry for the rant. OH has some really good features, but its also got some totally illogical drawbacks.

I know computer problems can be frustrating, but you should keep in mind that openHAB is open source and is designed and improved upon by members of this community. Therefore, the people you are referencing here as intentionally creating a complicated and obtuse system are the same ones you are asking for help.

openHAb is platform agnostic - though many users run it on Linux it also runs on Mac OS X, Windows, and in other setups like Docker containers. By utilizing the Karaf command line, the system runs the same no matter what it runs on.

The rules engine does a lot more than just schedule things. Read through the page that @rossko57 referenced for more details, but your rules can react to triggers like temperature changes, lights switching on and off, etc

If you don’t like the rules engine, you can also interface NodeRed with openHAB. The openHABian installer image by @ThomDietrich offers it as an optional package if you have a compatible single-board computer. Search the forum if you are interested as there’s quite a bit of information on both.

As I said, openHAB is open source. If you have coding skills, check out the repositories on GitHub and make some contributions. If not, then you can still go to GitHub to raise some issues with your specific concerns.

2 Likes

You said that in a far more conciliatory manner than I would have, had the roles been reversed.

You are right, of course.

2 Likes

I cannot seem to understand how to “run it in the foreground”. Interactive mode is eluding me.

The “interactive Mode” would be, starting openHAB through the start.bat or start.sh script and see the log output. In openHAB2 this ist completely useless. Please startup openHAB and ssh into the karaf console

1 Like

Hello @alabamatoy,

I have just created a TODO issue in reaction to your confusing regarding the “interactive mode” in the documentation: https://github.com/openhab/openhab-docs/issues/579 I’ll try to update this part of the documentation to be better comprehensible.

My answer to the rest of your questions is the same as by others:

The best way to connect to the console is via ssh. The fact that it is using the connection method ssh really doesn’t make a difference and NO, the openHAB remote console is not meant to be used for automation. If you wanted to write an automation script outside of openHAB you are doing something wrong and I’m almost glad the console didn’t allow that. Use the build in rule engine for that it’s one of the key components of openHAB! All the rest of your questions and confusions will be solved after you’ve read the documentation and a few Tutorials and Examples. Enjoy!

I think you have the Microsoft mindset here. OH is all there is, and no one needs anything else.

I realize that Im a newb, but I really disagree with this philosophy. OH should do home automation, not SSH, not be a webserver etc. I respectfully submit that it should be simple to have something else command an action through OH. But your design approach is no, OH is the center of the universe and should direct and control everything else, its all you need. Just like Microsoft.

The do-everything design mindset is what has led to such an overly complex rule interpreter that requires me to learn a new language rather than letting me direct a OH action using the languages and skills I already have, and just issue a command to OH from within my chosen toolset.

I am obviously in the minority here and I have grumbled about this issue elsewhere in this forum, so I will not pester yall about this design approach any further.

Thanks for the insight and the offer to improve the documentation. I am willing to assist with such activities if that is desired.

openHAB is to integrate many very different systems to one control system. openHAB is intended as a translator. If you don’t want to use all techniques which are used by openHAB, feel free to make another software.
But please don’t blame the work of others, only because they didn’t program openHAB the way you want it to be.

Of course you can control openHAB and use it as a dumb bit of translator.
Use the REST API through curl, this is the way, you can control it.

1 Like

I think you are missing my point, because you have emotion and part of yourself invested in OH. And that’s fine, I understand and applaud what you have helped create. But I want to be clear on this. My point is, installing openhab adds another SSH server and another webserver, both of which ARE without a doubt additional attack surfaces, and increase risk to the system.

When one cannot have a computer for this and a computer for that due to cost, we try to install everything on one machine for efficiency sake. Apache is THE webserver, there’s not much argument there unless you are a Microsoft fan. And Linux has its own well hardened SSH services, and it has scheduling services built in. These are sound, proven systems.

My point is that its risky and foolish to add additional services when there is already a heavy-iron server installed to provide that service. Also, having these services integrated into OH makes maintenance of OH more difficult for the good dedicated people like yourself who give of your time to keep it patched and add functionality. Why not eliminate those other services, and allow the system to run behind the ones already provided by the OS? Ones which have a MUCH larger community beating on them to harden them.

Someone invested a LOT of time to create a rule system and interpreter in OH. Why not use the existing scheduling functionality of the OS (cron, systemd) and let OH focus on home automation, rather than complex integration with a webserver and SSH and rules interpretation?

I know I am odd-man-out, and this community doesn’t see this they way I do. But perhaps having worked in the world of risk management makes me think differently than most.

I will strive to be supportive and make OH better. These comments are NOT intended to be destructive, but I hope I might make some of the developers think about the system from the perspective of managing risk.

Not at all :slight_smile: I’m an end user.

Installing openHAB adds additional attack surfaces, no doubt about that.
openHAB is developed in eclipse with karaf as the platform to run all stuff. karaf has its own console, this is exposed through ssh (by default only to localhost). This is not “an additional insecure ssh service”.
jetty is used as webserver, because it’s builtin. Why installing a big apache (which has its own vulnerabilities) in addition? nginx is very popular, too, and more lightweight as apache, by the way.

Right, but to be honest, the whole smarthome thing is expensive (and just for fun, you don’t really need anything to be smart at home!) and a Raspberry3 is about… 30$? For testing, it might be ok to install openHAB in addition on a machine, but for a productive system it is highly recommended to use a dedicated machine. There is no security system builtin in openHAB, no user access control, no… nothing, so forget about insecure web services (if any), this is a less important point in security questions :wink: .

I’m using a xen server to encapsulate my services, openHAB is one of these services, but these services are only available at LAN, not WAN, and of course I own a dedicated firewall (not builtin in the router/modem).So all in all there are two computers for the network, and one of them is powerful (or was powerful when I built the system :wink: ) and the only way to use the services from internet is to tunnel through a ssh (keys only, no password allowed at all) or, as a second way, with a vpn with IPSec private/public key.
And as it’s my own network, there are no guests allowed at all. But of course there are enough holes to get caught…

2 Likes