Blatantly stolen from mqttwarn.py