Ninja Sphere and Ninja Blocks with openHAB

Hi all,

We had a good conversation here about using the ninja sphere or blocks in the openHAB world -
https://discuss.ninjablocks.com/t/openhab-vs-open-source-sphere/3680/136

I’d suggest that conversation moves to this new forum!

@perrin

I have been using your script to transport 433 data to MQTT and thus into openhab, and it’s been perfect, thanks!

The only thing: I am also using eventghost with the MQTT client plugin, and that requires that topics be started with a slash as in /ninjaCape/# rather than ninjaCape/#.

I modified my local version last night, which is of course simple, but wonder if it should go in the github version of your script?

Cheers!

Thanks! Glad it is useful :smile:

Interesting nuance between mqtt brokers. I’d have to test with mosquitto and see if it complains about a leading slash. Does that mean your items in openhab are configured like:

Switch PIR_1 "Motion Sensor 1" (Persist_Change) {mqtt="<[mosquitto:ninjaCape/input/11:state:ON:010101010101010101010101]"}

(Notice there’s no leading slash… )

Think I answered my own question -
http://www.hivemq.com/mqtt-essentials-part-5-mqtt-topics-best-practices/

Looks like there shouldn’t be a leading slash for ‘best practise’

EDIT: found a few other links with definitions including the leading slash… so :confounded:

:smiley:
I looked and found conflicting info too…

I did have the config as you have it, but last night changed to

Switch PIR_1 “Motion Sensor 1” (Persist_Change) {mqtt="<[mosquitto:/ninjaCape/input/11:state:ON:010101010101010101010101]"}

note, with leading slash. This is working with mosquitto as the broker. I needed to do this as I want to have some communication between openhab and eventghost and the EG pluging requires a leading slash.

Maybe you shouldn’t change it if it isn’t clearly best practise, as it’s working fine for me with simple modification! Thanks again :slight_smile:

1 Like

No worries, maybe I’ll add it as a configurable item instead of hardcoding it.
Ill add it to the github repo as a ‘todo item’

I actually need to add another level to the topics at some point as well, as the “GID” which I assumed was always ‘1’ in the script changes if you have more than one of the ninja temperature/humidity sensors.

1 Like

Yeah, it was me that told you that, on the NB forum :wink:

Thanks again!

2 Likes

Just writing a message to add my support!

I got the v1 and v2 running with the mqttbridge, updated the wiki page with my experience

In the BBB I left OpenHab v1 running, just because it is easier to install with apt-get. Only thing I had to do is limit the memory in JAVA_OPTS and create a swap file, otherwise OpenHab was crashing every day, killed by the kernel

1 Like

Hi

Followed you from the NinjaBlocks forum. I’ve ditched the Ninja image on my Pi, started with a fresh raspbian image, installed everything as per the instructions - with a couple of changes (openhab installed itself in /etc/openhab not /opt/openhab and I had to install upstart to get the services to start).

I can see that the messages are making it to MQTT by subscribing to them, but the connection with openhab doesn’t seem to be there.

Can anyone give me any tips on debugging this, like where are the logs I need to be looking at etc?

I can tell I’m pretty close. The combination of OpenHab and the PiCrust seems like it will be pretty powerful.

So you have a MQTT broker installed and can subscribe to the messages? All thats left is to configure the openHAB MQTT binding to subscribe to the broker, and start configuring items!

If you need some help doing this, reply and all see what I can do :slight_smile:

Thanks, I’d appreciate a bit of help. Haven’t had a chance to have a play since I wrote my last message.

I managed to get everything set up. I can view the OpenHab interface in the browser and I can view the messages successfully using mosquitto_sub.

OpenHab was configured using the instructions from the wiki page, i.e.

#default stuff    
folder:items=10,items
folder:sitemaps=10,sitemap
folder:rules=10,rules
folder:scripts=10,script
folder:persistence=10,persist
#mqtt stuff. In all my examples, broker name is mosquitto - this is customisable.
# if you need to add in authentication here, you can do that also - see default config for required lines
mqtt:mosquitto.url=tcp://127.0.0.1:1883

OpenHAB doesn’t reflect changes to RF devices and changing things in OpenHAB web interface doesn’t have any effect.

I’ll try and get it going this evening if I get a chance and see if I can pull anything useful out of the logs.

Thanks for the help!

It looks like your openhab.cfg is ok.
Can you post your item and sitemap definitions?
I assume your item doesn’t have a mis-spelled mosquitto as the broker? :slight_smile:

I wouldn’t be at all surprised! it’s bound to be something simple like that.

I had a quick go last night, although I forgot to pull off the log and the config files, so I’ll do that this evening.

It looks like the sitemap doesn’t seem to be able to find the relevant items, so it must be a problem in the item definition.

if you can post the items and sitemap entries it should something easy enough

Silly question - I’ve got one of the original Ninjablocks (white Beaglebone board - Rev A6a) - not a cape on a RPi or Arduino. Can I install Ubuntu & OpenHAB on it and use the Ninjacape-mqtt-bridge on it?

Is it possible to run the bridge on the NB and have it talk to a mqtt broker/OH instance on another machine?

I too have a Beaglebone white (ninjablock), I haven’t tried installing openhab on it, however, I have installed mosquito and the mqttbridge on the beaglebone and openhab on a separate server and it works. Installing mosquito somewhere else should work too.

Also on BBW, have the bridge on that, mosquitto and openhab running elsewhere. Works well…

I’m trying to configure, the thermometers that come with the NB (I own two thermometers). I am able to get the temperature though mqttbridge, however, when using the following item:

Number Thermo_1 “Thermo 1 [%.1f °C]" <temperature> (Kitchen) {mqtt=" <[mosquitto:ninjaCape/input/31:state:default]"}

I get readings from both sensors, so I am trying to set a regex in order to identify the right sensor, this is what mqttbridge outputs for the sensors:
Thermometer 1:

 line to decode: {"DEVICE":[{"G":"0202","V":0,"D":31,"DA":21.50000}]}
 json decoded: {u'DEVICE': [{u'DA': 21.5, u'D': 31, u'G': u'0202', u'V': 0}]}

Thermometer 2:

line to decode: {"DEVICE":[{"G":"0301","V":0,"D":31,"DA":22.30000}]}
json decoded: {u'DEVICE': [{u'DA': 22.3, u'D': 31, u'G': u'0301', u'V': 0}]}

As you can see both sensors can be identified by the G id (0202 & 0301).

Would appreciate any help in writing the correct regex in order to get the data from the right thermometer.

Hi @federic0

Yeah this is a known issue and I haven’t spent any time fixing it - its actually Issue #1 :smile:https://github.com/perrin7/ninjacape-mqtt-bridge/issues/1

Its a really simple fix - just need to add another level to the mqtt addressing - which will break everyone’s rules :frowning:

I didn’t realise that the ninja cape used the GID to identify items (i only have one temperature sensor!), so I hardcoded it to be ‘1’