@ -5,7 +5,7 @@ from typing import Union
import wx
import wx . lib . scrolledpanel as scrolled
from tinge import Tinge , HueBridge , HueGroup , HueLight , HueUtils
from tinge import Tinge , HueBridge , HueGroup , HueLight , HueUtils , is_bridge
class Hui ( wx . Frame ) :
@ -108,6 +108,29 @@ class Hui(wx.Frame):
lambda event , mgroupid = groupid : self . goto_group ( mgroupid ) , group_btn )
self . sizer . Add ( inner_sizer , 0 , wx . EXPAND )
def add_manual_discovery_dialog ( self ) - > bool :
self . sizer . Clear ( delete_windows = True )
found_any : bool = False
text_entry : wx . TextEntryDialog = wx . TextEntryDialog ( self . pnl , " Manually enter IP address of bridge: " ,
caption = " Auto discovery failure " )
warn_label : wx . StaticText = wx . StaticText ( self . pnl , label = " Waiting for Button Press on Bridge " )
if text_entry . ShowModal ( ) == wx . ID_OK :
ipaddress : str = text_entry . GetValue ( )
if is_bridge ( ipaddress ) :
self . sizer . Add ( warn_label , 0 , wx . ALIGN_CENTER )
self . sizer . Layout ( )
user_or_error = HueUtils . connect ( ipaddress )
while user_or_error . is_error ( ) :
user_or_error = HueUtils . connect ( ipaddress )
self . m_tinge . append_bridge ( HueBridge ( ipaddress , user_or_error . get_user ( ) , ipaddress ) )
found_any = True
self . m_tinge . write_all_bridges_to_conf ( )
else :
label = " Supplied IP Address did not match a Bridge. " ,
failure_msg : wx . GenericMessageDialog = wx . GenericMessageDialog ( self . pnl , label , caption = " Try again! " )
failure_msg . ShowModal ( )
return found_any
@redraw
def add_lights ( self , lights : list [ HueLight ] ) :
""" This will add the lights from a group to the sizer
@ -245,6 +268,9 @@ class Hui(wx.Frame):
found_any = True
self . m_tinge . write_all_bridges_to_conf ( )
self . add_bridges ( )
else :
found_any = self . add_manual_discovery_dialog ( )
self . add_bridges ( )
return found_any
def get_ok_cancel_answer_from_modal ( self , message : str ) - > bool :