Python wrapper of libtelldus
Moderator: Telldus
Python wrapper of libtelldus
Hi
I have put togheter a wrapper for python linux users that want to skip tdtool and work directly against the libtelldus.
Source is available here:
http://bitbucket.org/davka003/pytelldus/
There is also an example that mimics tdtool but is written in python.
Currently I am lacking support for the API commands for changing the configuration and event handling.
Configuration will come, just missing answer to a question on permissions here: http://www.telldus.com/forum/viewtopic.php?f=8&t=2107
Event handling will probably also come, but as I am lacking a DUO it doesnt make much sense to develop that yet.
Please let me know what you think. Contributions are allways welcome.
I have put togheter a wrapper for python linux users that want to skip tdtool and work directly against the libtelldus.
Source is available here:
http://bitbucket.org/davka003/pytelldus/
There is also an example that mimics tdtool but is written in python.
Currently I am lacking support for the API commands for changing the configuration and event handling.
Configuration will come, just missing answer to a question on permissions here: http://www.telldus.com/forum/viewtopic.php?f=8&t=2107
Event handling will probably also come, but as I am lacking a DUO it doesnt make much sense to develop that yet.
Please let me know what you think. Contributions are allways welcome.
My home automation software: Automagically @ Raspberry Pi http://automagically.weebly.com
Re: Python wrapper of libtelldus
Now configuration and most event handling is added as well.
Currently missing support for:
All the remaining APIs are in there, as well as untested Windows support.
An example tdtool is there as well that is able to serve as an example of how it can be used.
Let me know if you have any questions.
Currently missing support for:
Code: Select all
int tdRegisterRawDeviceEvent( TDRawDeviceEvent eventFunction, void *context );
int tdRegisterControllerEvent( TDControllerEvent eventFunction, void *context);
int tdSendRawCommand(const char *command, int reserved);
An example tdtool is there as well that is able to serve as an example of how it can be used.
Let me know if you have any questions.
My home automation software: Automagically @ Raspberry Pi http://automagically.weebly.com
-
- Site Admin
- Posts: 2243
- Joined: Fri Mar 17, 2023 9:45 am
- Location: Lund
- Contact:
Re: Python wrapper of libtelldus
Great wrapper. I have just one note.
Regarding your init function. You may never assume which methods the library client will implement. This goes against the purpose of the supportedMethods variable. You should define the ini function like this:
It is always up to the end software to decide the methods.
Regarding your init function. You may never assume which methods the library client will implement. This goes against the purpose of the supportedMethods variable. You should define the ini function like this:
Code: Select all
def init(defaultMethods = 0):
Micke Prag
Software
Telldus Technologies
Software
Telldus Technologies
Re: Python wrapper of libtelldus
Noticed a bug in __main__
Should be
Same problem exists in getDeviceIdFromStr()
Code: Select all
for i in range(getNumberOfDevices()):
print getDeviceId(i), getName(i), methods(i)
Code: Select all
for i in range(getNumberOfDevices()):
id = getDeviceId(i)
print id, getName(id), methods(id)
Re: Python wrapper of libtelldus
Thanks for the bugreport, i Will look into it when i am back from vacation.
My home automation software: Automagically @ Raspberry Pi http://automagically.weebly.com
Re: Python wrapper of libtelldus
Thanks Klas and Micke for pointing out these problems. They are now fixed and pushed to the git repository. At the same time I added support for raw device event's as I just got hold of an DUO.
My home automation software: Automagically @ Raspberry Pi http://automagically.weebly.com
Re: Python wrapper of libtelldus
Great,
A suggestion, it would be nice with a debug-flag. To be used instead of if 0: in the callbacks.
A suggestion, it would be nice with a debug-flag. To be used instead of if 0: in the callbacks.
Re: Python wrapper of libtelldus
Great wrapper!
I've tried it out using mac os x adding
The only problem I've got was when calling tdlib.tdReleaseString(vp)
Or is skipping tdReleaseString the only solution?
I've tried it out using mac os x adding
Code: Select all
elif (platform.system() == 'Darwin'):
#Mac
from ctypes import cdll, CFUNCTYPE
tdlib = cdll.LoadLibrary('/Library/Frameworks/TelldusCore.framework/TelldusCore')
Do you guys know how to solve this?python2.6(10014,0x7fff752b2180) malloc: *** error for object 0xffffffffb2601c50: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Or is skipping tdReleaseString the only solution?
Re: Python wrapper of libtelldus
If you dont mind I will include your code snippet in the git repository. Is that ok?
At least once the memory handling has been strighten out.
At least once the memory handling has been strighten out.
My home automation software: Automagically @ Raspberry Pi http://automagically.weebly.com
Re: Python wrapper of libtelldus
No problem at all.
Found it while running thou the forums to learn about python/telldus.
And btw, while adding, what i did was just adding before tdReleaseString
Right now i'm thinking about tackle the tdSendRawCommand
How far have you come so far?
Found it while running thou the forums to learn about python/telldus.
And btw, while adding, what i did was just adding
Code: Select all
if (platform.system() != 'Darwin'):
Right now i'm thinking about tackle the tdSendRawCommand
How far have you come so far?
Re: Python wrapper of libtelldus
I include your source contributions then. (With a comment about potentially memory leak).
For Raw Command sending I havent tried anything at all. (I dont know any good way of testing if I am correct). But I think it should be as simple as:
I allways push all my changes to the git repo as soon as I have done anything so all I got is in there.
For Raw Command sending I havent tried anything at all. (I dont know any good way of testing if I am correct). But I think it should be as simple as:
Code: Select all
def sendRawCommand(command, reserved = 0):
return tdlib.tdSendRawCommand(command, reserved)
My home automation software: Automagically @ Raspberry Pi http://automagically.weebly.com
Re: Python wrapper of libtelldus
Hi!
I can't get this to work. If I run the python script with -t option and trigger a sensor, nothing happens. Am I missing something? I can't add the sensor to tellstick.conf as I have no information about it. I think I have installed all libraries from the repo, so what am I missing? Is there a guide for getting sensors to work in linux with tellstick duo? I can't seem to find any useful information...
I can't get this to work. If I run the python script with -t option and trigger a sensor, nothing happens. Am I missing something? I can't add the sensor to tellstick.conf as I have no information about it. I think I have installed all libraries from the repo, so what am I missing? Is there a guide for getting sensors to work in linux with tellstick duo? I can't seem to find any useful information...
Re: Python wrapper of libtelldus
You dont have to configure anything in Linux to get sensors to work. But be aware that the range may not be very good. My temp sensor sends a signal every 50 sec. If the duo receive the signal it flashes blue. Also you could try pressing the button on a ordinary nexa remote or similar. This should also give you blue blink.
My home automation software: Automagically @ Raspberry Pi http://automagically.weebly.com
Re: Python wrapper of libtelldus
Yes, I do see it flashes when triggering my motion sensor or pressing the remote. But how will I access the data? Is using the API the only way or are there other tools for testing?
Re: Python wrapper of libtelldus
I think there is a clarification needed.
Sensors in the tellstick world are not Nexa motion detectors or light sensor. It is only temperature and humidity that is sensors. All others are deviceevent or rawdeviceevent.
If you see the duo flashes you should see a rawDeviceEvent (or many) if you run python tdtool.py --event
To make it device event you need to create a device entry in /etc/tellstick.conf matching the protocol/house/unit code reported in the rawdeviceevent.
Sensors in the tellstick world are not Nexa motion detectors or light sensor. It is only temperature and humidity that is sensors. All others are deviceevent or rawdeviceevent.
If you see the duo flashes you should see a rawDeviceEvent (or many) if you run python tdtool.py --event
To make it device event you need to create a device entry in /etc/tellstick.conf matching the protocol/house/unit code reported in the rawdeviceevent.
My home automation software: Automagically @ Raspberry Pi http://automagically.weebly.com