Ive been running hassio on an rpi2 for about a year. It worked fine until today when it failed to run the mqtt service giving a connection refused error. The python file specified the mqtt server as hassio.local. I changed it to its ip address and that error is gone. Now when I run the mqttReceive.py script I get:
import paho.mqtt.client as mqtt
from failedPythonBLE import turn1ON,turn1OFF,turn2ON,turn2OFF,turn3ON,turn3OFF
MQTT_SERVER = "192.168.1.113"
MQTT_PATH = "test_channel"
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
# Subscribing in on_connect() means that if we lose the connection and
# reconnect then subscriptions will be renewed.
client.subscribe(MQTT_PATH)
# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
print(msg.topic+" "+str(msg.payload))
# more callbacks, etc
if str(msg.payload)=='01':
print "letsGoBaby! Turn On Relay 1"
turn1ON.letsgobaby()
elif str(msg.payload)=='02':
print "Turn Off Relay 1"
turn1OFF.letsgobaby()
elif str(msg.payload)=="komp-on":
print "Turn On Relay 2"
turn2ON.letsgobaby()
elif str(msg.payload)=="komp-off":
print "Turn Off Relay 2"
turn2OFF.letsgobaby()
elif str(msg.payload)=="sole-on":
print "Turn On Relay 3"
turn3ON.letsgobaby()
elif str(msg.payload)=="sole-off":
print "Turn Off Relay 3"
turn3OFF.letsgobaby()
elif str(msg.payload)=='07':
print "Turn On Relay 4"
turn4ON.letsgobaby()
elif str(msg.payload)=='08':
print "Turn Off Relay 4"
turn4OFF.letsgobaby()
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect(MQTT_SERVER, 1883, 60)
client.loop_forever()
Ok i just noticed that if I run the mqtt service directly from Developer Tools on hassio, I get this message:
Im also unable to access the configurator in hassio, I get hassio refused to connect error with sad face. However I can ping hassio.local from my laptop. I also upgraded to .103 hassio and I still get that error.
Its macbook pro. I just updated the Configurator from the Updater to 4.2 and I have access again to the configurator. I went into configuration.yaml and changed mqtt broker from 127.0.0.1 to 192.168.1.113 which is the ip address. Now when I go to publish an mqtt msg, I dont get the error (i actually get no error but nothing else happens), but i also dont get the python file running which should run. If I run the python file manually everything runs fine, but the mqtt isnt firing the python which it used to do just fine before. It must be an mqtt issue.
I also noticed these orange and red warnings in the system log:
Wait, mqtt was not installed on hassio, was it? It was installed on my rpi3 running raspbian. Thats the broker. Or well, it was running on both?
rpi2-hassio is .117 and it runs the lovelace interface.
rpi3-raspbian is .113 and it runs the python script mqttReceive.py in my OP which receives the msg and its payload in order to determine which python script to run for relay activation.
I dont know which one I used to be honest. But I know it worked. In the receiving rpi3 i was obviously using the terminal one from raspbian. I think I only have the addon one on the hassio.
I just went to my rpi3-raspbian and typed:
mosquitto_sub -d -t test_channel
and went over to rpi2-hassio in Developer Tools and tested but I dont get it on the rpi3. Weird thing is that now I dont even get it in the Developer Tools>Testing GUI either.