In the upcoming PiCockpit release, we will have an online status tracking for Pi’s connected via picockpit-client.

image

The online function is realized by MQTT’s Last Will & Testament feature.

You can test it by unplugging your Pi from the network.

I unplugged the Pi at: 17:59:10

At about 18:00:05 it was shown as offline:

image

Why is that?

This is because MQTT has a keep-alive ping after an agreed-upon time interval between the MQTT Broker and the client.

To save network bandwidth, we assume the client continues to be there – until the next ping fails.

If the client does not respond as it should, the last will & testament message of the client is going to be sent to the right subscribers.

In other words: if your Pi disconnects, you will know after about a minute real-time in PiCockpit!

For the future we are also planning to introduce push messages, so you can be notified of a client going offline, even if you are not logged into PiCockpit.

What if the network comes back?

If the network comes back, picockpit-client (if it is still running – i.e. the Pi is in a normal state) will reconnect to the MQTT client, after a certain timeout.

Your Raspberry Pi will be shown as being online again!

Please don’t expect this to be immediate (the PAHO MQTT client will pause between attempts to reconnect, with the interval getting longer the longer it waits if I remember correctly.)

image

Showing the online state and the corresponding message (still being shown while I develop)

and this is the message about the client being offline (note that it is JSON):

{„onlineState“: „online“, „$uuid“: „4817713e-b9f6-11e9-9321-b827ebaefc47“, „$client“: „pi/000000007eaefc47“, „$ts“: 1565273103.409718}

I’m very happy how the decision to go with Vue.js for the webfrontend is turning out – it’s very good for these state changes.