Philips Hue plugin

Questions and comments specific to a particular plugin should go here.
leejk
Posts: 18
Joined: Sun Dec 04, 2016 4:32 pm

Re: Philips Hue plugin

Post by leejk » Fri Aug 09, 2019 1:40 am

It seems that no matter what action I use now, after selecting which light in the action settings dialog, when I close the dialog and reopen, the previously selected light is no longer selected. I believe this behavior started after upgrading to the newer square bridge. I'm stuck using an older version of this plugin, because the newer version is no longer linked in the first post. Can someone confirm this behavior?

thanks

skribb
Experienced User
Posts: 228
Joined: Thu Feb 12, 2015 7:22 pm
Location: Win7 64bit

Re: Philips Hue plugin

Post by skribb » Fri Aug 09, 2019 3:54 pm

leejk wrote:
Fri Aug 09, 2019 1:40 am
It seems that no matter what action I use now, after selecting which light in the action settings dialog, when I close the dialog and reopen, the previously selected light is no longer selected. I believe this behavior started after upgrading to the newer square bridge. I'm stuck using an older version of this plugin, because the newer version is no longer linked in the first post. Can someone confirm this behavior?

thanks
what's a square bridge? what gen is that?
Automation is life.

Win7 64bit
EG: v0.5.0-rc4

Aquila
Experienced User
Posts: 88
Joined: Wed Jan 28, 2015 2:49 am

Re: Philips Hue plugin

Post by Aquila » Fri Aug 09, 2019 5:35 pm

I have reuploaded the plugin. It's available in the first post. :)

Try the newest version and come back if it still fails. There was a change in the API some versions ago that might cause the error you are experiencing.

User avatar
kgschlosser
Site Admin
Posts: 5119
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Philips Hue plugin

Post by kgschlosser » Fri Aug 09, 2019 7:55 pm

Dude thank you for re uploading the plugin.. I really do appreciate it. If you happen across any other plugins that may be missing and if it is not too much trouble would you mind uploading them?
If you like the work I have been doing then feel free to Image

leejk
Posts: 18
Joined: Sun Dec 04, 2016 4:32 pm

Re: Philips Hue plugin

Post by leejk » Sat Aug 10, 2019 11:40 pm

Yes thank you again for posting the updated version :)

I tried it, but the same behavior exists... opening the settings for the change light actions causes it to default to the same light every time versus the light the action was originally assigned to.

harmonywave
Posts: 6
Joined: Tue Jun 11, 2019 8:55 am

Re: Philips Hue plugin

Post by harmonywave » Tue Oct 29, 2019 7:30 pm

I cannot getthe OK and Apply buttons to activate in the set a scene dialogue box. They were working at one point, but randomly stopped, and now I have deleted the plugin, added it back, cleared out every scene from my bridge, I still cannot get it to activate. I've looked at the plugin code but am not familiar enough with it to override this behavior.

How can I edit this plugin to make OK and Apply always selectable?

User avatar
kgschlosser
Site Admin
Posts: 5119
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Philips Hue plugin

Post by kgschlosser » Wed Oct 30, 2019 7:05 am

you have to edit one of the settings in the config box.
If you like the work I have been doing then feel free to Image

harmonywave
Posts: 6
Joined: Tue Jun 11, 2019 8:55 am

Re: Philips Hue plugin

Post by harmonywave » Wed Oct 30, 2019 11:48 am

Well I knew that much, and the plugin was working for previous Set Scene actions I set, but when this config panel is loaded for a new item, it is not recognizing the new input as having changed and does not allow OK or Apply to become selectable.

I'm not exactly sure why the dialogue is not getting set ConfigPanel.SetIsDirty(), so how can I manually call this function? Could I add a command in the while.panel affirmed section that will manually call this to override the default behavior?

harmonywave
Posts: 6
Joined: Tue Jun 11, 2019 8:55 am

Re: Philips Hue plugin

Post by harmonywave » Wed Oct 30, 2019 1:20 pm

I figured it out, I had to apply the bug fixes from the March Github commits for EventGhost

User avatar
kgschlosser
Site Admin
Posts: 5119
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Philips Hue plugin

Post by kgschlosser » Thu Oct 31, 2019 5:07 am

Now that you mention it.. I did look at the plugin and it does need to be fixed. Every where you see a definition similiar to this

Code: Select all

def OnSomeEvent(event):
    # some code is done here
    event.skip() <------- This is what is missing
these will be in the Configuration methods Typically you will see a line after the function similiar to the following

Code: Select all

some_control.Bind(EVT_SOME_EVENT, OnSomeEvent)
These functions are callback functions used by the GUI interface. If you run the following code using a Python Script action it will make a new window with a single button in it.. when you click the button it will change the label of the button.

Code: Select all

import wx

frame = wx.Frame(None, -1, size=(200, 200)
button = wx.Button(frame, -1, 'CLICK ME!')
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(button, 0, wx.EXPAND | wx.ALL, 10)
frame.SetSizer(sizer)

def OnButtonClick(event):
    if button.GetLabel() ==  'CLICK ME!'
        button.SetLabel('CLICK ME AGAIN!')
    else:
        button.SetLabel('CLICK ME!')
    event.skip()

button.Bind(wx.EVT_BUTTON, OnButtonClick)
frame.Show()
Now in this code it is going to do the exact same thing. But we changed the bind point from the button it's self to the frame that holds the button.

Code: Select all

import wx

frame = wx.Frame(None, -1, size=(200, 200)
button = wx.Button(frame, -1, 'CLICK ME!')
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(button, 0, wx.EXPAND | wx.ALL, 10)
frame.SetSizer(sizer)

def OnButtonClick(event):
    if button.GetLabel() ==  'CLICK ME!'
        button.SetLabel('CLICK ME AGAIN!')
    else:
        button.SetLabel('CLICK ME!')
    event.skip()

frame.Bind(wx.EVT_BUTTON, OnButtonClick)
frame.Show()
It still functions the exact same.

The callbacks are set into a list for the object you bound it to. When an event occurs in a control that event propagates to it's parent an then it's parents parent... and so on and so forth.

Code: Select all

import wx

frame = wx.Frame(None, -1, size=(200, 200)
button = wx.Button(frame, -1, 'CLICK ME!')
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(button, 0, wx.EXPAND | wx.ALL, 10)
frame.SetSizer(sizer)

def OnButtonClickButton(event):
    print 'Button clicked'
    event.Skip()

def OnButtonClickFrame(event):
    if button.GetLabel() ==  'CLICK ME!'
        button.SetLabel('CLICK ME AGAIN!')
    else:
        button.SetLabel('CLICK ME!')
    event.skip()

button.Bind(wx.EVT_BUTTON, OnButtonClickButton)
frame.Bind(wx.EVT_BUTTON, OnButtonClickFrame)
frame.Show()

Now you can stop that propagation by NOT calling event.Skip()

Code: Select all

import wx

frame = wx.Frame(None, -1, size=(200, 200)
button = wx.Button(frame, -1, 'CLICK ME!')
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(button, 0, wx.EXPAND | wx.ALL, 10)
frame.SetSizer(sizer)

def OnButtonClickButton(event):
    print 'Button clicked'

def OnButtonClickFrame(event):
    if button.GetLabel() ==  'CLICK ME!'
        button.SetLabel('CLICK ME AGAIN!')
    else:
        button.SetLabel('CLICK ME!')
    event.skip()

button.Bind(wx.EVT_BUTTON, OnButtonClickButton)
frame.Bind(wx.EVT_BUTTON, OnButtonClickFrame)
frame.Show()
you should see the log entry but not the label change because I removed the call to Skip() from the OnButtonClickButton function.

This is the mechanism that EG uses to know if anything has changed, it registers a callback to a master event that captures all events. It only knows about the dialog and has no way of knowing what has been added. so we can only register at the dialog level. So if a plugin registers for an event at the control and then does not make the call to Skip() the events never propagate down to the dialog level so EG will have not a clue that something has changed.

Now I know the fix you have put into place is working. There was a goof in a code change that I made which would gray out the buttons even if the dialog was created without any controls in it that a user could change.. When this happened if a plugin would get installed that did not have any config settings there was no way to "Ok" it to allow the plugin to install.. This was a mistake on my part. The reason why we made a change like that was because users were going into actions and then simply clicking on OK and expecting them to work.. and more times then not the action would not work So we needed a mechanism that would cause them to have to look around at how to enable the OK button and hopefully they would realize they needed to make some kind of a change. we wanted them to have to read a little so they would know that there possibly could be a setting change that needs to be made.

There is still a fatal flaw in the plugin. If you make a setting change and then click on Apply and then Test you can test out your settings.. Now make an adjustment to those settings after clicking the Apply button. The Apply button should become available again, but it does not. Any further presses of the Test button are going to use the previous settings and not the ones you just made. Because EG is unaware that any changes were made.
If you like the work I have been doing then feel free to Image

harmonywave
Posts: 6
Joined: Tue Jun 11, 2019 8:55 am

Re: Philips Hue plugin

Post by harmonywave » Fri Nov 01, 2019 11:11 am

I played around with your examples and learned a few things. I had to correct a couple things in the code you included, such as another parenthesis at the end of the frame= line, adding a semicolon to the If statement, and Skip needs to have an uppercase S. Took me a little while to figure it out as I'm still familiarizing myself with Python code. I appreciate the well thought out responses and helping me learn.

The particular issue and part of the code I was working on didn't have that particular issue which you made reference too, rather I discovered another minor bug in EventGhost and have created a pull request on GitHub. The ConfigPanel class does not contain the eventhandler for ListBox changes, therefore whenever a Configuration Panel only contains ListBox's, the Apply button never gets activated, so I simply added self.Bind(wx.EVT_LISTBOX, OnEvent) to the ConfigPanel.py file and now it works as intended.

As I use the plugin more, I will watchout for code needing the event.Skip() added.

Thanks again!

User avatar
kgschlosser
Site Admin
Posts: 5119
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Philips Hue plugin

Post by kgschlosser » Sat Nov 02, 2019 4:03 am

I didn't test the code I just hammered it out. my keyboard is having issues again as well. keys not registering or getting stuck.. Things like that..

You did get the point to the tutorial which lead you to locate yet another underlying issue, which you have fixed.. and TY for that. But you can now see why the Skip() is so important to have in place. unless there is a specific need to not let EG know that a change was made it MUST me there.

NOTE: my finger to key orientation is horrid as well. (lots of typos!)
If you like the work I have been doing then feel free to Image

harmonywave
Posts: 6
Joined: Tue Jun 11, 2019 8:55 am

Re: Philips Hue plugin

Post by harmonywave » Wed Nov 20, 2019 6:21 am

Oh I didn't mean to criticize rather it helped me learn python a little better going through your examples, I didn't realize that you wrote them out just for this post. I appreciate the help and thoughtful yet thorough response and explanation you gave.

I also appreciate all the time and work you have put into this program, I only wish it was as popular and active as it once was. I worry about commiting my home automations to program that isn't actively being developed but it helps knowing you're available to help and with it being open source, that bugs can be fixed. Plus its a fun way to learn the python programming language.

leejk
Posts: 18
Joined: Sun Dec 04, 2016 4:32 pm

Re: Philips Hue plugin

Post by leejk » Thu Nov 21, 2019 12:44 am

Are you all also seeing the same behavior I described above: http://eventghost.net/forum/viewtopic.p ... 578#p53578

User avatar
kgschlosser
Site Admin
Posts: 5119
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Philips Hue plugin

Post by kgschlosser » Thu Nov 21, 2019 6:54 am

I am going to look over the plugin ans see what is causing the problem with the controls not defaulting to the last used setting. I will also correct the issue with the skip as well.
If you like the work I have been doing then feel free to Image

Post Reply