Python mqtt binary sensor example

I want to feed some sensor data in to HA from another computer and I guess the easiest way is MQTT. Does anyone have a good example of a simple binary sensor in python using MQTT including HA discovery and availability?

You can get inspiration here:

1 Like