@federic0
OK so I literally just banged together what I think will workā¦
completely untestedā¦
should be
ninjaCape/input/31/0202 for your first temp sensor and
ninjaCape/input/31/0301 for the second
test it and let me know!
@federic0
OK so I literally just banged together what I think will workā¦
completely untestedā¦
should be
ninjaCape/input/31/0202 for your first temp sensor and
ninjaCape/input/31/0301 for the second
test it and let me know!
Hi @perrin, thanks a lot for the quick reply! Just tested your new code, itās not working for me⦠Iām trying to see whatās going on but hereās an error I get when I try to actuate a wall plug:
ubuntu@ninjablock:/opt/openhab$ ./ninjaCapeSerialMQTTBridge.py
Connecting... /dev/ttyO1
Connected
Traceback (most recent call last):
File "./ninjaCapeSerialMQTTBridge.py", line 132, in <module>
ser.write(mqtt_to_JSON_output(outputData.pop()))
File "./ninjaCapeSerialMQTTBridge.py", line 69, in mqtt_to_JSON_output
json_data = '{"DEVICE": [{"G":"'+ topics[3] +'","V":0,"D":' + topics[2] + ',"DA":"' + mqtt_message.payload + '"}]})'
IndexError: list index out of range
Otherwise, thereās no output generated from ninjaCapeSerialMQTTBridge.py
The error I just cited is coming from my actuatorās topic missing the GID, the code is expecting an array of size 4. @perrin, in order not to break otherās rules and items you could probably test for the size of topics and when size is 3 go with your previous code.
The code is working, I had a typo in my item declarations for the thermometers. Sorry. However, you need to add a GID of ā0ā and not ā1ā to other items with the new script, i.e.:
mosquitto:ninjaCape/input/11:state:ON: 000000000000010101010001
needs to be:
mosquitto:ninjaCape/input/11/0:state:ON: 000000000000010101010001
@federic0 Nice! thanks for testing this. Yeah, iāll put a test in that if there is no GID specified then use zero - which should allow backwards compatibility.
Once I get around to itā¦
Hi guys, Iām struggling with some sensors (cheap rf 433 Mhz PIRs and door sensors). When triggered they send a burst of signals (can be 4 signals within a second) and they seem to be activating my rules āin parallelā. The items are coming from the mqtt broker which receives them from the NinjaBlock. Anyone with NB with the same issue?
(I started a topic on this with more details here)
Hi Everyone,
I have a working setup using OpenHAB and MQTT running on a RPi and a gateway on an Arduino as a receiver/transmitter for 433Mhz for FSK modulation. Now I want to my NB as a āgatewayā for 433Mhz ASK modulation. If I got it right I just need to install MQTT client, shutdown Ninjablocks and install the script to collect the data from the receiver/transmitter and send through MQTT, is that right?
Perrin, thanks for the script.
Cheers,
Saback
pretty much, yeah. The script just monitors the serial port and converts it to mqtt messages.
Thereās some info on the wiki about how to configure items etc.
Hi Perrin,
The script is working with some issues. The first time I run it I get an error that there is no route to route. If I just run the same command again (with no change) it works (see below). When I start it as service I have the same symptom and even when it starts as a service, it works for few minutes and stop sending messages to MQTT (running in another server). I have other gateways sending message to this MQTT server without problems and the Ninja blocks is connected to the same network and I monitored the connectivity and couldnāt find any network error. Any thoughts?
Thanks in advance!!!
root@ninjablock:/home/ubuntu# python /opt/openhab/ninjaCapeSerialMQTTBridge.py
Connecting⦠/dev/ttyO1
Traceback (most recent call last):
File ā/opt/openhab/ninjaCapeSerialMQTTBridge.pyā, line 117, in
mqttc.connect(broker, port, 60)
File ā/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.pyā, line 612, in connect
return self.reconnect()
File ā/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.pyā, line 734, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File ā/usr/lib/python2.7/socket.pyā, line 571, in create_connection
raise err
socket.error: [Errno 113] No route to host
root@ninjablock:/home/ubuntu# python /opt/openhab/ninjaCapeSerialMQTTBridge.py
Connecting⦠/dev/ttyO1
Connected
Subscribed. mid: 1
line to decode: {āDEVICEā:[{āGā:ā0ā,āVā:0,āDā:1007,āDAā:ā000000ā}]}
looks like its the MQTT client thats crashing out, which is odd. Make sure you have the latest version from here:
https://eclipse.org/paho/clients/python/
or do a
pip install paho-mqtt
The āno route to hostā suggests an issue with your network - could you have a duplicate IP address or something simple thats interfering with it?
Hi Perrin,
I did a full update/upgrade of the ubuntu and updated paho-mqtt as well. Iāll run some tests later today but it is working fine as a background job with a &.
I donāt have any other device with the same IP and I started a ping session from the Ninja to the MQTT server before I had run the script meaning that there is connectivity between both devices and it is still showing the same error. Iāll let you know how it will behavior after the upgrade.
Thanks,
Saback
Sorry for the huge delay, Iāve been distracted by a bunch of other projects. Iām still having problems with my OpenHab config, Iām pretty sure itās my items file thatās wrong.
Hereās my default.items:
Group All
Group mainFloor (All)
Switch Doorbell "Doorbell" (All) <bell> {mqtt="<[mosquitto:ninjaCape/input/11:state:ON:010001000101010101010011],
>[mosquitto:ninjaCape/output/11:command:ON:010001000101010101010011]"
}
Switch smoke_1 "Lower Smoke Detector" (All) {mqtt="<[mosquitto:ninjaCape/input/11:state:ON:010101000101000100110000],
>[mosquitto:ninjaCape/output/11:command:ON:010101000101000100110000]"
}
Group frontroom "Front Room" (mainFloor)
Switch TV_Socket "TV Socket" (frontroom) {mqtt="<[mosquitto:ninjaCape/input/11:state:ON:000101010101010001010101],
<[mosquitto:ninjaCape/input/11:state:OFF:000101010101010001010100],
>[mosquitto:ninjaCape/output/11:command:OFF:000101010101010001010100],
>[mosquitto:ninjaCape/output/11:command:ON:000101010101010001010101]"
}
Color NinjaEyes (frontroom) {mqtt="<[mosquitto:ninjaCape/input/1007:state:JS(ninjaEyesColor.js)],
>[mosquitto:ninjaCape/output/1007:command:*:JS(ninjaEyesOutput.js)]"}
Color StatusLight (frontroom) {mqtt="<[mosquitto:ninjaCape/input/999:state:JS(ninjaEyesColor.js)],
>[mosquitto:ninjaCape/output/999:command:*:JS(ninjaEyesOutput.js)]"}
Group kitchen "Kitchen" (mainFloor)
Switch DW_Socket "Dishwasher Socket" (kitchen) {mqtt="<[mosquitto:ninjaCape/input/11:state:ON:000101010001010101010101],
<[mosquitto:ninjaCape/input/11:state:OFF:000101010001010101010100],
>[mosquitto:ninjaCape/output/11:command:OFF:000101010001010101010100],
>[mosquitto:ninjaCape/output/11:command:ON:000101010001010101010101]"
}
And my starter default.sitemap:
sitemap default label="Main Menu"
{
Frame label="TV" {
Switch item=TV_Socket
Switch item=DW_Socket
}
Frame label="Ninja" {
Colorpicker item=NinjaEyes
}
}
Hi Perrin,
After the update/upgrade it is stable running as a background job (&) but still not working when I start it as a service. Iāll try to troubleshoot it more this weekend.
Cheers,
great, thanks. I didnāt write the service config file, and tbh I donāt know a lot about init.d, so itāll be a learning experience for me too!
If it works running by hand but not as a service the problem is almost certainly one of permissions. When you are running it by hand I assume you are running it as the root user. But when it starts as a service (assuming you installed using apt-get) it runs as the openhab user. So you have to give openhab access to read and write to all the things it needs access to.
For example, a common problem with z-wave is that the openhab user needs to be added to the dialout group so it can read and write to /dev/ttyUSB0 (or whereever the z-wave controller appears). Another problem might be openhab doesnāt have permission to write to /var/log/openhab or read from /etc/openhab.
On a Raspberry Pi one problem can be that you need to be root to access the GPIO pins. If this is the case, you may need to update the openhab script in /etc/init.d so it starts with the root user and group instead.
Hi rlkoshak,
Thanks for your reply. Iām running OpenHAB in a different RPi. The problem is to start the Python script wrote by Perrin. The script starts it as ubuntu user (sudo) so I donāt believe that itās related to permissions. Iāll write a new start/stop script to test. Iāll let you know the outcome.
Cheers,
From first glance it looks OK to me.
Whatās not working exactly?
Can you see the inputs and outputs using mosquitto_sub -t ā#ā ?
if you monitor the openhab events.log do you see the items changing state or receiving commands?
No errors in openhab.log related to mqtt?
Sorry for beeing slow, but can I install openhab on the sphere and be able to control zigbee/zwave devices using the spheres hardware?
hi guys - Iām using the step-by-step here https://github.com/perrin7/ninjacape-mqtt-bridge/wiki/Setting-up-OpenHAB-on-rpi-(and-BBB)
except that Iām doing a fresh install with wheezy on my RPI with the piCrust. I get to the end of the step-by-step and I try and start mqttbridge but am only getting unrecognised service. What am I doing wrong?
Also, what else do I need to install for the pi Crust as Iāve not got Ninjablocks on it? WiringPi? 433utils?