From Hentschel
Jump to: navigation, search
Filelocations.png


Openhab hacks

  • log files are at ohab: log files
    • change log settings in org.ops4j.pax.logging.cfg' in the userdata/etc directory. The location depend on install, normally in /var/log/openhab2/etc.
  • karaf console login: By default disabled from anywhere but localhost. Thus ssh into ohab, then ssh from there to
    ssh -p 8101 openhab@localhost
    default pwd is habopen.
  • timeout exception prevents any further updates. This is evidently a eclipse smarthome framework bug
    2017-11-21 16:59:30.517 [WARN ] [org.apache.karaf.services.eventadmin] - EventAdmin: Blacklisting ServiceReference [{org.osgi.service.event.EventHandler, org.eclipse.smarthome.core.events.EventPublisher}={event.topics=smarthome, component.name=org.eclipse.smarthome.core.internal.events.OSGiEventManager, component.id=38, service.id=139, service.bundleid=109, service.scope=bundle} | Bundle(org.eclipse.smarthome.core_0.9.0.201711202142 [109])] due to timeout!
  • on Mac OSX: at some point, the Eclipse Devel setup quit launching the OpenHAB launch - it just hang, when accessing the web gui at port 8080 the browser was just spinning and not moving forward. Reason is that Mac OSX cannot load a graphics library and just blocks in the ClassLoader. Details here: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8019496
    • to fix, add
      -XstartOnFirstThread -Djava.awt.headless=true
      to the VM arguments of the launch
  • to show "configuration->items" in PaperUI, you need to switch from "simple" to "advanced" mode. Go to Configuration->System->Item Linking and deactivate the "Simple Mode". You will then have a new entry Configuration->Items which will show you all your items (also the ones from the files, but note that these are read-only).
  • if the mqtt broker binding doesn't start, and the log shows two entries for mqtt brokers, check /var/lib/openhab2/config/org/openhab/mqtt.config for double entries (or other files that configure another broker in that directory), and remove those files
  • if there are no channels created for a binding, then make sure the binding didn't fail with an earlier instance which is still present in the system. Delete the bindings "Thing" and re-add, thi should make things work.

OpenHAB 2.3--

  • the isy binding now wants the following before it can start (in the OH console "ssh -p 8101 openhab@localhost" )
 feature:install openhab-httpclient
 feature:install esh-io-transport-upnp   
  • for z-wave, before adding the jar to addon/, add
 feature:install openhab-transport-serial

5 inch touch screen

  • clone following repo onto pi
 sudo rm -rf LCD-show 
 git clone https://github.com/goodtft/LCD-show.git 
 chmod -R 755 LCD-show 
 cd LCD-show/
  • depending on LCD type, excute:
    • In case of 5" LCD
  sudo ./LCD5-show 
  • If you need to switch back to the traditional HDMI display
 sudo ./LCD-hdmi 

Wait a few minutes,the system will restart automatically

Homekit setup

  • setup instructions here: https://docs.openhab.org/addons/bindings/mqtt1/readme.html
    • there is a issue with the homekit addon overwriting the generated mac address on exit (I think). See https://github.com/openhab/openhab2-addons/issues/1822
      • for now, after successful pairing, set /var/lib/openhab2/jsondb/homekit.json read only after successful pairing. May have to undo to re-create a new pairing
    • after a reset of the openhab server, it may take quite some time for homekit to attempt a reconnect to the server. You can force a reconnect by putting the iPhone etc temporarily into and out of airplane mode. This forces homekit to reconnect
  • looks like most people gave up on the homekit addon in OHAB2, and use Node + Homebridge + Node-OHAB plugin. Install here: https://www.npmjs.com/package/homebridge-openhab2
    • make sure Node version already installed is > 8.0 (update to TLS version)
    • upgrade before installing the homebridge-openhab2 node contribution and the stuff required for homebridge
  • Important: When the OpenHAB server is rebooted - or the OpenHAB server is restarted, the HomeBridge server doesn't reconnect (timing problem). Need to restart HomeBridge too <-- fix me
  • Important: After initial start of OHAB, wait until that's settled, then start HomeBridge. It seems that Homebridge/Homekit needs some time to settle for updates from devices to work. Also, always restart the Home.app's on the iOS devices.

Alexa setup

  • Install the openhab cloud connector in add-ons -> misc. This will create a UUID and secret that we need for hitching up to the openhab cloud. In the background, it already attempted to log on with the created credentials, but fails (since there is no account on myopenhab yet), and will not attempt to go any further. As we'll see, this creates a bit of a problem later.
  • get the UUID and secret from
    /var/lib/openhab2/uuid
    and
    /var/lib/openhab2/openhabcloud/secret
    and create/sign on at http://myopenhab.org
  • myopenhab needs to verify email address, do so...
  • Tricky: myopenhab will still say that your openhab instance is not connected. This is b/c a earlier attempt by the openhab server failed, and now it has given up. Go back to paper ui, configuration -> services -> openHAB cloud and hit configure. Just hitting "Save" will retrigger the log-on process, which should now be ok.The log files will tell you.
  • Once we have the myopenhab cloud setup working, go to amazon.com, and search for the openhab skill. Install that skill to your amazon alexa skill set. This will ask you to permit the myopenhab cloud to get credentials and permissions from the alexa cloud. Use the defaults, eventually there is a web page that says "close this window" (you'll need pop-ups enabled in your browser, otherwise you'll miss that window).
  • Once the connection between Alexa and Myopenhab is made via the openhab skill. ask alexa to "discover devices". It should announce all devices that have HomeKit tags (both the homekit plugin and the alexa skill use the same tagging system)

MQTT

create Fireplace binding

  • see also Fireplace controller project
  • follow this -> https://docs.openhab.org/developers/development/bindings.html , look at Creating a Skeleton
  • once the skeleton is in place, we need mqtt
    • add the actual library reference ('org.openhab.io.transport.mqtt') to META-INF/MANIFEST.MF
    • add reference to OSGI Declarative Service (DS)
      • in OSGI-INF/org.openhab.binding.marlinfireplace.internal.MarlinFireplaceHandlerFactory.xml add
          <<reference bind="setMqttService" cardinality="1..1" interface="org.openhab.io.transport.mqtt.MqttService" name="MqttService" policy="static" unbind="unsetMqttService"/>> 
      • implement the methods in the named class (this case org.openhab.binding.marlinfireplace.internal.MarlinFireplaceHandlerFactory)
        public void setMqttService(MqttService mqttService) {}; public void unsetMqttService(MqttService mqttService) 

Node-RED

Zoneminder integration

  • the current binding already has the monitor ID and the session values (user/pass). With that, the URL to get a single snap shot is:
wget "http://zmhost/zm/cgi-bin/nph-zms?mode=single&scale=<scale>&monitor=<monitorid>&user=xxx&pass=yyy" -O foo.jpg
('scale' scales the image, 100 = org size)
  • should be able to integrate this binding into the ZM binding

Options to nph-zms (scraped off the web, not confirmed)

mode=[mpeg|jpeg|raw|zip|single]. defaults to jpeg if nothing is entered, and to mpeg if junk is entered 
format=[asf|swf|flv|mp4|mov|3gp|avi|mpegts|...*] is passed to zm_mpeg. only relevant in mpeg. defaults to mpeg.
seems to accept every format that ffmpeg would accept. 
monitor=n the monitor number as in zm's web interface
source=[event|*] if source =event an event will be replayed, otherwise the live stream
time= ??? replaying can either be startet specifying monitor ID and time
event= or eventID, used if source=event to specify which one is replayed
scale=x picture size scale factor in%, defaults to 100
rate=n the actual frame rate
maxfps=n maximal frame rate
frame= n replaying starts at the nth frame of an event
bitrate=x no detectable influence. only relevant in mpeg
ttl=n don't know
replay=[gapless, all]
connkey=x is used by streams through the web interface, don't know what it is
buffer=n no visible effect.
auth, user, pass used when authentication is used.

Installed bindings and Node-RED modules

  • the idea is to split the work between openhab2 and Node-RED to use the modules that appear to be working best on their respective platform.

User interfaces

There are three user interfaces that everything needs to work with and stay in sync with:

  1. Apple HomeKit for use with Siri and the Apple Home app (also on the Apple Watch)
  2. OpenHAB2 BasicUI for use in browser (either computer, panel or mobile browser)
  3. Amazon Echo voice control

Essential mapping between Apple HomeKIt and OpenHAB2 is done via the Node.js homebridge-openhab2 plugin (https://www.npmjs.com/package/homebridge-openhab2). This will map any OpenHAB2 Items decorated in the .items files into the HomeKIT space. The HomeBridge setup is essential since HomeKit can only deal with 99 accessories. Since HomeBridge is a bridge, it only counts as one. Important: The items defined in the items file also need to be in the sitemap file for updates to work. Otherwise, the items will update on restart of Home app, or when operated thru the Home app, but not when the update happens from another client (incl. HW switches)

Additional mappings of devices that have troubles with OpenHAB + HomeKit bridge can be added as separate HomeKit devices in Node-RED and hitched up to OpenHAB via the node-red-contrib-homekit plugin. To install, first look here: https://www.npmjs.com/package/node-red-contrib-homekit . However, the install needs a small modification, basically run:

> sudo apt-get install libavahi-compat-libdnssd-dev
> sudo npm install -g node-red-contrib-homekit --unsafe-perm=true

For some reason, this builds the new library in "/usr/local/lib", but the current running instance looks in "/usr/lib". Something isn't right. A hack to get around was to create a symlink to the new build module, after that, the new nodes finally showed up.

The Node RED service is installed as nodered (not node-red). Stop and start via:

> sudo systemctl stop nodered
> sudo systemctl start nodered

Cameras are mapped via the ZM node server, separate from the ohab server

Mappings of devices into Amazon Echo is done on an individual basis via the Node-RED alexa-local plugin (https://www.npmjs.com/package/node-red-contrib-alexa-local). The downside that each device has to be added separately is outweighed by the fact that the response doesn't have to go thru the Amazon cloud (fast response, works w/o Amazon cloud account). Using OpenHAB cloud is a alternative, and already enabled. We'll have to see how the two mix and match.

Openhab Cloud

  • setup with existing account

Cameras

  • cameras will be tied to openhab2 via the zoneminder binding, which will get them onto BasicUI
  • use the zm server to install Node.js + the homebridge camera node server, which gets them onto Apple HomeKit
  • the node/homebridge/camera server evidently cannot add a camera to an already existing HomeKit key mapping. The camera def's need to be present when the bridge is paired with iOS. However, it is possible to change the cam url in the homebridge config.json.
  • create a systemd service for homebridge as per the instructions here: https://gist.github.com/johannrichard/0ad0de1feb6adb9eb61a/ . If the homebridge setup was started and paired by starting manually before, copy the entire ~/.homebridge folder to /var/lib (not just the config.json), otherwise the already existing pairing info is missing. Don't forget to set correct perms/user/group on copied files. Also, make this service depend on "zoneminder.service" as explained here: https://stackoverflow.com/questions/21830670/systemd-start-service-after-specific-service
  • the resulting script is saved as homebridge.service. Commands are
    • sudo systemctl <command> homebridge on zm

ISY binding

Note: see OpenHAB ISY Binding rework before proceeding

  • install ISY binding
  • establish items in .items files, decorate for HomeKit/Alexa
  • create sitemaps for BasicUI
  • link ISY thing channels to items

It's probably best to have the Thermostat control mapped as a OpenHAB node in Node-RED as a separate HomeKit device, since the OpenHAB2 mappings for thermostats don't appear to work correctly. Also, the same is true for other "Thermostat" like devices (hottub, fireplace) - just keep Thermostats separate for now (with their own HomeKit ID). This also requires a separate Node-RED map into Alexa.

Zoneminder

  • install ZM binding
  • establish items (probably no need for decorations for HomeKit/Alexa)
  • place in sitemap (image or video tags for cam's)
  • link ZM thing channels to items

The handling of image/video streams between BasicUI and HomeKit is separate. BasicUI uses the zoneminder plugin, HomeKit uses a Node instance running on the zm server (https://github.com/KhaosT/homebridge-camera-ffmpeg)

Hottub

  • map via OpenHAb2 binding into NodeRED
  • create items
  • create in sitemap

Fireplace

  • finish Sonoff implementation
  • map via OpenHAb2 binding into NodeRED
  • create items
  • create in sitemap