Ninjablocks

I was curious if anyone had any success running HA on a ninjablock. And if so, how’d you do it?

I did, but just wiped it and didnt use the 433.92mhz transmitter/receiver on it. It was much slower than on Raspberry Pi3

some discussion here:

I had a pi shield.

I am not using it currently - I now use RFLink to listen for the ninjablock temperature sensors (plus a lot more)

I looked at that post, and I didn’t find it terribly helpful as I didn’t understand how it was installed onto the block in the first place.

I am currently using an Android (Remix Mini specifically) running HA. Thoughts on if there is a way to have the 433mhz tie into that?

Hi, I now use my ninjablock for almost 2 years now with hass. I really like it.
I did a clean install of debian. In this install you need to activate the port to the cape : BB-UART1. This works differently on the Debian stretch then on the previous Debian versions.

Then you install the ninjacapebridge from Perrin (if you google you will find his github page)
Then install mqtt.
Then install hass.

Now you can communicate with the cape with mqtt and the other way around.

Works like a charm on all 433 devices

thank you @bart.

I know of the ninjacapebridge git page…I stumbled onto that when I was attempting to research the possibility of resurrecting my ninjablock. The rest of it looks like I need to do some Google searching.

Good luck! If you get stuck just ask. I will look for my configuration to send you.

So, do you mind helping a fellow ninja?
I have:
-RPi 3 with a cape (dosn’t quite fit as the RPi 1 had less pins…)
-i also have an old rpi1, in case I can’t use the rpi3.
-Debian Jessie
-hass 0.55 (as of today)
-mqtt up and running

I have read mqttcapin git stuff, however, how do I incorporate (that part that you mentioned about the port?)

Thanks in advance.
I currently use that the 433 anteneas with the RPifx script, but unable to receive any day :frowning: that’s so sad…

I use the original ninjablock beagleboneblack.

This is what I did:

*Install Debian (stretch)
—if you open a port you have to protect your device! (like add new user/ passwords/ passwords to root etc etc.
*install mqtt
–just follow: https://www.youtube.com/watch?v=AsDHEDbyLfg

curl -o /root/ninjaCapeSerialMQTTBridge.py https://raw.githubusercontent.com/perrin7/ninjacape-mqtt-bridge/master/ninjaCapeSerialMQTTBridge.py
chmod +x ninjaCapeSerialMQTTBridge.py

sudo curl -o /etc/init/mqttbridge.conf https://raw.githubusercontent.com/perrin7/ninjacape-mqtt-bridge/master/mqttbridge.conf
service mqttbridge start

----- don’t forget to make this service start on boot up. There are a few instructions on the web to make rc.local work on Debian Stretch. (http://www.pc-freak.net/blog/rc-local-missing-in-debian-8-jessie-and-deiban-9-stretch-and-newer-ubuntu-16-fedoras-etc-why-is-that-and-how-to-make-etcrc-local-working-if-its-not/)

Put in rc.local:
su -c ‘/root/ninjaCapeSerialMQTTBridge.py’ >>/dev/null 2>&1 &

In the ninjaCapeSerialMQTTBridge.py file I changed one string to get more specific stings.

            # split the JSON packet up here and publish on MQTT
            json_data = json.loads(line)
            if(debug):
                    print "json decoded:",json_data

            try:
                    device = str( json_data['DEVICE'][0]['D'] ) + str( json_data['DEVICE'][0]['G'] )
                    data = str( json_data['DEVICE'][0]['DA'] )
                    mqttc.publish("ninjaCape/input/"+device, data)
            except(KeyError):
                    # TODO should probably do something here if the data is malformed
                    pass

if you want to use a password and username on mqtt you have to put it here in the bridge:

#connect to broker
    mqttc.username_pw_set("your-username", password="yourpassword")
    mqttc.connect(broker, port, 60)

    # start the mqttc client thread
    mqttc.loop_start()

examples in my configuration file:

sensor 2:
  platform: mqtt
  state_topic: "ninjaCape/input/310303"
  name: "temperatuur sensor-binnen"
  qos: 0
  unit_of_measurement: "°C"

sensor 3:
  platform: mqtt
  state_topic: "ninjaCape/input/300303"
  name: "humidity-binnen"
  qos: 0
  unit_of_measurement: "%"

if you don’t change the line in the ninjaCapeSerialMQTTBridge.py , then you don’t get the specific state topic.

one of my motion sensors:

binary_sensor 1:
  platform: mqtt
  state_topic: "ninjaCape/input/#"
  name: "beweging-overloop"
  qos: 0
  payload_on: "101111100100010011001111"
  payload_off: "000000"
  device_class: motion

For payload_off I use the “000000” payload. This is one of the codes for ninjablock eyes which is blinking on every ninjablock for every 10 seconds or so. Puts your sensor to off…

This is one of my switches like the klik-aan-klik-uit:

switch 1:
  platform: mqtt
  name: "avl"
  state_topic: "ninjaCape/input/110"
  command_topic: "ninjaCape/output/11"
  payload_on: "000000011100110001001101"
  payload_off: "000000011100110000000100"
  optimistic: true
  qos: 0
  retain: true

With all the 433 devices you can make a lot of nice automations. As example;

automation 23:
  alias: avond lamp woonkamer
  trigger:
    - platform: state
      entity_id: binary_sensor.bewegingwoonkamer, binary_sensor.bewegingtafel
      to: 'on'
  condition:
    - condition: time
      after: '20:00:00'
      before: '01:00:00'
  action:
    service: homeassistant.turn_on
    entity_id: script.timed_lamp7


automation 30:
  alias: buitenlamp aan in donker bij openen deur en achterdeur
  trigger:
    - platform: state
      entity_id: binary_sensor.voordeuropen, binary_sensor.achterdeuropen
      to: 'on'
  condition:
      condition: and
      conditions:
      - condition: state
        entity_id: binary_sensor.schemersensor
        state: 'on'
      - condition: state
        entity_id: input_boolean.variabel
        state: 'off'
  action:
    - service: switch.turn_off
      data:
        entity_id: switch.lampbuiten
    - service: switch.turn_off
      data:
        entity_id: switch.lampbuiten
    - delay: '00:00:01'
    - service: switch.turn_on
      data:
        entity_id: switch.lampbuiten
    - service: switch.turn_on
      data:
        entity_id: switch.lampbuiten
    - delay: '00:00:02'
    - service: homeassistant.turn_on
      data:
        entity_id: input_boolean.variabel
    - delay: '00:05:00'
    - service: homeassistant.turn_off
      data:
        entity_id: input_boolean.variabel
3 Likes

So, I having issues right at the start with trying to flash Debian onto my BBB. I followed the instructions at Beagleboard, including how to flash it on board. However, well after 45 minutes have passed, the all four LEDs remain steady lit. Did you have any trouble?

@bart So somehow I got Debian to finally install. Got mosquitto to install. Can’t get Python to install. I got the error e: you don't have enough free space in /var/cache/apt/archives.

I tried searching to see what may be the cause, how to troubleshoot/address, etc, as the BBB has 4 GB, etc. There aren’t any other partitions except the main one, I think. I tried sudo apt-get clean and sudo apt-get autoclean, but neither helped (nor do I think they should have in my case, as since I was starting fresh there shouldn’t have been anything for them to clean).

I should mention that I’ve been doing all this with the shield/cape physically removed. It seemed to only way to install Debian (as to get to the buttons on the BBB, etc). I don’t know when I am supposed to reattach them.

Did you run into this issue?

Did you use the iot version of Debian? This one should be less then 2gb. It is on the website of beagleboard.

@bart - yes

Ok strange.
Can you do “df -h” in the terminal. You can see then your free and used space.
And As far Asbreuk I remember, python is already installed on Debian. You only have to install the extra s which are on the github site of perrin for the ninjabridge

this is the output of “df -h”.

> Filesystem      Size  Used Avail Use% Mounted on
> udev            217M     0  217M   0% /dev
> tmpfs            49M  5.0M   44M  11% /run
> /dev/mmcblk1p1  1.8G  1.7G  460K 100% /
> tmpfs           244M     0  244M   0% /dev/shm
> tmpfs           5.0M  4.0K  5.0M   1% /run/lock
> tmpfs           244M     0  244M   0% /sys/fs/cgroup
> tmpfs            49M     0   49M   0% /run/user/1000

Looks like you have the old beaglebone black with 2gb.
You better use the sd-card. I do the same cause my emmc got corrupted somehow…
I use a 16gb sd card.
This website was very helpful to expand size and update all kind of things like kernel and time
https://elinux.org/Beagleboard:BeagleBoneBlack_Debian

You can also give the bbb a static ip with conman. If you don’t know how, I will post it.

My block has a static IP from before.

Everything has been going fine until chmod +x ninjaCapeSerialMQTTBridge.py2. I get chmod: cannot access 'ninjaCapeSerialMQTTBridge.py2': No such file or directory.

Also, in following the instructions to install ninjabridge, it says to run the command service ninjablock stop OR service ninjablocks stop. I tried running both, getting the error:

Failed to stop ninjablock.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files
    See system logs and 'systemctl status ninjablock.service' for details.

I see you have py2. Shouldn’t this be .py ?
And I think you have to use sudo

Ninjablocks service isn’t installed on your device, so you cannot stop it.
You only have to install:
Install some prereqs##

We need pip to install some python pre-reqs

sudo apt-get install python-pip
sudo pip install pyserial
sudo pip install paho-mqtt

—don’t install openhab cause you use home assistant.

And then what I already posted.

@ bart - I am following directions step by step. I am assuming they are prescriptive.

So I installed Debian, used pip for the pre-reqs, entered the curl command…all goes fine there.

You were correct in your first reply. Somehow I added the extra “2” so that it was supposed to be “.py” (not sure how I did that as I just copy/pasted from this discussion into my terminal).

Still, when the error is fixed (as in chmod +x ninjaCapeSerialMQTTBridge.py like you wrote above), I still get the error (as in chmod: cannot access 'ninjaCapeSerialMQTTBridge.py': No such file or directory is still the output).