New: the AI firewall watches the whole platform and explains each incident in plain words. See how it works

Emily C.

emily30

@emily-campbell · Joined August 2025

Newcomer

Backend developer · energy

Topics
6
Replies
36
Points
0
Newcomer10 points to Member

Forum Replies Created

Viewing 15 posts – 16 through 30 (of 36 total)

From what the docs say, the mobile app is for notifications and approvals. For the switch, the web console in the phone browser works fine, that’s how I run my allotment pump.

What to set up:

  1. On the Pi’s device profile, Commands tab, add a command, e.g. method heater.set, one Yes/no parameter on, tier Basic. Boards only send Basic tier commands.
  2. Make a dashboard, add a Switch control, action Run a command, pick the Pi and heater.set, and bind the current state to a key the Pi reports (say heater_on as 0/1).
  3. On the Pi:
def on_connect(c, u, f, rc):
    c.subscribe("v1/rpc/req/+", qos=1)

def on_message(c, u, msg):
    req_id = msg.topic.rsplit("/", 1)[1]
    body = json.loads(msg.payload)
    if body.get("method") == "heater.set":
        on = bool(body["params"]["on"])
        GPIO.output(17, on)
        c.publish("v1/telemetry", json.dumps({"heater_on": int(on)}), qos=1)
        c.publish(f"v1/rpc/res/{req_id}", json.dumps({"ok": True}), qos=1)

No ports opened. Bookmark the board on your phone’s home screen and it’s basically an app. For alerts (room too cold etc.) the app gives you push on the phone, or use e-mail or a linked chat app.

Accepted solution♥ 1

Kevin, no: the broker needs SNI, so you have to connect by host name, and the certificate check is against that name too. IP is a dead end.

The clue is that the tech’s static config included 8.8.8.8. rc=-2 in PubSubClient is “connect failed”, which on an 8266 is very often a failed name lookup. I’ve seen this on plant networks a few times: the DHCP server hands out the plant’s internal DNS server, and that one only answers for internal names, or blocks outside lookups. With static config the board used 8.8.8.8 instead and everything worked. Add this after connecting and you’ll see it:

Serial.println(WiFi.dnsIP());
IPAddress ip;
Serial.println(WiFi.hostByName(MQTT_HOST, ip) ? ip.toString() : "lookup failed");

Then ask IT for one of two things: let their DNS resolve your organisation’s broker host name (it’s on the device’s Connection details card), or allow outbound DNS from that VLAN. And while you’re talking to them, outbound TCP 8883 has to be open as well, plus 443 if you ever use HTTPS. Wilson’s guess is worth guarding against anyway: wait for WiFi.localIP() to be non-zero before the first connect.

Accepted solution♥ 7
Viewing 15 posts – 16 through 30 (of 36 total)