Ninja Sphere and Ninja Blocks with openHAB

Isn’t this related to wheezy being systemd-based vs sysv-init?

So I should be on Jessie?

Sorry, it’s the other way around, wheezy should be fine with those instructions.

Have you tried to manually start the python script? i.e.:


thanks for confirming :slight_smile: yeah - it -
Failed to connect serial.

I’m guessing I don’t have a driver installed… maybe I’ll try installing ninjablocks on it and disabling it - but I’m loathe to add in unnecessary packages :stuck_out_tongue:

lol ok. for all our peace of minds - that was dumb :slight_smile:

So after flashing and reflashing blocks and non-blocks, installing wiringPi etc. this is what it turned out to be:
I couldn’t find the error message anywhere and then after several hours it hit me - I’m running a damn python script - so there must be exception catching in there!!!

and sure enough - I traced the lines back - and lo and behold the serial.Serial( … var which it was trying to get is the BBB and not the RPI one (which is commented out) now I can slowly insert each strand of my hair back in again grumble

Note: this still doesn’t resolve my issue with mqttbridge not starting (unrecognised service). It just means that the python script works. ~ this would be because there’s nothing with mqtt in init.d - so no daemon, which makes me wonder why that step is in the list.

I made the messages verbose and can see: Output Data: ninjaCape/output/11 data: 101001100011100100000110

but nothing actually happens with my 433 devices… the sleuthing continued with my CompSci101 linux experience :confused:

What do you mean by nothing happens with your 433 devices, if you are seeing the mqtt messages you should be good. Did you configure mqtt on OH?

  • added pi’s address in openhab.cfg under mqtt settings (mqtt:mosquitto.url=tcp://piIPAddress:1883)
  • added the org.openhab.binding.mqtt-1.8.0.jar to addons
  • configured your items

@federic0 ok… I sorted myself out - turns out I was being dumb on 2 accounts.

a) I neglected the fact that after restart ninjablocks service starts too and occupies resources for serial (any way of fixing this? I’m not great at Linux) so I manually stopped it
b) the stupid pi Crust sometimes falls under the weight of gravity and hits the USB case of the pi shorting itself out.

All working now!! yay!

I think this should do it:
echo manual | sudo tee /etc/init/ninjablock.override

That does it - thanks. Only one last thing to figure out. The .conf file is not executing properly on start-up. I’m manually launching it at the moment based on the exec command in the .conf file (modified the user to default pi for testing purposes)

exec su pi -c “python /opt/openhab/”

works in the command line but I need to input the password - which I assume is what’s stopping it from running on reboot.

In other news, happy to share what I’ve learnt and modifications to perrin7’s tutorial coming from a complete Linux idiot.

a) make sure you install both mosquitto and mosquitto-clients (I missed clients on the first run through because of the “OR” paragraph)

b) when stopping ninja services - you might as well use both “ninjablock” and “ninjablocks” for good measure - i.e. echo manual | sudo tee /etc/init/ninjablocks.override

c) You might as well get OH 1.8 now that it’s released so modify to suit

d) Use the 2nd method (manual method) to install OH, otherwise you’ll end up with different directories than the ones you’re following the tutorial with.

e) “service mqttbridge start” does not work as it’s not daemonised - it depends on the .conf file in /etc/init/ to execute the python script on startup. In addition: i) the python script needs to be modified to ensure you’ve got the right serial device (the default in the script is set to BBB). ii) The .conf file needs to be modified to ensure you’ve got the right user/directories in there.

1 Like

anyone get to the bottom of this? I’m using the conf file in etc/init per perrin7’s original github description. I’ve never got it to work so I’ve always executed the process manually (exec su pi line) whenever I reboot - the pid persists after I close the terminal so that’s the only way I know how to do this right now.

I’ve chowned the conf file as root:root and chmod as 644 like all the other conf files in etc/init, but it just doesn’t respond to service start, nor does it start on boot. Any ideas?

description "MQTT ninja bridge"
author      "Carlos Sanchez"
start on filesystem and net-device-up IFACE!=lo
stop on shutdown
respawn limit 99 1
    export HOME="/home/pi"
    echo $$ > /var/run/
    exec su pi -c "python /opt/openhab/"
end script
pre-start script
    echo "[`date`] mqttbridge Starting"
end script
pre-stop script
    rm /var/run/
    echo "[`date`] mqttbridge Stopping"
end script

I have no programming skills whatsoever, however, google is my friend!
This is what I have tried so far:
(I read that OH uses ETC, instead of opt… so I changed some things around from:
Started with wheezy 2015 something…something…hence the rpi-update

33-sudo nano sudo
serialdev = ‘/dev/ttyAMA0’ # for RPi

and here is where all HELL broke lose:
34-sudo ./

So I got this (below excerpt from my screen ):
I went to my friend: GOOGLE, and it says it could be something with indentation? so checking for that…first, but Im also trying to find a way to capture the log (I read something about verbose!?.. no idea how to…yet)
Any help… most appreciated!

pi@ninja ~ $ cd /etc/openhab/
pi@ninja /etc/openhab $ sudo ./
Connecting… /dev/ttyAMA0
Exception in thread Thread-2:
Traceback (most recent call last):
File “/usr/lib/python2.7/”, line 552, in __bootstrap_inner
File “/usr/lib/python2.7/”, line 505, in run
self.__target(*self.__args, **self.__kwargs)
File “./”, line 82, in serial_read_and_publish
json_data = json.loads(line)
File “/usr/lib/python2.7/json/”, line 326, in loads
return _default_decoder.decode(s)
File “/usr/lib/python2.7/json/”, line 368, in decode
raise ValueError(errmsg(“Extra data”, s, end, len(s)))
ValueError: Extra data: line 1 column 5 - line 2 column 1 (char 5 - 40)

Message from syslogd@ninja at Feb 25 21:32:21 …
kernel:[ 210.807788] Internal error: Oops: 17 [#1] ARM

Message from syslogd@ninja at Feb 25 21:32:21 …
kernel:[ 210.917181] Process kworker/u2:0 (pid: 6, stack limit = 0xdd8f6188)

Message from syslogd@ninja at Feb 25 21:32:21 …
kernel:[ 210.924690] Stack: (0xdd8f7e08 to 0xdd8f8000)

Message from syslogd@ninja at Feb 25 21:32:21 …
kernel:[ 210.930315] 7e00: dd8f7e2c dd8f7e18 c0331288 c032fea4 e132e000 e132e000

Message from syslogd@ninja at Feb 25 21:32:21 …
kernel:[ 210.941091] 7e20: dd8f7e3c dd8f7e30 c03312e0 c0331268 dd8f7e9c dd8f7e40 c031a3cc c03312d4

Message from syslogd@ninja at Feb 25 21:32:21 …
kernel:[ 210.951918] 7e40: dcb71458 c004ae34 e132e000 00000046 00000000 e132e018 e1330000 e132e000

Message from syslogd@ninja at Feb 25 21:32:21 …
kernel:[ 210.962770] 7e60: 00000000 dc9370d2 00000046 dc9371d2 dd8f7e9c dcb71400 dd822014 db54a120

Message from syslogd@ninja at Feb 25 21:32:21 …
kernel:[ 210.973758] 7e80: dc937000 dd822004 dd822000 c031a840 dd8f7eb4 dd8f7ea0 c031a864 c0319e4c

Message from syslogd@ninja at Feb 25 21:32:21 …
kernel:[ 210.984881] 7ea0: 00000001 dcb71400 dd8f7eec dd8f7eb8 c031df5c c031a84c dc9c8da0 c07d4fd0

When I use

mosquitto_sub -d -t “ninjaCape/input/#”

I never get anything that comes up when I’m using my RF devices. The light on my ninjaCape flashes green when I use the motion sensor or push a button but never displays that it’s capturing any data. I made sure mqttbridge is running. I do get messages saying Sending PINGREQ and Recieved PINGRESP, but that’s it. What am I doing wrong?

Hi Paul,

Haven’t touched this for a while - but from memory the ninjablock will take control of the serial port if you don’t disable the services on the ninjablock first?
I just installed the BBB standard image and used that which removed all the ninjablocks code mucking with it.
It’s been working for ages without a hiccup (obviously over a year! crazy!)

Let me know if I can help further.

Hi everybody. I didn’t touch my Ninja Block for quite some time. But after trying openhab on Synology with mixed success I remembered my Ninja Block that would even allow me to address 433 MHz devices.
I tried updating my Ninja block by creating an SD card with Gallium (I got it from here: ) and starting Ninja with it. My Ninja block works again now, but when I ssh in I just get into ubuntu shell (without that Ninja image at login), and no Ninja add-ons in sight. Do I have to call some script? On the other side, that Gallium image doesn’t contain any reference to Ninja at all. Any idea from your side?