Even though it is probably very simple I am still trying to get my head round < and >. When you say INcoming do you mean INcoming to openhab or INcoming to the device
IN to openhab. Your line is openHAB config , so it’s obviously from the POV of OH, and you had a “>” line defining how OH would talk to the device but no “<” part. You can have both, “>” AND “<” be part of the item config line.
I am pretty sure your item definitions are not correct. Have you read the documentation here? http://docs.openhab.org/addons/bindings/mqtt1/readme.html
(Look at the sections called “Item Configuration for Inbound Messages” and “Item Configuration for Outbound Messages”)
That might be so, but I am still pretty sure your curent items are incorrectly configured.
It may be easier to give you some suggestions if you could explain how your PIR device works. It looks a bit funny to send commands towards the PIR device. Normally a PIR device does not accept commands - it will only send status updates whenever it detects motion (or lack thereof; usually determined by a timeout).
The PIR is a HC-SR501, one of the basic ones used a lot in the “Arduino World”
I may (or may not) be doing this the correct way, so i am not averse to (a bit) of criticism. After all i have learnt a lot from you guys
If we take it one step at a time, HallPIRProxy is supposed to be an indication on the OH2 UI as to the state of the PIR. Below is the item file that I now think accepts messages from the PIR and sets the state of HallPIRProxy. I’m not 100% sure what * and default does, according to the docs it is transformation and regex_filter respectively.
This will basically take the message received on the MQTT topic and try to use that to post an update to the openHAB item. This means that if your MQTT message is ON (or OFF) and your item is a Switch, then openHAB should be happy.
If your MQTT message is ON (or OFF) and you would like your item to be a Contact (as in your item file) then you would have to use the ‘transformation’ property to convert from “ON” to “OPEN” (and “OFF” to “CLOSED”).
I hope this brings you one step closer to a working solution.
Ps! I still don’t undertand the HallPIRProxy item and why you would like to send a command to a PIR.
The HallPIRProxy, is just supposed to be a visualization on the UI to the state of the PIR, so when the PIR is ON, then the HallPIRProxy displays as ON in the UI. A “Proxy” was suggested in a previous thread and my understanding was it was just an “indication” type of item. I will try your suggestions and get back to you
connect to your MQTT broker and subscribe to “#” (multi-level wildcard topic) to get all messages published to all topics.
activate your PIR and check what is actually sent to the MQTT broker
Please provide information about the exact topic and message that is sent by your PIR device, along with the configuration of openHAB for your broker connection (mqtt,cfg) and I’ll try to help you further.
Would the command mosquitto-t /# show everything in real-time. I’m hoping
you say say no because nothing is actually being displayed. However I have
mqtt.fx on my PC connected to the mosquitto server and can see lots of
topics. I will also try your suggestion but am in a rush at the moment to
get to an appoint with the dreaded accountant.
OK, so i have moved on a little further, the topic i was subscribing to was cmnd/pir1/ the topic i was publishing to was cmnd/pir1 (School boy error i guess)
As i say we have progressed, but now i get an error in openhab log
2017-12-06 10:20:23.529 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'HallPIR'
So i guess we need to be able to handle NULL someway
First of all, I suggest you get rid of the HallPIRProxy item because it is 1) simply a copy of the HallPIR item (meaning there is no more information to be gained) and 2) incorrectly defined (the same error that you had in the HallPIR item before).
This will not solve your problem, but only serve to focus the search for the root cause of your problem.
Using MQTT.fx towards your broker, you say that you see lot’s of topics, but do you find the topic and message that you are interested in?
For your openHAB item definition to work, you will need to find the following being published to your broker:
topic: cmnd/pir1
message: ON
From the warning message that you receive in the opehab log, it sounds like a message is indeed published to the correct topic, but with the incorrect content (i.e. it is not ON or OFF). Please check this!
Just a generic collection composed of snippets of advice learned the hard way;
If you don’t know what a rule is doing (or whether it’s firing at all), add debug
sendXMPP(“pellie@xxxx.xxxx.xxx”,“Warning: L2 High Temp. Alert!”)
pushover(“Warning L2 High Temp. Alert!”, “Samsung-XXX”, 0, “”, “”, “pushover”)
executeCommandLine("/bin/sh@@-c@@echodate - Warning: L2 High Temp. Alert! >> /var/log/ha.log")
The STDOUT of the OpenHAB JVM can also provide hints, together with openhab.log which generally contains the STDERR. As you most likely know, the above are just three “media types”, you can use email or syslog or anything else you want.
Check whether it works if you manually execute part of the process. You can for example send commands and update statusses via XMPP, I personally use that a lot. Try sending an update to your item, and see whether your rule fires.
Check the startup logs for any issues regarding the bindings you’re using. Some will spit out a couple of errors and never complain again until the process is restarted, reloaded or the JAR is renamed/moved/replaced.
There is a tool called strace on Linux which will show you the executed system calls. Often, this is way more than you wanted to see, so some filtering is often required. I don’t think this is the right place for a discussion on how to use it, but PM me if you can’t figure it out
This is all rather generic, as I’ve completely avoided MQTT with OpenHAB, but it might help in debugging.