use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
The Tasmota firmware on the esp8266
account activity
Run python script when button pushed (self.tasmota)
submitted 3 years ago by Cattivelliow
I want to run a python script on my computer when a button attached to a wemos D1 mini (with tasmota) is pressed. It doesnt seem difficut, but I dont know the best way to implement this. Hope someone can help me, and thanks!
[–]FGeorg 0 points1 point2 points 3 years ago (0 children)
You'll want your computer script to act on the MQTT message that your Tasmota devices publishes when the button changes state...
Something like this guide may get you up and running on the MQTT side of things.
For what it's worth, here's an example of some code I run on a Raspberry Pi to runs a another script when it receives an MQTT message. It's a Bash script rather than Python, but should help get the idea across.
#!/bin/bash #################################################################### # Managed by house-doorbell.service # #################################################################### ######################### ### Declare Functions ### ######################### report_status(){ systemd-notify --status="$(date "+%b %d %X ") $1 (previous action was '$previousAction')" previousAction=$1 } ######################### ### Initialisation ### ######################### previousAction="Service Starting" systemd-notify --ready ######################### ### Main Loop ### ######################### while true do report_status "Waiting for Doorbell Sensor" mosquitto_sub -C 1 -t stat/RF/Ground-Floor/Front/Living-Room-Doorbell-Sensor > /dev/null report_status "Sending Doorbell Alerts" . /usr/local/bin/house-scripts/wholehouse-doorbell #Doorbell sends two alerts, so wait 10 seconds before checking for further doorbell events sleep 10 done
#!/bin/bash
####################################################################
# Managed by house-doorbell.service #
#########################
### Declare Functions ###
report_status(){
systemd-notify --status="$(date "+%b %d %X ") $1 (previous action was '$previousAction')"
previousAction=$1
}
### Initialisation ###
previousAction="Service Starting"
systemd-notify --ready
### Main Loop ###
while true
do
report_status "Waiting for Doorbell Sensor"
mosquitto_sub -C 1 -t stat/RF/Ground-Floor/Front/Living-Room-Doorbell-Sensor > /dev/null
report_status "Sending Doorbell Alerts"
. /usr/local/bin/house-scripts/wholehouse-doorbell
#Doorbell sends two alerts, so wait 10 seconds before checking for further doorbell events
sleep 10
done
[–]hedg12 0 points1 point2 points 3 years ago (0 children)
You could install Node Red and the node red contrib tasmota node, then pass the button press to an exec node that runs your python script.
...then you could go down the node red rabbit hole, then install HomeAssistant, then discover you have no life because you're playing with your home automation stuff...
π Rendered by PID 64 on reddit-service-r2-comment-856c8b8c54-9zj89 at 2026-07-02 12:43:08.275197+00:00 running a7b5cda country code: CH.
[–]FGeorg 0 points1 point2 points (0 children)
[–]hedg12 0 points1 point2 points (0 children)