Closed xbmcnut closed 8 years ago
P.S The buttons on the PiFace do update the log and I also receive a broker message using mqtt.fx. Sending /piface/in/0 payload 1 also does not update the log.
The script is not receiving any message on /piface/in/+
, as any thing arriving on that should be logged via logging.debug("Incoming message for pin %d -> %d" % (pin, value))
. You need to be publishing to /piface/in/0
to change the relay state of pin 0. /piface/out/+
is where the pin states being monitored are published.
Thanks for your help Ben. If I send /piface/in/0
with 1, I get the following in the log file but no output at /piface/out/+
. Is the + supposed to be a pin #? If I subscribe to /piface/out/#
, I see nothing either.
2016-08-04 08:06:02,260 DEBUG Incoming message for pin 0 -> 1
Incidentally, pushing the buttons on the PiFace does update the log, but not /piface/out/+
2016-08-04 08:13:56,805 DEBUG Pin 1 changed from 0 to 1
2016-08-04 08:13:57,033 DEBUG Pin 1 changed from 1 to 0
2016-08-04 08:13:58,018 DEBUG Pin 2 changed from 0 to 1
2016-08-04 08:13:58,355 DEBUG Pin 2 changed from 1 to 0
2016-08-04 08:14:00,096 DEBUG Pin 3 changed from 0 to 1
2016-08-04 08:14:00,432 DEBUG Pin 3 changed from 1 to 0
Further testing. /piface/out/+
is updated for all monitored pins when I start and stop the script so I know PAHO is capable of sending the messages now.
One output is working now but this is where I think the problem might be? The outputs on the V1 PiFace are 0 thru 7. When I monitor 0~7, the script will start. If I change the ini to monitor 1~8, the script will not start. However, when I publish to /piface/in/0
, nothing is published, same for any of the other inputs except input 1. If I publish to /piface/in/1
, then I DO get an output on /piface/out/+ but it reports /piface/out/0
!
Getting there Ben. All outputs are controllable using /piface/in/<pin#>
, 0 or 1. Pushing the buttons 0~3 outputs MQTT messages now e.g. /piface/out/3
(0/1) when subscribed to /piface/out/+
. So the only problem I have now is when I publish to /piface/in/0
or /piface/in/2~7
, there is no MQTT message but as mentioned above, I do get a message albeit incorrect when I publish to /piface/in/1
.
The idea with this simple script was to allow swtiching of a relay (with no acknowledgement) and to monitor digital pins. But it was not designed to both for the same pin - i.e. if you are switching pin 3 then you would not be monitoring pin 3. since your calling system knows the state (since it is controlling it).
I think that is your problem, you are expecting that when you publish a message to switch a relay, that you will receive an ack on the /out
topic. That was never designed to work that way unfortunately - it was a very simple implementation which I used with openHAB.
Thanks Ben but that doesn't explain why I get an output (desirable) when I publish to /piface/in/1. In MQTT for HA, normally the system has a feedback loop so the HA system knows the device received the message. I know I can publish a message to turn a relay on, but did it actually flip? Looks like it is real close to working perfectly if it could output MQTT messages on the other 7 pins with the right statement.
As I said before, this was never the intention so it is not going to do that for you. You are welcome to make some changes to do what you want, but I no longer use this script so won't be able to do it myself.
Thanks Ben, I totally understand. If it's OK with you, I'll ask the Home Assistant community to see if someone can fork it and update it for output messages on relay activation. Thanks heaps for all of your assistance and time, very much appreciated.
Of course - this is open source after all! I would suggest you also have a look at Homie - that might be a better match to what you are after and is a much more complete implementation than my hack!
Hi Ben,
I have it partly working now and can control the PiFace module with Python using
pfd.output_pins[7].value = 1
. Below is my ini file and the log file. It is connected to my broker but when I publish a message to /piface/out/0 with a payload of 1, the broker reports the action on /piface/# but the relay does not change state. I'm using tail -F to track the log and it is not updating past the data below after running the script.How do I debug this?