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.

Help with Tellstick Plugin Python Command

If you have a question or need help, this is the place to be.
Post Reply
woggy
Posts: 40
Joined: Sun May 02, 2010 2:06 pm

Help with Tellstick Plugin Python Command

Post by woggy »

I have I server with an Tellstick witch receives this event for an example:
Broadcast.DesktopRemote.Arbetsrum Taklampa '12'

the payload is 12, then I run my Python Command:

Code: Select all

eg.plugins.TellStick.Dim(11, eg.event.payload)
The result is bad, maybe 50/50


If I do it like this, and change the number manually it works 100% of the time

Code: Select all

num  = 12
eg.plugins.TellStick.Dim(11, num)
Any ideas? Here is the script that sends the event if it has anything to do with it:

Code: Select all

num = input("Dimm to: ")
num = num * 255
num = num / 100
eg.globals.num = num
eg.plugins.BroadcastListener.Broadcast(u'{eg.event.string}', u'{eg.globals.num}')
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Help with Tellstick Plugin Python Command

Post by Pako »

Try this:

Code: Select all

eg.plugins.TellStick.Dim(11, int(eg.event.payload))
Pako
woggy
Posts: 40
Joined: Sun May 02, 2010 2:06 pm

Re: Help with Tellstick Plugin Python Command

Post by woggy »

Tnx a lot, it worked :D
woggy
Posts: 40
Joined: Sun May 02, 2010 2:06 pm

Re: Help with Tellstick Plugin Python Command

Post by woggy »

I need to abort this script if there is no input for 10 seconds. I have tried a lot of different things but I'm no programmer =)

Code: Select all

eg.plugins.Window.SetAlwaysOnTop(0)
def dec():
    
    while True:
        try:
            num = int(raw_input('enter number between 0 and 100:  '))
            if num > 100:
                print ("Only positive numbers between 0 and 100 please!")
            elif num < 1:
                print ("Only positive numbers between 0 and 100 please!")
            else:
                num = num * 255
                num = num / 100
                eg.globals.num = num
                return num

        except ValueError:
            print 'Numer only'       
dec()
#print "New value is ", eg.globals.num
eg.plugins.Window.SetAlwaysOnTop(1)
eg.plugins.BroadcastListener.Broadcast(u'{eg.event.string}', u'{eg.globals.num}')
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Help with Tellstick Plugin Python Command

Post by Pako »

woggy wrote:I need to abort this script if there is no input for 10 seconds. I have tried a lot of different things but I'm no programmer =)
After some time I thought of your problem.
You can try this script:

Code: Select all

from threading import Timer
from time import sleep
from winsound import PlaySound, SND_ASYNC

class MyTimer():
    def __init__(self, t, dialog):
        self.timer = Timer(t, self.Run)
        self.dialog = dialog
        self.timer.start()

    def Run(self):
        try:
            edit = self.dialog.GetSizer().GetChildren()[2].GetWindow()
            edit.SetValue("Too late !!!")
            edit.SetSelection(-1,-1)
            PlaySound('SystemExclamation', SND_ASYNC)
            sleep(3)
            PlaySound('SystemExclamation', SND_ASYNC)
            self.dialog.Show(False)
            self.dialog.MakeModal(False)
            self.dialog.Destroy()
        except:
            pass

    def Cancel(self):
        self.timer.cancel()
        

class myDialog(wx.Dialog):
    def __init__(self):
        wx.Dialog.__init__(
            self,
            None,
            -1,
            "Self-timeout-aborted dialog",
            style=wx.CAPTION | wx. STAY_ON_TOP
        )
        label = wx.StaticText(self,-1,"Enter number between 1 and 100:")
        edit = wx.TextCtrl(self,-1,"")
        message = "Only positive numbers between 1 and 100 please!"
        w = edit.GetTextExtent(message)
        edit.SetMinSize((10+w[0],-1))
        buttons = self.CreateSeparatedButtonSizer(wx.OK|wx.CANCEL)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(label,0,wx.TOP|wx.LEFT|wx.RIGHT, 15)
        sizer.Add((1,3))
        sizer.Add(edit,0,wx.EXPAND|wx.LEFT|wx.BOTTOM|wx.RIGHT, 15)
        sizer.Add(buttons, 0, wx.EXPAND|wx.ALL, 5)        
        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)
        self.MakeModal(True)
        self.Show(True)
        edit.SetFocus()
        timer=MyTimer(t = 10.0, dialog = self)
        
        def onButton(evt):
            timer.Cancel()
            if evt.GetId() == wx.ID_OK:
                try:
                    value = int(edit.GetValue())
                    if value >= 1 and value <= 100:
                        value = value * 255
                        value = value / 100
                        eg.plugins.BroadcastListener.Broadcast(u'{eg.event.string}', str(value), 3456)
                        self.Show(False)
                        self.MakeModal(False)
                        self.Destroy()
                    else:
                        edit.SetValue(message)
                        edit.SetFocus()
                        edit.SetSelection(-1,-1)
                except ValueError:   
                    edit.SetValue(message)
                    edit.SetFocus()
                    edit.SetSelection(-1,-1)
            else:
                self.Show(False)
                self.MakeModal(False)
                self.Destroy()
        self.Bind(wx.EVT_BUTTON, onButton)


wx.CallAfter(myDialog)
You may need to adjust this row:

Code: Select all

eg.plugins.BroadcastListener.Broadcast(u'{eg.event.string}', str(value), 3456)
Pako
hanspettersson
Posts: 42
Joined: Sat Feb 20, 2010 2:42 pm

Re: Help with Tellstick Plugin Python Command

Post by hanspettersson »

I borrow this thread a lite.

I got a slider in my webbpage on the webbserver, and whant to control my dimmer whit.
I got this event when i change the slider : "HTTP.lightsSlider.0" the 0 is the value of the slider
Can someone help me with this?

Can i use this Phyton command some way? eg.plugins.TellStick.Dim(10, 50)
And how to get this script run when the value is change?
Post Reply