Skip to content

Commit

Permalink
Fix time format usage
Browse files Browse the repository at this point in the history
  • Loading branch information
zim514 committed Mar 31, 2024
1 parent 8733751 commit 324688a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
5 changes: 2 additions & 3 deletions script.service.hue/addon.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<addon id="script.service.hue" name="Hue Service" provider-name="zim514" version="1.5.9">
<addon id="script.service.hue" name="Hue Service" provider-name="zim514" version="2.0.0">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.requests" version="2.27.1"/>
Expand All @@ -20,7 +20,7 @@
</assets>
<source>https://github.com/zim514/script.service.hue</source>
<forum>https://forum.kodi.tv/showthread.php?tid=344886</forum>
<news>v1.5.8
<news>v2.0.0
- Hue API V2 support (requires reconfiguration of scenes and ambilight)
- Now uses standard scenes
- Sunrise is now manually configured (Default 8AM)
Expand All @@ -30,7 +30,6 @@
- Various bug fixes
- Localisation updates from Weblate


</news>
<summary lang="ca_ES">Automatitza les llums Hue amb la reproducció de Kodi</summary>
<summary lang="cs_CZ">Automatizace Hue světel s přehráváním Kodi</summary>
Expand Down
3 changes: 2 additions & 1 deletion script.service.hue/resources/lib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ def _run_sunset(self):

def _set_daytime(self):
now = datetime.now()

xbmc.log(f"[SCRIPT.SERVICE.HUE] _set_daytime(): Morning Time: {self.morning_time}, Now: {now.time()}, bridge.sunset: {self.bridge.sunset}")

Check notice on line 197 in script.service.hue/resources/lib/core.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (147 \> 120 characters)

Check notice on line 197 in script.service.hue/resources/lib/core.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (147 \> 120 characters)
xbmc.log(f"[SCRIPT.SERVICE.HUE] _set_daytime(): Morning Time: {type(self.morning_time)}, Now: {type(now.time())}, bridge.sunset: {type(self.bridge.sunset)}")

Check notice on line 198 in script.service.hue/resources/lib/core.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (165 \> 120 characters)

Check notice on line 198 in script.service.hue/resources/lib/core.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (165 \> 120 characters)
if self.morning_time <= now.time() < self.bridge.sunset:
cache_set("daytime", True)
else:
Expand Down
1 change: 1 addition & 0 deletions script.service.hue/resources/lib/lightgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def _is_within_schedule(self):

# Check if schedule setting is enabled
if schedule_enabled:
xbmc.log(f"[SCRIPT.SERVICE.HUE] Schedule enabled: {schedule_enabled}, start: {schedule_start}, end: {schedule_end}")

Check notice on line 230 in script.service.hue/resources/lib/lightgroup.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (128 \> 120 characters)

Check notice on line 230 in script.service.hue/resources/lib/lightgroup.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (128 \> 120 characters)
xbmc.log(f"[SCRIPT.SERVICE.HUE] Schedule enabled: {schedule_enabled}, start: {schedule_start}, end: {schedule_end}")

Check notice on line 231 in script.service.hue/resources/lib/lightgroup.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (128 \> 120 characters)

Check notice on line 231 in script.service.hue/resources/lib/lightgroup.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (128 \> 120 characters)
# Check if current time is within start and end times
if schedule_start < datetime.now().time() < schedule_end:
Expand Down
10 changes: 4 additions & 6 deletions script.service.hue/resources/lib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def reload_settings(self):
self.daylight_disable = ADDON.getSettingBool("daylightDisable")

Check notice on line 45 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

An instance attribute is defined outside `__init__`

Instance attribute daylight_disable defined outside __init__

Check notice on line 45 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

An instance attribute is defined outside `__init__`

Instance attribute daylight_disable defined outside __init__
self.schedule_enabled = ADDON.getSettingBool("enableSchedule")

Check notice on line 46 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

An instance attribute is defined outside `__init__`

Instance attribute schedule_enabled defined outside __init__

Check notice on line 46 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

An instance attribute is defined outside `__init__`

Instance attribute schedule_enabled defined outside __init__

self.morning_time = ADDON.getSettingString("morningTime")
self.schedule_start = ADDON.getSettingString("startTime")
self.schedule_end = ADDON.getSettingString("endTime")
self.morning_time = convert_time(ADDON.getSettingString("morningTime"))

Check notice on line 48 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

An instance attribute is defined outside `__init__`

Instance attribute morning_time defined outside __init__

Check notice on line 48 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

An instance attribute is defined outside `__init__`

Instance attribute morning_time defined outside __init__
self.schedule_start = convert_time(ADDON.getSettingString("startTime"))

Check notice on line 49 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

An instance attribute is defined outside `__init__`

Instance attribute schedule_start defined outside __init__

Check notice on line 49 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

An instance attribute is defined outside `__init__`

Instance attribute schedule_start defined outside __init__
self.schedule_end = convert_time(ADDON.getSettingString("endTime"))

Check notice on line 50 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

An instance attribute is defined outside `__init__`

Instance attribute schedule_end defined outside __init__

Check notice on line 50 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

An instance attribute is defined outside `__init__`

Instance attribute schedule_end defined outside __init__

# video activation settings
self.minimum_duration = ADDON.getSettingInt("video_MinimumDuration")

Check notice on line 53 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

An instance attribute is defined outside `__init__`

Instance attribute minimum_duration defined outside __init__

Check notice on line 53 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

An instance attribute is defined outside `__init__`

Instance attribute minimum_duration defined outside __init__
Expand Down Expand Up @@ -118,9 +118,7 @@ def _validate_ambilight(self):
def _validate_schedule(self):
xbmc.log(f"[SCRIPT.SERVICE.HUE] Validate schedule. Schedule Enabled: {self.schedule_enabled}, Start time: {self.schedule_start}, End time: {self.schedule_end}")

Check notice on line 119 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (168 \> 120 characters)

Check notice on line 119 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (168 \> 120 characters)
if self.schedule_enabled:
start_time = convert_time(self.schedule_start)
end_time = convert_time(self.schedule_end)
if start_time > end_time: # checking if start time is after the end time
if self.schedule_start > self.schedule_end: # checking if start time is after the end time
ADDON.setSettingBool('EnableSchedule', False)
xbmc.log('[SCRIPT.SERVICE.HUE] _validate_schedule: Start time is after end time, schedule disabled')
notification(_('Hue Service'), _('Invalid start or end time, schedule disabled'), icon=xbmcgui.NOTIFICATION_ERROR)

Check notice on line 124 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (130 \> 120 characters)

Check notice on line 124 in script.service.hue/resources/lib/settings.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (130 \> 120 characters)

0 comments on commit 324688a

Please sign in to comment.