More fan fun

I’ve had a couple of threads on here recently about an openhab switch and a mosfet relat and a raspberry pi…individually it’s all working.

So the raspberry pi with a dht22 is using mqtt to send temps to openhab (another machine).
And I’ve got a switch in openhab that sends a command to the raspberry pi that then controls the mosfet relay - if i flick the switch in the intreface the fan is controlled.

I’ve now been mucking around with a rule to use that temp and turn the fan on - ie Fan Based Temp control - who should control fan
So i got that working today with @rlkoshak’s help and now that the temp hits the threshold the logging says the fan it on…but it’s not.

I’d added a couple of triggers, when the temperature is updated and assigned to an arbitary switch I use for testing. When I use the switch I see it interrogate the temp, find it’s reached threshold and post the MQTT topic that the fan is listening for…all is fine.

But when I let the temperature update trigger the rule, I see the openhab logging say fan turned on, I see the mqtt binding post that it’s publishing the OFF command, but I see nothing on the raspberry pi listening for the message.

What could the difference be between the temperature received update and the switch received update…as they’re both running exactly the same code, but one doesn’t seem to be causing the mqtt to be received.

So for some reason something on the receiving end wasn’t working…but nothing I saw indicated that.

My python code for creating the mqtt client read: mqttc = mqtt.Client(“python_pub”) and I changed it to mqttc = mqtt.Client()

Don’t ask me why this solved the problem - unless the older way was publish only? doesn’t make sense though as it was subscribing when triggering the rule manually, just not as part of the temp update.