Compare commits

...

2 Commits

@ -2,4 +2,4 @@
Type=Application
Name=Tinge
Exec=tinge
Icon=face-cool
Icon=org.smolnet.tinge

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

@ -2,13 +2,13 @@
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="210mm"
height="297mm"
viewBox="0 0 210 297"
width="170.17047mm"
height="166.50186mm"
viewBox="0 0 170.17047 166.50186"
version="1.1"
id="svg5"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
sodipodi:docname="icon.svg"
sodipodi:docname="org.smolnet.tinge.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
@ -28,8 +28,8 @@
inkscape:snap-grids="false"
inkscape:object-nodes="false"
inkscape:zoom="0.48222205"
inkscape:cx="1098.0419"
inkscape:cy="1165.4382"
inkscape:cx="1046.1985"
inkscape:cy="1128.111"
inkscape:window-width="3440"
inkscape:window-height="1440"
inkscape:window-x="0"
@ -42,15 +42,15 @@
<marker
style="overflow:visible"
id="Arrow1Lstart"
refX="0.0"
refY="0.0"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="scale(0.8) translate(12.5,0)"
style="fill-rule:evenodd;fill:context-stroke;stroke:context-stroke;stroke-width:1.0pt"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path11947" />
</marker>
<linearGradient
@ -65,9 +65,10 @@
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
id="layer1"
transform="translate(-13.673282,-10.01244)">
<ellipse
style="fill:#ffffff;fill-rule:evenodd;stroke-width:1.00000003;stroke-miterlimit:4;stroke-dasharray:8.00000022,2.00000006,1.00000003,2.00000006;stroke:#000000;stroke-opacity:1;stroke-dashoffset:0;stroke-linecap:round"
style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:8, 2, 1, 2;stroke-dashoffset:0;stroke-opacity:1"
id="path18033"
cx="98.75856"
cy="93.263443"

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

@ -81,6 +81,20 @@ class Hui(wx.Frame):
self.sizer.Add(btn, 0, wx.EXPAND)
self.Bind(wx.EVT_BUTTON, lambda event: self.discover_new_bridges(),
btn)
@redraw
def add_manage_bridge(self):
"""Add bridges to sizer, the entry point of the program
"""
self.SetTitle('Tinge - Manage Bridge')
label = "Delete Bridge"
btn: wx.Button = wx.Button(self.pnl, label=label)
self.sizer.Add(btn, 0, wx.EXPAND)
self.Bind(wx.EVT_BUTTON, lambda event: self.delete_bridge(),
btn)
back_btn: wx.Button = wx.Button(self.pnl, label="Go Back")
self.sizer.Add(back_btn, 0, wx.EXPAND)
self.Bind(wx.EVT_BUTTON, lambda event: self.add_groups(self.cur_bridge.get_groups()),
back_btn)
@redraw
def add_groups(self, groups: list[HueGroup]):
@ -152,6 +166,9 @@ class Hui(wx.Frame):
add_single_light(mlightid, True),
light_btn)
self.sizer.Add(inner_sizer, 0, wx.EXPAND)
bridge_mgm_btn: wx.Button = wx.Button(self.pnl, label="Manage Bridge")
self.sizer.Add(bridge_mgm_btn, 0, wx.EXPAND)
self.Bind(wx.EVT_BUTTON, lambda event: self.manage_bridge(), bridge_mgm_btn)
def add_manual_discovery_dialog(self) -> bool:
self.sizer.Clear(delete_windows=True)
@ -329,6 +346,19 @@ class Hui(wx.Frame):
delete_light_and_goto_group(mlightid),
delete_btn)
def delete_bridge(self):
dlg: wx.MessageDialog = wx.MessageDialog(self.pnl,
"Delete " + self.cur_bridge.m_name + "?",
"Are you sure?",
style=wx.CANCEL | wx.CANCEL_DEFAULT | wx.OK)
dlg.SetOKCancelLabels("&Yes", "&Don't delete")
reply: int = dlg.ShowModal()
if reply == wx.ID_CANCEL:
self.add_groups(self.cur_bridge.get_groups())
else:
self.m_tinge.delete_bridge(self.cur_bridge)
self.add_bridges()
def delete_light_and_goto_group(self, lightid):
"""Combo call back for delete and goto group
@ -426,6 +456,12 @@ class Hui(wx.Frame):
self.cur_group = group
self.add_lights(group.get_lights())
def manage_bridge(self):
"""Call back for manage bridge button
"""
self.add_manage_bridge()
def rename_light_and_goto_light(self, lightid, unattached: bool = False):
"""Combo call back to rename a light and display that light again

@ -5,10 +5,10 @@ with open("README.md", "r", encoding="utf-8") as fh:
setuptools.setup(
name="tinge",
version="0.0.1",
version="0.0.3",
author="Micke Nordin",
author_email="hej@mic.ke",
data_files = [('share/applications', ['data/org.smolnet.tinge.desktop']),],
data_files = [('share/applications', ['data/org.smolnet.tinge.desktop']),('share/icons/hicolor/scalable/apps',['data/org.smolnet.tinge.svg']),],
description="A GUI for Philips Hue lights.",
long_description=long_description,
long_description_content_type="text/markdown",

@ -8,8 +8,7 @@ import toml
from upnpy import UPnP
from .HueBridge import HueBridge
from .HueUtils import connect, is_valid_config, make_request, is_bridge
from .UserOrError import UserOrError
from .HueUtils import is_valid_config, make_request, is_bridge
class Tinge:
@ -25,16 +24,25 @@ class Tinge:
self.create_confdir()
self.read_bridges_from_file()
def append_bridge(self, bridge: HueBridge):
def append_bridge(self, bridge: HueBridge) -> None:
"""Append a bridge to the list
"""
self.m_bridges.append(bridge)
self.m_discovered.append(bridge.get_ipaddress())
def create_confdir(self):
def create_confdir(self) -> None:
"""Create the config dir if it does not allready exist
"""
if not os.path.exists(os.path.dirname(self.m_config)):
os.makedirs(os.path.dirname(self.m_config))
def delete_bridge(self, bridge: HueBridge) -> None:
"""Delete a bridge from the list
"""
self.m_bridges.remove(bridge)
self.m_discovered.remove(bridge.get_ipaddress())
self.write_all_bridges_to_conf()
def discover_new_bridges(self) -> Union[None, list[dict]]:
"""Use UPnP to discover bridges on the current network
"""
@ -76,7 +84,7 @@ class Tinge:
"""
return self.m_bridges
def read_bridges_from_file(self):
def read_bridges_from_file(self) -> None:
"""Read config file and add back previously discovered bridges
"""
if is_valid_config(self.m_config):
@ -95,9 +103,11 @@ class Tinge:
self.m_bridges.append(bridge)
self.m_discovered.append(key)
def write_all_bridges_to_conf(self):
def write_all_bridges_to_conf(self) -> None:
"""Save to file
"""
with open(self.m_config, 'w') as configfile:
for bridge in self.m_bridges:
configfile.write('["{}"]\nuser = "{}"\n'.format(bridge.get_ipaddress(), bridge.get_user()))
if len(self.m_bridges) == 0:
configfile.truncate()

Loading…
Cancel
Save