Manage Tasmota device using MQTT and Python

  • switch Tasmota device on/off
  • read status values from Tasmota device
#connect to MQTT broker
Tasmota.connect(mqtt_broker, mqtt_port, mqtt_user, mqtt_password)
#switch on (please use the topic name configured in Tasmota)
Tasmota.on(topic_name)
#switch off (please use the topic name configured in Tasmota)
Tasmota.off(topic_name)
#read status information (flattened json result)
Tasmota.get(topic_name, "8", ["StatusSNS_SI7021_Temperature"])
Tasmota.get(topic_name, "8", ["StatusSNS_ENERGY_Power", "StatusSNS_ENERGY_Today"])

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store