How does the self-learning system work?

Moderator: Telldus

Post Reply
svearike
Posts: 12
Joined: Fri Mar 17, 2023 9:45 am

How does the self-learning system work?

Post by svearike »

Hi,
I just bought the Tellstick Duo + a kit with three receivers and a remote controll, to start with, more is coming ;)
Now I'm developing my own little program for controlling it all, using c.

I'm a bit confused as to how the self-learning system actually works.
It seems that I've learned against both the duo and the remote control, but the codes does not seem match between the two systems.
I dont quite know how that could be?
Are the receivers capable of memorizing several transmitter codes?

I came to this conclusion after trying to fetch the device events using tdRegisterDeviceEvent, nothing happened when I pressed the remote control (as I would have expected).
So I called tdRegisterRawDeviceEvent and printed out what it got called with:

raw_device_event: class:command;protocol:arctech;model:selflearning;house:7462818;unit:1;group:0;method:turnoff;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:sartano;model:codeswitch;code:1111111011;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:everflourish;model:selflearning;house:7674;unit:1;method:turnoff;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:arctech;model:selflearning;house:7462818;unit:1;group:0;method:turnoff;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:sartano;model:codeswitch;code:1111111011;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:everflourish;model:selflearning;house:7674;unit:1;method:turnoff;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:arctech;model:selflearning;house:7462818;unit:1;group:0;method:turnoff;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:sartano;model:codeswitch;code:1111111011;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:everflourish;model:selflearning;house:7674;unit:1;method:turnoff;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:arctech;model:selflearning;house:7462818;unit:1;group:0;method:turnoff;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:sartano;model:codeswitch;code:1111111011;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:everflourish;model:selflearning;house:7674;unit:1;method:turnoff;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:arctech;model:selflearning;house:7462818;unit:1;group:0;method:turnoff;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:sartano;model:codeswitch;code:1111111011;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:everflourish;model:selflearning;house:7674;unit:1;method:turnoff;, -1, 2, 0x9d2250



raw_device_event: class:command;protocol:arctech;model:selflearning;house:7462818;unit:1;group:0;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:sartano;model:codeswitch;code:1111011011;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:everflourish;model:selflearning;house:7674;unit:1;method:turnoff;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:arctech;model:selflearning;house:7462818;unit:1;group:0;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:sartano;model:codeswitch;code:1111011011;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:everflourish;model:selflearning;house:7674;unit:1;method:turnoff;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:arctech;model:selflearning;house:7462818;unit:1;group:0;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:sartano;model:codeswitch;code:1111011011;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:everflourish;model:selflearning;house:7674;unit:1;method:turnoff;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:arctech;model:selflearning;house:7462818;unit:1;group:0;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:sartano;model:codeswitch;code:1111011011;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:everflourish;model:selflearning;house:7674;unit:1;method:turnoff;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:arctech;model:selflearning;house:7462818;unit:1;group:0;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:sartano;model:codeswitch;code:1111011011;method:turnon;, -1, 2, 0x9d2250
raw_device_event: class:command;protocol:everflourish;model:selflearning;house:7674;unit:1;method:turnoff;, -1, 2, 0x9d2250


First of all it seems the remote is implementing every protocol out there? :)
And this is my tellstick.conf

user = "nobody"
group = "plugdev"
ignoreControllerConfirmation = "false"
device {
id = 1
name = "Example device"
protocol = "arctech"
model = "codeswitch"
parameters {
house = "A"
unit = "1"
}
}

device {
id = 2
name = "Sovrummets Fonsterlampa"
protocol = "arctech"
model = "selflearning-switch"
parameters {
house = "123123"
unit = "1"
}
}

device {
id = 3
name = "Traningsrumslampan"
protocol = "arctech"
model = "selflearning-switch"
parameters {
house = "324323"
unit = "1"
}
}

device {
id = 4
name = "Hallampan - Rod liten rackare"
protocol = "arctech"
model = "selflearning-switch"
parameters {
house = "38223"
unit = "1"
}
}


And as you can see, the house-id is not quite the same as the remote sends out.
But I can turnon/off the lights using both the remote and the duo (with the tellstick.conf)

If I wanted them to work together, would it be more wise of me to perhaps sniff out the house/unit from the remote
and copy the values into my tellstick.conf?
And how many transmitters can use the same receiver with differing ids?

I might have misunderstood everything completely, in that case please tell me so ;)
svearike
Posts: 12
Joined: Fri Mar 17, 2023 9:45 am

Re: How does the self-learning system work?

Post by svearike »

I also noted now that 1 out of 5 runs of the program does not successfully get the events.
Neither the device events nor the raw events.
Is there any known bug to these functions or am I doing something wrong?

I get id 1 and id 2 from the respective tdRegister.... functions
even those times it doesn't respond any events.
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: How does the self-learning system work?

Post by micke.prag »

svearike wrote:Are the receivers capable of memorizing several transmitter codes?
Yes
svearike wrote:If I wanted them to work together, would it be more wise of me to perhaps sniff out the house/unit from the remote
and copy the values into my tellstick.conf?
Yes
svearike wrote:And how many transmitters can use the same receiver with differing ids?
Depends on the receivers. Most have 3 to 6 memories. Some only have one.
Micke Prag
Software
Telldus Technologies
svearike
Posts: 12
Joined: Fri Mar 17, 2023 9:45 am

Re: How does the self-learning system work?

Post by svearike »

Thank you very much for your answers :)

I still have a problem though, and it's with not all events being registered.
I can see on the telldus duo that it's blinking and thus receving the signal.
I let the program run a while longer now and it seems that at some random periods it completely ignores the signals coming in,
it can however kick back in again after awhile.

# dmesg
usb 6-1: usbfs: process 14969 (telldusd) did not claim interface 0 before use
usb 6-1: usbfs: process 14738 (telldusd) did not claim interface 0 before use
usb 6-1: usbfs: process 14738 (telldusd) did not claim interface 0 before use
usb 6-1: usbfs: process 14738 (telldusd) did not claim interface 0 before use

Not sure if that might be related?

The code that I'm using is this:

#include <stdio.h>
#include <signal.h>
#include <telldus-core.h>

int device_event_id = -1;
int raw_event_id = -1;
int quit = 0;

void device_event(int device_id, int method, const char *data, int callbackId, void *context)
{
printf("device_event: %d, %d, %s, %d, %p\n", device_id, method, data, callbackId, context);
}

void raw_device_event(const char *data, int controllerId, int callbackId, void *context)
{
printf("raw_device_event: %s, %d, %d, %p\n", data, controllerId, callbackId, context);
}

void sigint_handler(int signum)
{
printf("Caught interrupt, shutting down\n");
quit = 1;
}

int main(int argc, char **argv)
{
struct sigaction sigint = {.sa_handler = &sigint_handler};
sigaction(SIGINT, &sigint, NULL);

device_event_id = tdRegisterDeviceEvent(&device_event, NULL);
raw_event_id = tdRegisterRawDeviceEvent(&raw_device_event, NULL);
printf("%d, %d\n", device_event_id, raw_event_id);

while(!quit)
{
sleep(1);
printf("sleeping\n");
}
shutdown:
if (device_event_id != -1)
tdUnregisterCallback(device_event_id);

if (raw_event_id != -1)
tdUnregisterCallback(raw_event_id);

return 0;
}
svearike
Posts: 12
Joined: Fri Mar 17, 2023 9:45 am

Re: How does the self-learning system work?

Post by svearike »

Ok, excuse my stupidity.

I obviously forgot the tdClose() and tdInit();
I had it in my first code, but the copy'n'paste devil got to me ;)

I'm a bit surprised it worked 1/5 without tdInit() ;)

Thanks for the help
svearike
Posts: 12
Joined: Fri Mar 17, 2023 9:45 am

Re: How does the self-learning system work?

Post by svearike »

I feel like I'm ranting here....

But I thought it got fixed with the addition of tdInit() / tdClose();
After about 5 minutes of fiddling around with the remote control it
stopped receving events all of a sudden.

And it won't come back again either, is there any easy way for me to debug this?

(my program is stuck at simply writing out "sleeping")
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: How does the self-learning system work?

Post by micke.prag »

Is TelldusCenter still receiving the signals even though your application doesn't get them?
Micke Prag
Software
Telldus Technologies
Post Reply