TellStick + Python
Posted: Fri Mar 17, 2023 9:45 am
Hello,
I have done some research on using Python with the TellStick, and have managed to get it working, with the tellcore-py wrapper. Although I don't entirely understand how to use it.
The code I have written is very bad, but it does the job for now. Could someone please help me optimise it. I can't find out how to use an existing device either, so my .conf file adds a new entry *every* time I run the script...
Here is the code:
from tellcore.telldus import TelldusCore
core = TelldusCore()
Switch = core.add_device("Switch", "arctech", "selflearning-switch", house=9, unit=1)
Switch.turn_on()
print "ON"
I have it on a webserver too, and it's connected to an 'On' button on the index page. Is there a way I can make the .py page close it's self after running the script? How do I call the device named 'Switch' without it creating a new device every time?
Do I even need the wrapper? All I want to be able to do, is visit a webpage and have it run a script in the background to turn on/off the power.
I have done some research on using Python with the TellStick, and have managed to get it working, with the tellcore-py wrapper. Although I don't entirely understand how to use it.
The code I have written is very bad, but it does the job for now. Could someone please help me optimise it. I can't find out how to use an existing device either, so my .conf file adds a new entry *every* time I run the script...
Here is the code:
from tellcore.telldus import TelldusCore
core = TelldusCore()
Switch = core.add_device("Switch", "arctech", "selflearning-switch", house=9, unit=1)
Switch.turn_on()
print "ON"
I have it on a webserver too, and it's connected to an 'On' button on the index page. Is there a way I can make the .py page close it's self after running the script? How do I call the device named 'Switch' without it creating a new device every time?
Do I even need the wrapper? All I want to be able to do, is visit a webpage and have it run a script in the background to turn on/off the power.