Page 11 of 28

Re: TellStick Duo

Posted: Fri Feb 14, 2014 3:48 pm
by krambriw
You may try this version.
(obsolete, see below for updated version)

It has a new action that can dim devices up or down with step sizes in percentage

When trigger the macro, I noticed that it is not working well if you use a rf remote that the Duo also reacts to. I works better if you add a 0.5 second wait between the triggering event and the action.

I also tried using an IR remote with a USB-UIRT to trigger the macros and then it worked just fine without any need for delays
Image6.jpg

Re: TellStick Duo

Posted: Fri Feb 14, 2014 9:56 pm
by Fumes
Thats exactly what im looking for! And maby persistent variables so that eventghost remembers the values in case of a restart. Thank you for taking your time, undetstanding what im geting at.

Regards /Bjarne

I will test this as soon as possible, probably Sunday

Re: TellStick Duo

Posted: Sat Feb 15, 2014 8:26 am
by Fumes
I did a fast check now this morning. It doesn't work at all for me. I only have the TellStick dongle and not the DUO at hand. Is it required?
(I deleted all .pyc files on installtion)

LOG:

---> Welcome to EventGhost <---
Autostart
Plugin: TellStickDuo
Loading library
Initiating TellStick Duo...
Starting TellStick Duo...
Main.OnInit
TellStickDuo: Dim up/down with a defined step size: MP
Error in Action: "TellStickDuo: Dim up/down with a defined step size: MP"
Traceback (most recent call last) (1640):
File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
return self(*args)
File "C:\Program Files (x86)\EventGhost\plugins\TellStickDuo\__init__.py", line 2227, in __call__
self.DimPercentage()
File "C:\Program Files (x86)\EventGhost\plugins\TellStickDuo\__init__.py", line 2241, in DimPercentage
the_level = int(ret)
ValueError: invalid literal for int() with base 10: '\x88\xf6j\x04\xf8\x86o\x04'

/Bjarne

Re: TellStick Duo

Posted: Sat Feb 15, 2014 8:40 am
by Fumes
After some more testing it seems to fail when the value gets to 0% or 100%.
Setting a dim value to 75% with the action "DIM" first and then use the new action to step down works. Until it reaches 0% then it stops working and you can't get it to work until set it manually to a value above 0%.
Same also aplies upwards, reaching 100% kills the function.

Best regards / Bjarne

Re: TellStick Duo

Posted: Sat Feb 15, 2014 11:48 am
by krambriw
I have made a modified version
__init__.py
(81.75 KiB) Downloaded 145 times
The code is changed so now it first checks with the Telldus api for the current level value. If the api response is '' (empty) which can happen (this is the reason for your error message above), the code instead used the stored persistence value.

When the command is sent, the level value is also saved to be used when the next command is sent. I have tried stepping up and down, reaching both 100% and 0% and it works perfect to change direction all the time. Obviously the lower and upper limits are 0% and 100% and trying to step further will obviously not work, the level will stay on 0% or 100% until the direction is changed.

The implementation also works if you for instance change the dim level with Telldus Center 'in between'. When you make the next percentage step, it will be added to the actual level.

You do not need a Duo for this, a Classic is enough

Please try and see if it works better for you as well

Re: TellStick Duo

Posted: Sat Feb 15, 2014 1:29 pm
by Fumes
Now it's working down to 0. But still, if you press down one more time it crashes.

---> Welcome to EventGhost <---
Autostart
Plugin: TellStickDuo
Loading library
Initiating TellStick Duo...
Starting TellStick Duo...
Main.OnInit
TellStickDuo: Dim: MP
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.50"
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.40"
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.30"
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.20"
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.11"
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.1"
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo.MP.OFF u"selflearning-dimmer:nexa.2.0"
TellStickDuo: Dim up/down with a defined step size: MP
Error in Action: "TellStickDuo: Dim up/down with a defined step size: MP"
Traceback (most recent call last) (1640):
File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
return self(*args)
File "C:\Program Files (x86)\EventGhost\plugins\TellStickDuo\__init__.py", line 2230, in __call__
self.DimPercentage()
File "C:\Program Files (x86)\EventGhost\plugins\TellStickDuo\__init__.py", line 2252, in DimPercentage
the_level = int(ret)
ValueError: invalid literal for int() with base 10: '\xc8Bl\x04\xc0Ic\x04http://www.w3.org/XML/1998/namespace'


/Bjarne

Re: TellStick Duo

Posted: Sat Feb 15, 2014 2:17 pm
by krambriw
'\xc8Bl\x04\xc0Ic\x04http://www.w3.org/XML/1998/namespace'
Where is this coming from?

This is the response from the Telldus api and it is of course looking completely wrong. What version of Telldus Center are you using?

If not already, use the latest beta version and see if it works better


I will also try with a Classic Tellstick to see what happens. Otherwise, if nothing else, I have to add some additional exception handling for 'unexpected' responses like the above.

BR

EDIT: My Tellstick Classic is too old,,,,is not supporting selflearning devices..

Re: TellStick Duo

Posted: Sat Feb 15, 2014 2:21 pm
by krambriw

Re: TellStick Duo

Posted: Sat Feb 15, 2014 4:11 pm
by Fumes
Ah... I intentionally revertred to an old version of the TelldusCenter because i had a lot of problems after standby/hibernation. I have since given up the idea of having this pc go to sleep, so it should be no problem to use the new beta. It works better now on one device. I have 5 devices learned in TelldusCenter, MP, MP2, MP3, MP4, MP5. When i use the "MP"-device it works like a charm, any other (MP2, MP3, and so on) creates errors in the manner below:

---> Welcome to EventGhost <---
Autostart
Plugin: TellStickDuo
Loading library
Initiating TellStick Duo...
Starting TellStick Duo...
Main.OnInit
TellStickDuo: Dim: MP
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.50"
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.60"
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.69"
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.79"
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.89"
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.100"
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.100"
TellStickDuo: Dim up/down with a defined step size: MP
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.100"
TellStickDuo.MP.DIM u"selflearning-dimmer:nexa.2.100"
TellStickDuo: Dim up/down with a defined step size: MP2
Error in Action: "TellStickDuo: Dim up/down with a defined step size: MP2"
Traceback (most recent call last) (1640):
File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
return self(*args)
File "C:\Program Files (x86)\EventGhost\plugins\TellStickDuo\__init__.py", line 2230, in __call__
self.DimPercentage()
File "C:\Program Files (x86)\EventGhost\plugins\TellStickDuo\__init__.py", line 2252, in DimPercentage
the_level = int(ret)
ValueError: invalid literal for int() with base 10: '\xc3\x84\xc2\x9d\xe6\xba\xa8\xc2\x9dech'

I don't want to put up alot of trouble for you, this is just a feature and if it is stealing time from some other project you are working on, just leave this be.
/Regards Bjarne

Re: TellStick Duo

Posted: Sat Feb 15, 2014 4:21 pm
by Fumes
I've solved it. Renaming the devices in the TelldusCenter seemed to do the trick!
Thank you for everything!

Re: TellStick Duo

Posted: Sat Feb 15, 2014 4:41 pm
by krambriw
No problems, I think it is a nice feature

Please try this version, I think (and hope) it will work now, I have added a check that the data received from Telldus api is likely to be correct. If not valid, I use instead the stored value

Obsolete, see below for the updated version

Re: TellStick Duo

Posted: Sat Feb 15, 2014 5:05 pm
by Fumes
Works like a charm. Thank you one more time.
I have one thing more to consider.
Lets say you have 4 devices.
#1 is at 30%
#2 is at 40%
#3 is at 20%
#4 is at 5%

We could then have a all up or down relative to current value. Say 10% down on all would obviously give

#1 20%
#2 30%
#3 10%
#4 -5% (Wich should of course be 0% in reality)

The nice thing is that when you then dim up with that event, the negative number vould be +5% again and not 10% as it would be otherwise.
I cant really explain my self better. My native language is obviously not English...
I'm trying to say that even if you lower all lights to very low values some devices could go to a negative value, and when dimmed up again the would not light up untill they reached a positve value...
I hope you can see the possibilites here.

Regards /Bjarne

Re: TellStick Duo

Posted: Sat Feb 15, 2014 7:16 pm
by krambriw
OK, I got the point I think

a) We should save the actual value even if it gets below 0% or above 100%
b) We should always use the saved value (and not what Telldus api reports) to calculate the new actual value
c) We would however only send values between 0% and 100% to Telldus api (otherwise you get an error message)

I see the following issues to think about:

1) When should we stop saving values?
I mean if you continue to dim down or up and you reach either below 0% or above 100%, we should only save until we are outside boundaries first time??? Or shall we continue for ever as long as you press the buttons up or down? My suggestion is that we only save until we hit outside boundaries first time,

2) What if you dim down or up so that the saved value is outside boundaries and then change the step size?
When you then continue dimming up or down, it may take some more key presses than before until something is happen, especially if you now have a smaller step size configured. My suggestion is we have to accept this.

BestR

Re: TellStick Duo

Posted: Sat Feb 15, 2014 8:47 pm
by Fumes
You got it perfectly right, your statements a,b,c matches the original thought!

About the issues,

1) Your suggestion is ok! But i have another thought. Maybe hard to implement but here goes:
If we only allow the devices to have a offset between eachother by max 100%?
The last device inside boundaries is king.
The only action that should be able to move the device outside of boundaries are the "all up/down" action, if say we execute action "light1 - down" when it already is out of boundaries, nothing happens.
Worst case scenario would be -100% and +200%, right?

Or we could set a given device as "king"? And the others as slaves and a max offset by a defined or fixed value?

2) Definitely accept it, I for one does'nt change step size once settled for a smart value for my devices.

Another thing that comes to mind is that it could take a serious amount of time to send all those values. If someone has 10 devices it should take about 3 seconds to do one step?

/Bjarne

Re: TellStick Duo

Posted: Sun Feb 16, 2014 3:51 pm
by krambriw
a,b,c is implemented with some additional design considerations

- I went back to setting the step size in units (0-255) instead of percentage (0-100%), it was very hard to verify otherwise since what we send as dim level to the device is actually units (once we know it is working as expected, I can revert back to percentage if that feels better.

- when checking the dim level previously set, I use the response from the api only if the level is between 0 and 255, otherwise I use the reference level saved by the plugin.

I have also temporarily added some print statements. Later we will comment them out but for now it helps in verification.

When you run an action to dim up (with step size 10), it looks similar to this (I am triggering the macros with an IR remote)

Code: Select all

16:33:37   USB_UIRT.SIRC12.00F4
16:33:37   TellStickDuo: Dim up/down with a defined step size: Garage
16:33:37   5 Previously saved dim level
16:33:37   5 API reported dim level
16:33:37   15 Sent dim level to device
16:33:37   15 New reference level
16:33:38   Main./eventghost/zwave 'Device_3_Instance_3_temperature, 15.75'
16:33:43   USB_UIRT.SIRC12.00F4
16:33:43   TellStickDuo: Dim up/down with a defined step size: Garage
16:33:43   15 Previously saved dim level
16:33:43   15 API reported dim level
16:33:43   25 Sent dim level to device
16:33:43   25 New reference level
When running down (with step size 5)

Code: Select all

16:34:15   USB_UIRT.SIRC12.00F5
16:34:15   TellStickDuo: Dim up/down with a defined step size: Garage
16:34:15   25 Previously saved dim level
16:34:15   25 API reported dim level
16:34:15   20 Sent dim level to device
16:34:15   20 New reference level
16:34:17   USB_UIRT.SIRC12.00F5
16:34:17   TellStickDuo: Dim up/down with a defined step size: Garage
16:34:17   20 Previously saved dim level
16:34:17   20 API reported dim level
16:34:17   15 Sent dim level to device
16:34:17   15 New reference level
Regarding your idea with groups, you are correct, that will be harder since I currently do not handle such collections at all, the plugin is designed for handling devices individually. However, there is nothing that prevents you from adding several actions (with different settings) into one single macro. To make what you wish, it might eventually be possible with a python script for the logic. What I have added is the possibility to receive a dictionary with your controlled device id's and the current reference dim level. If you run a simple python script like this

Code: Select all

print eg.plugins.TellStickDuo.DimPercentage(u'Garage', True, 0)
the dictionary will be printed in the log similar to this

Code: Select all

16:43:57   {'96': '15'}
where '96' in this case is the Telldus device id and '15' the current reference dim level.

If you use the returned dictionary with the data in a script, you could evaluate and decide what you want to do depending on the highest / lowest dim level you find.

Please try the new version and check if it is working ok as you think
(obsolete, see below for updated version)

BestR