Compare commits
No commits in common. "cfef9595d751969fd7890ad8a1ba6ca054aa1aad" and "5972f4e9588cec6831592dbc0504313f9d25bfd8" have entirely different histories.
cfef9595d7
...
5972f4e958
6 changed files with 22 additions and 69 deletions
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
|
@ -2,13 +2,13 @@
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
width="170.17047mm"
|
width="210mm"
|
||||||
height="166.50186mm"
|
height="297mm"
|
||||||
viewBox="0 0 170.17047 166.50186"
|
viewBox="0 0 210 297"
|
||||||
version="1.1"
|
version="1.1"
|
||||||
id="svg5"
|
id="svg5"
|
||||||
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
|
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
|
||||||
sodipodi:docname="org.smolnet.tinge.svg"
|
sodipodi:docname="icon.svg"
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
@ -28,8 +28,8 @@
|
||||||
inkscape:snap-grids="false"
|
inkscape:snap-grids="false"
|
||||||
inkscape:object-nodes="false"
|
inkscape:object-nodes="false"
|
||||||
inkscape:zoom="0.48222205"
|
inkscape:zoom="0.48222205"
|
||||||
inkscape:cx="1046.1985"
|
inkscape:cx="1098.0419"
|
||||||
inkscape:cy="1128.111"
|
inkscape:cy="1165.4382"
|
||||||
inkscape:window-width="3440"
|
inkscape:window-width="3440"
|
||||||
inkscape:window-height="1440"
|
inkscape:window-height="1440"
|
||||||
inkscape:window-x="0"
|
inkscape:window-x="0"
|
||||||
|
@ -42,15 +42,15 @@
|
||||||
<marker
|
<marker
|
||||||
style="overflow:visible"
|
style="overflow:visible"
|
||||||
id="Arrow1Lstart"
|
id="Arrow1Lstart"
|
||||||
refX="0"
|
refX="0.0"
|
||||||
refY="0"
|
refY="0.0"
|
||||||
orient="auto"
|
orient="auto"
|
||||||
inkscape:stockid="Arrow1Lstart"
|
inkscape:stockid="Arrow1Lstart"
|
||||||
inkscape:isstock="true">
|
inkscape:isstock="true">
|
||||||
<path
|
<path
|
||||||
transform="matrix(0.8,0,0,0.8,10,0)"
|
transform="scale(0.8) translate(12.5,0)"
|
||||||
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
|
style="fill-rule:evenodd;fill:context-stroke;stroke:context-stroke;stroke-width:1.0pt"
|
||||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
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 "
|
||||||
id="path11947" />
|
id="path11947" />
|
||||||
</marker>
|
</marker>
|
||||||
<linearGradient
|
<linearGradient
|
||||||
|
@ -65,10 +65,9 @@
|
||||||
<g
|
<g
|
||||||
inkscape:label="Layer 1"
|
inkscape:label="Layer 1"
|
||||||
inkscape:groupmode="layer"
|
inkscape:groupmode="layer"
|
||||||
id="layer1"
|
id="layer1">
|
||||||
transform="translate(-13.673282,-10.01244)">
|
|
||||||
<ellipse
|
<ellipse
|
||||||
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"
|
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"
|
||||||
id="path18033"
|
id="path18033"
|
||||||
cx="98.75856"
|
cx="98.75856"
|
||||||
cy="93.263443"
|
cy="93.263443"
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
|
@ -2,4 +2,4 @@
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=Tinge
|
Name=Tinge
|
||||||
Exec=tinge
|
Exec=tinge
|
||||||
Icon=org.smolnet.tinge
|
Icon=face-cool
|
||||||
|
|
|
@ -81,20 +81,6 @@ class Hui(wx.Frame):
|
||||||
self.sizer.Add(btn, 0, wx.EXPAND)
|
self.sizer.Add(btn, 0, wx.EXPAND)
|
||||||
self.Bind(wx.EVT_BUTTON, lambda event: self.discover_new_bridges(),
|
self.Bind(wx.EVT_BUTTON, lambda event: self.discover_new_bridges(),
|
||||||
btn)
|
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
|
@redraw
|
||||||
def add_groups(self, groups: list[HueGroup]):
|
def add_groups(self, groups: list[HueGroup]):
|
||||||
|
@ -166,9 +152,6 @@ class Hui(wx.Frame):
|
||||||
add_single_light(mlightid, True),
|
add_single_light(mlightid, True),
|
||||||
light_btn)
|
light_btn)
|
||||||
self.sizer.Add(inner_sizer, 0, wx.EXPAND)
|
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:
|
def add_manual_discovery_dialog(self) -> bool:
|
||||||
self.sizer.Clear(delete_windows=True)
|
self.sizer.Clear(delete_windows=True)
|
||||||
|
@ -346,19 +329,6 @@ class Hui(wx.Frame):
|
||||||
delete_light_and_goto_group(mlightid),
|
delete_light_and_goto_group(mlightid),
|
||||||
delete_btn)
|
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):
|
def delete_light_and_goto_group(self, lightid):
|
||||||
"""Combo call back for delete and goto group
|
"""Combo call back for delete and goto group
|
||||||
|
|
||||||
|
@ -456,12 +426,6 @@ class Hui(wx.Frame):
|
||||||
self.cur_group = group
|
self.cur_group = group
|
||||||
self.add_lights(group.get_lights())
|
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):
|
def rename_light_and_goto_light(self, lightid, unattached: bool = False):
|
||||||
"""Combo call back to rename a light and display that light again
|
"""Combo call back to rename a light and display that light again
|
||||||
|
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -5,10 +5,10 @@ with open("README.md", "r", encoding="utf-8") as fh:
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="tinge",
|
name="tinge",
|
||||||
version="0.0.3",
|
version="0.0.1",
|
||||||
author="Micke Nordin",
|
author="Micke Nordin",
|
||||||
author_email="hej@mic.ke",
|
author_email="hej@mic.ke",
|
||||||
data_files = [('share/applications', ['data/org.smolnet.tinge.desktop']),('share/icons/hicolor/scalable/apps',['data/org.smolnet.tinge.svg']),],
|
data_files = [('share/applications', ['data/org.smolnet.tinge.desktop']),],
|
||||||
description="A GUI for Philips Hue lights.",
|
description="A GUI for Philips Hue lights.",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
|
|
@ -8,7 +8,8 @@ import toml
|
||||||
from upnpy import UPnP
|
from upnpy import UPnP
|
||||||
|
|
||||||
from .HueBridge import HueBridge
|
from .HueBridge import HueBridge
|
||||||
from .HueUtils import is_valid_config, make_request, is_bridge
|
from .HueUtils import connect, is_valid_config, make_request, is_bridge
|
||||||
|
from .UserOrError import UserOrError
|
||||||
|
|
||||||
|
|
||||||
class Tinge:
|
class Tinge:
|
||||||
|
@ -24,25 +25,16 @@ class Tinge:
|
||||||
self.create_confdir()
|
self.create_confdir()
|
||||||
self.read_bridges_from_file()
|
self.read_bridges_from_file()
|
||||||
|
|
||||||
def append_bridge(self, bridge: HueBridge) -> None:
|
def append_bridge(self, bridge: HueBridge):
|
||||||
"""Append a bridge to the list
|
|
||||||
"""
|
|
||||||
self.m_bridges.append(bridge)
|
self.m_bridges.append(bridge)
|
||||||
self.m_discovered.append(bridge.get_ipaddress())
|
self.m_discovered.append(bridge.get_ipaddress())
|
||||||
|
|
||||||
def create_confdir(self) -> None:
|
def create_confdir(self):
|
||||||
"""Create the config dir if it does not allready exist
|
"""Create the config dir if it does not allready exist
|
||||||
"""
|
"""
|
||||||
if not os.path.exists(os.path.dirname(self.m_config)):
|
if not os.path.exists(os.path.dirname(self.m_config)):
|
||||||
os.makedirs(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]]:
|
def discover_new_bridges(self) -> Union[None, list[dict]]:
|
||||||
"""Use UPnP to discover bridges on the current network
|
"""Use UPnP to discover bridges on the current network
|
||||||
"""
|
"""
|
||||||
|
@ -84,7 +76,7 @@ class Tinge:
|
||||||
"""
|
"""
|
||||||
return self.m_bridges
|
return self.m_bridges
|
||||||
|
|
||||||
def read_bridges_from_file(self) -> None:
|
def read_bridges_from_file(self):
|
||||||
"""Read config file and add back previously discovered bridges
|
"""Read config file and add back previously discovered bridges
|
||||||
"""
|
"""
|
||||||
if is_valid_config(self.m_config):
|
if is_valid_config(self.m_config):
|
||||||
|
@ -103,11 +95,9 @@ class Tinge:
|
||||||
self.m_bridges.append(bridge)
|
self.m_bridges.append(bridge)
|
||||||
self.m_discovered.append(key)
|
self.m_discovered.append(key)
|
||||||
|
|
||||||
def write_all_bridges_to_conf(self) -> None:
|
def write_all_bridges_to_conf(self):
|
||||||
"""Save to file
|
"""Save to file
|
||||||
"""
|
"""
|
||||||
with open(self.m_config, 'w') as configfile:
|
with open(self.m_config, 'w') as configfile:
|
||||||
for bridge in self.m_bridges:
|
for bridge in self.m_bridges:
|
||||||
configfile.write('["{}"]\nuser = "{}"\n'.format(bridge.get_ipaddress(), bridge.get_user()))
|
configfile.write('["{}"]\nuser = "{}"\n'.format(bridge.get_ipaddress(), bridge.get_user()))
|
||||||
if len(self.m_bridges) == 0:
|
|
||||||
configfile.truncate()
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue