This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on Button#Switch do | |
| if [State#State]=0 | |
| gpio,15,1 | |
| else | |
| gpio,15,0 | |
| endif | |
| endon | |
| On MQTT#Connected do | |
| // **** switch on gpio 15 **** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # based on examples found at | |
| # https://learn.adafruit.com/running-programs-automatically-on-your-tiny-computer/systemd-writing-and-enabling-a-service | |
| # https://medium.com/@johannes_gehrs/getting-started-with-systemd-on-debian-jessie-e024758ca63d | |
| # https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/ | |
| # https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Before= | |
| # https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Wants= | |
| # copy to target with: | |
| # sudo cp olad.service /etc/systemd/system/ | |
| # enable service |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # While this code still works, I would recommend using Fast API for websockets in modern applications. | |
| # See: https://fastapi.tiangolo.com/advanced/websockets/ | |
| # Note this is targeted at python 3 | |
| import tornado.web | |
| import tornado.httpserver | |
| import tornado.ioloop | |
| import tornado.websocket | |
| import tornado.options |