Callback in C#
Moderator: Telldus
-
- Site Admin
- Posts: 2243
- Joined: Fri Mar 17, 2023 9:45 am
- Location: Lund
- Contact:
Maybe some python code can help regarding call-backs. I receive all callbacks with this code but the content of the raw is a bit confusing at the moment
Declaring the procedures
Defining the callback functions
Terminating...(tdUnregisterCallback not yet implemented in TelldusCore.dll)
Declaring the procedures
Code: Select all
DEVICEEVENTPROC = WINFUNCTYPE(c_void_p, c_int, c_int, POINTER(c_ubyte), c_int, c_void_p)
DEVICECHANGEEVENTPROC = WINFUNCTYPE(c_void_p, c_int, c_int, c_int, c_int, c_void_p)
RAWDEVICEEVENTPROC = WINFUNCTYPE(c_void_p, POINTER(c_ubyte), c_int, c_void_p)
Code: Select all
def deviceEventCallback(self, deviceId, method, p1, i3, p2):
deviceName = (c_char_p(self.dll.tdGetName(deviceId))).value
if (method == TELLSTICK_TURNON):
strMethod = "ON"
elif (method == TELLSTICK_TURNOFF):
strMethod = "OFF"
elif (method == TELLSTICK_DIM):
strMethod = "DIM"
elif (method == TELLSTICK_BELL):
strMethod = "BELL"
else:
return
deviceType = (c_char_p(self.dll.tdGetModel(deviceId))).value
self.TriggerEvent(deviceName+'.'+strMethod, payload=str(deviceType))
winsound.Beep(1000, 200)
def deviceChangeEventCallback(self, deviceId, changeEvent, i3, i4, p1):
deviceName = (c_char_p(self.dll.tdGetName(deviceId))).value
deviceType = (c_char_p(self.dll.tdGetModel(deviceId))).value
self.TriggerEvent("ChangeEvent: " + str(deviceType) + str(deviceName) + str(changeEvent))
def deviceRawEventCallback(self, p1, i1, p2):
strData = string_at(p1)
if (strData == ""):
return
self.TriggerEvent("RawEvent: " + strData + ':' + str(p1.contents))
Code: Select all
self.dll.tdClose()
#unReg = self.dll.tdUnregisterCallback( self.callbackId_0 )
#unReg = self.dll.tdUnregisterCallback( self.callbackId_1 )
#unReg = self.dll.tdUnregisterCallback( self.callbackId_2 )
Re: Callback in C#
Krambriw, would you like to share an more concrete example of your Python-code? If so, I would really appreciate it.
Thanks!
Zyber
Thanks!
Zyber
Re: Callback in C#
Hi,
Here is a first plugin for EventGhost (eg). Unzip it to a folder under plugins, restart eg and you should have the Tellstick Duo as a selectable device
http://sto.hopto.org:8080/SM/TellStickDuo.zip
You have to go into the code with a text editor and comment out one line if you get crazy from the sound it makes when a nexaL rf signal is received
Edit the line nbr 102 so it looks like this
Save and restart eg
Best regards, Walter
Here is a first plugin for EventGhost (eg). Unzip it to a folder under plugins, restart eg and you should have the Tellstick Duo as a selectable device
http://sto.hopto.org:8080/SM/TellStickDuo.zip
You have to go into the code with a text editor and comment out one line if you get crazy from the sound it makes when a nexaL rf signal is received
Edit the line nbr 102 so it looks like this
Code: Select all
# winsound.Beep(1000, 200)
Best regards, Walter
Re: Callback in C#
Hi Walter, and thanks!
I've tried to convert it for Linux but with no success. The code runs but nothing ever happens when I press the buttons on my Sartano remote (the Tellstick is receiving, and I can read the raw info from /dev/ttyUSB0).
http://www.careface.eu/test.txt
It seems like the callback function is never called. Does anybody have some idea what might be wrong?
Thanks,
Fritiof
I've tried to convert it for Linux but with no success. The code runs but nothing ever happens when I press the buttons on my Sartano remote (the Tellstick is receiving, and I can read the raw info from /dev/ttyUSB0).
http://www.careface.eu/test.txt
It seems like the callback function is never called. Does anybody have some idea what might be wrong?
Thanks,
Fritiof
Re: Callback in C#
I'm sure you are not using the TelldusCode.dll (which is for Windows) that I use in the plugin for eg but instead relevant linux telldus-core library. It might be that Telldus (Micke) haven't had time to update that library with the same fixes yet
Best regards, Walter
Best regards, Walter
-
- Site Admin
- Posts: 2243
- Joined: Fri Mar 17, 2023 9:45 am
- Location: Lund
- Contact:
Re: Callback in C#
The Linux software does not support TellStick Duo.
Please read the documentation that has been sent by email to all of you.
Please read the documentation that has been sent by email to all of you.
Micke Prag
Software
Telldus Technologies
Software
Telldus Technologies
Re: Callback in C#
oops, that's right Micke, remember now, too hot
Re: Callback in C#
Well, it must be to hot as krambriw said - I now I've read that sentence.
It's quite fun though that you can enable Duo support when compiling the source. Well, I'll write something to fix it for me until the telldus library has support for it. Is there any timeplan for this?
It's quite fun though that you can enable Duo support when compiling the source. Well, I'll write something to fix it for me until the telldus library has support for it. Is there any timeplan for this?
-
- Posts: 27
- Joined: Fri Mar 17, 2023 9:45 am
Re: Callback in C#
This seems to have gone offline... any chane of onlineing it?krambriw wrote: Here is a first plugin for EventGhost (eg). Unzip it to a folder under plugins, restart eg and you should have the Tellstick Duo as a selectable device
http://sto.hopto.org:8080/SM/TellStickDuo.zip
/br SMS
Re: Callback in C#
Now it is back on-line again
Re: Callback in C#
Krambriw can you help me? I always get error when loading plugin. Do you know whats wrong?
Error while loading plugin-file TellStickDuo.
Traceback (most recent call last) (1462):
File "C:\Program Files\EventGhost\eg\Classes\PluginInfo.py", line 126, in ImportPlugin
File "C:\Program Files\EventGhost\plugins\TellStickDuo\__init__.py", line 35, in <module>
File "logging\__init__.pyc", line 1394, in basicConfig
File "logging\__init__.pyc", line 819, in __init__
File "logging\__init__.pyc", line 838, in _open
IOError: [Errno 2] No such file or directory: 'C:\\tmp\\logging_tellstick_duo.txt'
C:\Program Files\EventGhost\eg\Classes\PluginInfo.py:293: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
Plugin: TellStickDuo
Error starting plugin: TellStickDuo
Plugin load error!
Error while loading plugin-file TellStickDuo.
Traceback (most recent call last) (1462):
File "C:\Program Files\EventGhost\eg\Classes\PluginInfo.py", line 126, in ImportPlugin
File "C:\Program Files\EventGhost\plugins\TellStickDuo\__init__.py", line 35, in <module>
File "logging\__init__.pyc", line 1394, in basicConfig
File "logging\__init__.pyc", line 819, in __init__
File "logging\__init__.pyc", line 838, in _open
IOError: [Errno 2] No such file or directory: 'C:\\tmp\\logging_tellstick_duo.txt'
C:\Program Files\EventGhost\eg\Classes\PluginInfo.py:293: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
Plugin: TellStickDuo
Error starting plugin: TellStickDuo
Plugin load error!
-
- Posts: 27
- Joined: Fri Mar 17, 2023 9:45 am
Re: Callback in C#
22:52:07 ---> Welcome to EventGhost <---
22:52:07 Error while loading plugin-file TellStickDuo.
22:52:07 Traceback (most recent call last) (1462):
22:52:07 File "C:\Program Files\EventGhost\eg\Classes\PluginInfo.py", line 126, in ImportPlugin
22:52:07 File "C:\Program Files\EventGhost\plugins\TellStickDuo\__init__.py", line 35, in <module>
22:52:07 File "logging\__init__.pyc", line 1394, in basicConfig
22:52:07 File "logging\__init__.pyc", line 819, in __init__
22:52:07 File "logging\__init__.pyc", line 838, in _open
22:52:07 IOError: [Errno 2] No such file or directory: 'C:\\tmp\\logging_tellstick_duo.txt'
22:52:07 C:\Program Files\EventGhost\eg\Classes\PluginInfo.py:293: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
22:52:07
22:52:07 Autostart
22:52:07 Plugin: TellStickDuo
22:52:07 Error starting plugin: TellStickDuo
22:52:07 Plugin load error!
22:52:07 Main.OnInit
Hehe.. samma här... jag har flashat om BetaGizmon.
//M
22:52:07 Error while loading plugin-file TellStickDuo.
22:52:07 Traceback (most recent call last) (1462):
22:52:07 File "C:\Program Files\EventGhost\eg\Classes\PluginInfo.py", line 126, in ImportPlugin
22:52:07 File "C:\Program Files\EventGhost\plugins\TellStickDuo\__init__.py", line 35, in <module>
22:52:07 File "logging\__init__.pyc", line 1394, in basicConfig
22:52:07 File "logging\__init__.pyc", line 819, in __init__
22:52:07 File "logging\__init__.pyc", line 838, in _open
22:52:07 IOError: [Errno 2] No such file or directory: 'C:\\tmp\\logging_tellstick_duo.txt'
22:52:07 C:\Program Files\EventGhost\eg\Classes\PluginInfo.py:293: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
22:52:07
22:52:07 Autostart
22:52:07 Plugin: TellStickDuo
22:52:07 Error starting plugin: TellStickDuo
22:52:07 Plugin load error!
22:52:07 Main.OnInit
Hehe.. samma här... jag har flashat om BetaGizmon.
//M
-
- Posts: 27
- Joined: Fri Mar 17, 2023 9:45 am
Re: Callback in C#
okej.. det där var kanske lite för snabbt postat... skapade katalogen och filen c:\tmp\logging_tellstick_duo.txt så gick den igång fint..
men nu får jag:
22:59:23 LoadErrorPlugin.Doorswitch.ON 'selflearning-switch:nexa.2'
22:59:33 LoadErrorPlugin.RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
22:59:43 LoadErrorPlugin.Doorswitch.ON 'selflearning-switch:nexa.2'
22:59:53 LoadErrorPlugin.RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
23:00:03 LoadErrorPlugin.Doorswitch.ON 'selflearning-switch:nexa.2'
23:00:13 LoadErrorPlugin.RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
23:00:23 LoadErrorPlugin.Doorswitch.ON 'selflearning-switch:nexa.2'
23:00:33 LoadErrorPlugin.RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
23:00:43 LoadErrorPlugin.Doorswitch.ON 'selflearning-switch:nexa.2'
när det händer saker istället...
och filen den nyskapade filen har fått följande rader:
INFO:root:2010-09-13 22:59:23: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 22:59:33: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 22:59:43: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 22:59:53: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 23:00:03: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 23:00:13: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 23:00:23: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 23:00:33: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 23:00:43: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 23:00:53: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 23:01:03: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 23:01:13: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 23:01:23: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 23:01:33: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 23:01:43: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 23:01:53: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 23:02:03: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 23:02:13: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
men nu får jag:
22:59:23 LoadErrorPlugin.Doorswitch.ON 'selflearning-switch:nexa.2'
22:59:33 LoadErrorPlugin.RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
22:59:43 LoadErrorPlugin.Doorswitch.ON 'selflearning-switch:nexa.2'
22:59:53 LoadErrorPlugin.RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
23:00:03 LoadErrorPlugin.Doorswitch.ON 'selflearning-switch:nexa.2'
23:00:13 LoadErrorPlugin.RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
23:00:23 LoadErrorPlugin.Doorswitch.ON 'selflearning-switch:nexa.2'
23:00:33 LoadErrorPlugin.RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
23:00:43 LoadErrorPlugin.Doorswitch.ON 'selflearning-switch:nexa.2'
när det händer saker istället...
och filen den nyskapade filen har fått följande rader:
INFO:root:2010-09-13 22:59:23: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 22:59:33: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 22:59:43: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 22:59:53: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 23:00:03: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 23:00:13: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 23:00:23: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 23:00:33: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 23:00:43: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 23:00:53: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 23:01:03: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 23:01:13: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 23:01:23: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 23:01:33: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 23:01:43: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 23:01:53: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
INFO:root:2010-09-13 23:02:03: Doorswitch.ON.selflearning-switch:nexa.2
INFO:root:2010-09-13 23:02:13: RawEvent: protocol:arctech;type:selflearning;house:875804;group:0;method:turnon;unit:10;
Re: Callback in C#
Haha, lirar gut efter att jag skapat filen. Tackar mycket!!