Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

TellStick Duo

Questions and comments specific to a particular plugin should go here.
Fumes
Posts: 24
Joined: Wed Feb 12, 2014 3:46 pm

Re: TellStick Duo

Post by Fumes »

I will test this as soon as possible. Probably in the begining of this week. Thank you!
Fumes
Posts: 24
Joined: Wed Feb 12, 2014 3:46 pm

Re: TellStick Duo

Post by Fumes »

I've managed to do a bit of testing and it does what it's supposed to do, as far as i can tell.
I could see a use for a way to syncronize the values of the different devices.
I tried to do that with the DIM action but the plugin ofcourse remembers the stored values when using the new action again, if the device was out of boundaries.

This following text has nothing to do with your development of the plugin, i just want to share what i'm aiming at whith all this.
I want a classic "DIM when watch a movie" experience, except with a litle more functions.
Pressing PLAY would dim the lights to a value stored from the previous time i watched a movie. All single lights would be able to have its own value that it should dim to upon this event.
The lights would however be able to be controlled be a remote control individually and stored for the next movie session.
This memory function should also be available for PAUSE and STOP wich should have its own separate values.
I also wanted a funcion where a could increase/decrease all lights relative to it's previous value, making it easier to to just that, with one keypress.


Best regards /Bjarne
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

Well, are you building a cinema???

Anyway, the functionality you are targeting is possible with EventGhost but it requires something rather different than what we have discussed so far.

What we have now:
- you have an action that is able change the dim level up/down in steps per device

What I have understood that you need
Some components that
- can trigger a number of devices to dim to their individually configured "watch movie" dim level
- via a remote control can configure dim levels individually per device
- provide the same but also for "pause" and "stop" with their specific settings
- can allow you to with a remote fine adjust the all dim levels up/down

According to my opinion, this goes beyond what is really feasibly with a TellStick Duo device and those cheap RF devices. For this solution to be fool proof, I would change to a technology that operates faster, and therefore *virtually operates in parallel* and that provides status feedback like Z-Wave.

The limitations with TellStick and the RF devices are
- TellStick is too slow to create a Classic dim
- TellStick can't operate several devices *in parallel*
- There is no status feedback from the devices so you can't really know the actual dim level, you can only hope that it is correct according to what you just sent out (but if this is changed outside your control, you are lost)
- You can't set a specific dim level with the current available remotes.

With this in mind, I would consider a different approach, trying to make the best out of the stuff you already have.

I have modified the plugin so in this new version we keep track of the current dim level also if we use the normal 'dim', 'on', 'off' and the 'dim gradually' actions. Further more, I have reverted back to the percentage settings again since it seems to work fine now and the same is presented in the Telldus Center as well. To see the actual levels that are being used also printed in the log, you can check the 'logfile' box in the plugin setting.

One limitation is unfortunately that the TellStick cannot dim multiple devices with different addresses at the same time, it has to be done in sequence. Alternatively you can program all devices with the same address, then they will all be dimmed synchronized.

In essence, I would try something like this:

a) Group the 'dim gradually' actions for devices you like to control with one button press into the same macro (add a ''Wait" between each action if you have devices with different addresses, long enough so that the previous action can finish before the next starts). You can imagine the macros as a 'scenarios'

b) Create one macro for each scenario you need, 'Watch Movie', 'Pause', 'Stop', 'End', 'All Off' etc

c) Add actions to each macro (you can copy from one to the other and then change the configuration of the copies)

d) Assign one remote button for each macro (if you use a standard remote, you could use the normal 'play', 'pause', 'stop', 'off' etc buttons)

e) The actual configuration of the dim level for each device in each scenario you have to set in the corresponding action

f) Create an additional fine adjust macro for 'dim up' where you put a 'dim percentage' action for each of the device addresses you use and configure them with the same step size. Assign one remote button for 'dim up'

g) Do the same for 'dim down'. Assign one remote button for 'dim down'
__init__.py
(83.49 KiB) Downloaded 189 times
Below some pictures that shows a simple example of the above.
Last edited by krambriw on Mon Feb 17, 2014 10:36 am, edited 1 time in total.
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

Sample simple configuration of macros, events from remote and actions
Image2.jpg
Sample setting for the fine adjust step up action
Image4.jpg
Sample setting for the dim gradually action to dim to specified dim level
Image5.jpg
Fumes
Posts: 24
Joined: Wed Feb 12, 2014 3:46 pm

Re: TellStick Duo

Post by Fumes »

You are amazing!

In fact i am doing this for my livingroom but it is intended for an eventual future homecinema.

I've got the XBMC mediacenter (sending events to EG) and a pretty well working solution already.
As i am no coder, the solution is ugly with alot of disabling/enabling macros in EG and its only working with the same dim level for all lights (one adress on all dimmers).
The work you have done now will truly simplify my EG tree and most likely allow me to expand the functionality as i want it. I dont have a lot of time since im busy with life in general but i promise i will return here and report on how it finally turned out!

Best regards / Bjarne
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

Sure, take your time, no hurry

BestR
Fumes
Posts: 24
Joined: Wed Feb 12, 2014 3:46 pm

Re: TellStick Duo

Post by Fumes »

I'm trying to use the dictionary to store and later use the values for dim. Like a memory function.
Problem is i dont know how to use the device number that the dictionary uses?
your code for dimming "ALL_LIGHTS" device to 50% looks like this:

Code: Select all

eg.plugins.TellStickDuo.Dim(u'ALL_LIGHTS', 50)
Where in the dictionary "ALL_LIGHTS" in my case would be device 2.
And just substituting "ALL_LIGHTS" with "2" obviously don't work.

Ideas?

/Bjarne
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

It has to be like this:

Code: Select all

eg.plugins.TellStickDuo.DimPercentage(u'ALL_LIGHTS', True, 50)
If you want to see all saved levels (without changing any) you can run the following script:

Code: Select all

print eg.plugins.TellStickDuo.DimPercentage(u'ALL_LIGHTS', True, 0)

dct = eg.plugins.TellStickDuo.DimPercentage(u'ALL_LIGHTS', True, 0)

for i in dct:
    print i, dct[i]

PS You do not need to know device id numbers, only device names
Fumes
Posts: 24
Joined: Wed Feb 12, 2014 3:46 pm

Re: TellStick Duo

Post by Fumes »

Hmm, i know i need the names, its just that i cant retrieve them with the dictionary.
Your code given in the example above gives the exact same result as the one i made up before.
Log looks like this

19:11:24 ---> Welcome to EventGhost <---
19:11:37 Python Script
19:11:37 {'3': 100, '2': 75, '5': 100, '4': 100, '6': 100}
19:11:39 3 100
19:11:39 2 75
19:11:39 5 100
19:11:39 4 100
19:11:39 6 100
19:11:39 TellStickDuo.ALL_LIGHTS.DIM u"selflearning-dimmer:nexa.2.75"
19:11:40 TellStickDuo.ALL_LIGHTS.DIM u"selflearning-dimmer:nexa.2.75"
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

It is possible to create python code to retrieve both name and id's, I will give you an example shortly
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

Here is a python script to start with. It gives some hints how to access device id's, device names and current dim levels

BestR

Code: Select all


def loadLibrary(dll):
    print "Loading library"
    try:
        dll = windll.LoadLibrary("TelldusCore.dll")
    except: 
        raise eg.Exception('Could not load dll')

    dll.tdInit()
    return dll


def closeLibrary(dll):
    try:
        dll.tdClose()
        print "Closing library"
    except:
        pass
    dll = None
    return dll


from ctypes import(
	windll, WINFUNCTYPE, POINTER, string_at,
	wstring_at, c_char_p, c_int, c_ubyte, c_void_p	
)

#Device methods
TELLSTICK_DIM = 16

dll = None
dll = loadLibrary(dll)
deviceList = {}
numdevices = 0

try:
    numDevices = dll.tdGetNumberOfDevices()
except:
    numDevices = 0
for i in range(numDevices):
    id = dll.tdGetDeviceId(i)
    m = dll.tdMethods(
                    id,
                    TELLSTICK_DIM
              )
    if (m):
        gn = dll.tdGetName(id)
        name = (c_char_p(gn)).value
        dll.tdReleaseString(gn)
        deviceList[str(id)] = str(name.decode('utf-8'))
print deviceList     

closeLibrary(dll)

#This is an alternative way to access the dictionary with id's and the current dim levels
dct = eg.plugins.TellStickDuo.plugin.dimPercentage
print dct

#Here is how to combine the two, using the id to match the name with the level
nameLevels = {}
for i in dct:
    print i, dct[i], deviceList[i]
    nameLevels[deviceList[i]] = dct[i]
print nameLevels

#To extract only the keys
print nameLevels.keys()


krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

Another possibility, maybe better and simpler, is that I already in the plugin generate a dictionary keeping all needed data in one single place.

I have made a dictionary looking like this

Code: Select all

dimData = { deviceId:device name|currentDimLevel, etc }
A python script to access the data as example:

Code: Select all

dimData = eg.plugins.TellStickDuo.plugin.dimDeviceData
print dimData

for i in dimData:
    print dimData[i]    #the dim level and the device name
    d = dimData[i].split('|')
    level = d[0]
    name = d[1]
    print 'dim level: ', level
    print 'device name: ', name
    print 'device id: ', i
 
With my devices the result looks like this:

Code: Select all

12:54:52   {'106': '13|Front row', '107': '13|Back row'}
12:54:52   13|Front row
12:54:52   dim level:  13
12:54:52   device name:  Front row
12:54:52   device id:  106
12:54:52   13|Back row
12:54:52   dim level:  13
12:54:52   device name:  Back row
12:54:52   device id:  107
The data will be filled as soon as you start dimming the devices and then continuously updated and saved persistent.

Attached below is an updated version with this feature

BestR
__init__.py
(84.87 KiB) Downloaded 189 times
Fumes
Posts: 24
Joined: Wed Feb 12, 2014 3:46 pm

Re: TellStick Duo

Post by Fumes »

That looks good!
Can we have the dim levels in percent in some easy way?

Regards
/Bjarne
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

Yes, see below, very easy

Code: Select all

dimData = eg.plugins.TellStickDuo.plugin.dimDeviceData
print dimData

for i in dimData:
    print dimData[i]    #the dim level and the device name
    d = dimData[i].split('|')
    level = d[0]
    name = d[1]
    print 'dim level: ', level
    print 'dim level %: ', int(level)*100/255
    print 'device name: ', name
    print 'device id: ', i
 
Fumes
Posts: 24
Joined: Wed Feb 12, 2014 3:46 pm

Re: TellStick Duo

Post by Fumes »

Thank you for all the support, and sorry for a late reply. As far as the plugin goes, everything works like a charm. Now it really is down to my python skills wich are next to non existing. I've struggled a bit with the handling of dictionaries. Took a while to understand that i had to do a copy to store the dim levels. You guys must laugh or get tired of the newbie questions, but at least for me, it is this kind of devotion that inspires me to learn more. Well done!

Best regards
Post Reply