Callback in C#

Moderator: Telldus

micke.prag
Site Admin
Posts: 2242
Joined: Thu Jan 18, 2018 11:08 am
Location: Lund
Contact:

Post by micke.prag » Thu Jan 18, 2018 11:08 am

The scan-function is supposed to work. Only Arctech Selflearning though!
Micke Prag
Software
Telldus Technologies

krambriw
Posts: 654
Joined: Thu Jan 18, 2018 11:08 am

Post by krambriw » Thu Jan 18, 2018 11:08 am

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

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)
Defining the callback functions

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))
Terminating...(tdUnregisterCallback not yet implemented in TelldusCore.dll)

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 )


zyberzero
Posts: 56
Joined: Thu Jan 18, 2018 11:08 am
Location: Göteborg

Re: Callback in C#

Post by zyberzero » Thu Jan 18, 2018 11:08 am

Krambriw, would you like to share an more concrete example of your Python-code? If so, I would really appreciate it.
Thanks!
Zyber

krambriw
Posts: 654
Joined: Thu Jan 18, 2018 11:08 am

Re: Callback in C#

Post by krambriw » Thu Jan 18, 2018 11:08 am

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

Code: Select all

#        winsound.Beep(1000, 200)                
Save and restart eg

Best regards, Walter

zyberzero
Posts: 56
Joined: Thu Jan 18, 2018 11:08 am
Location: Göteborg

Re: Callback in C#

Post by zyberzero » Thu Jan 18, 2018 11:08 am

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

krambriw
Posts: 654
Joined: Thu Jan 18, 2018 11:08 am

Re: Callback in C#

Post by krambriw » Thu Jan 18, 2018 11:08 am

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

micke.prag
Site Admin
Posts: 2242
Joined: Thu Jan 18, 2018 11:08 am
Location: Lund
Contact:

Re: Callback in C#

Post by micke.prag » Thu Jan 18, 2018 11:08 am

The Linux software does not support TellStick Duo.

Please read the documentation that has been sent by email to all of you.
Micke Prag
Software
Telldus Technologies

krambriw
Posts: 654
Joined: Thu Jan 18, 2018 11:08 am

Re: Callback in C#

Post by krambriw » Thu Jan 18, 2018 11:08 am

oops, that's right Micke, remember now, too hot :banghead:

zyberzero
Posts: 56
Joined: Thu Jan 18, 2018 11:08 am
Location: Göteborg

Re: Callback in C#

Post by zyberzero » Thu Jan 18, 2018 11:08 am

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?

supermangesthlm
Posts: 27
Joined: Thu Jan 18, 2018 11:08 am

Re: Callback in C#

Post by supermangesthlm » Thu Jan 18, 2018 11:08 am

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
This seems to have gone offline... any chane of onlineing it?

/br SMS

krambriw
Posts: 654
Joined: Thu Jan 18, 2018 11:08 am

Re: Callback in C#

Post by krambriw » Thu Jan 18, 2018 11:08 am

Now it is back on-line again ;)

Halle
Posts: 33
Joined: Thu Jan 18, 2018 11:08 am
Location: VETLANDA
Contact:

Re: Callback in C#

Post by Halle » Thu Jan 18, 2018 11:08 am

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!

supermangesthlm
Posts: 27
Joined: Thu Jan 18, 2018 11:08 am

Re: Callback in C#

Post by supermangesthlm » Thu Jan 18, 2018 11:08 am

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

supermangesthlm
Posts: 27
Joined: Thu Jan 18, 2018 11:08 am

Re: Callback in C#

Post by supermangesthlm » Thu Jan 18, 2018 11:08 am

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;

Halle
Posts: 33
Joined: Thu Jan 18, 2018 11:08 am
Location: VETLANDA
Contact:

Re: Callback in C#

Post by Halle » Thu Jan 18, 2018 11:08 am

Haha, lirar gut efter att jag skapat filen. :D Tackar mycket!!

Post Reply