forked from AitorDB/home-assistant-sun-card
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calculation and graph overhaul + Moon support (#56)
- Completely revamped calculations and Sun graph, now way more realistic - Moon support: Moon on the graph, moonrise, moonset, Moon phase, Moon elevation and Moon azimuth - Obeys Home Assistant's settings for time and number formatting - Cleaned up config options - Font size adjustments, including the smaller AM/PM text from the original card - Lots of tests - All lint warnings gone Resolves the following issues: - #11 - Moon support - #30 - Horizon-card customize with card-mod - #40 - More realistic visualization and own source of Sun data - #54 - 24h format not working by default - #58 - Support HA 2023.7's local/server time zone setting
- Loading branch information
Showing
90 changed files
with
7,057 additions
and
4,094 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,6 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# IDEs | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import re | ||
|
||
|
||
def scale(group, x_offset, x_length, y_offset, y_length): | ||
x = float(group[2]) | ||
y = float(group[3]) | ||
|
||
x *= x_length/400 | ||
x += x_offset | ||
x = round(x, 3) | ||
|
||
y *= y_length/100 | ||
y += y_offset | ||
y = round(y, 3) | ||
|
||
return f"{group[1]}{x},{y}" | ||
|
||
|
||
# Base curve composed of two segments | ||
# Full | ||
# base_curve = "M0,100 C72.84,100 127.16,0 200,0 C272.84,0 327.16,100 400,100" | ||
# Simplified | ||
base_curve = "M0,100 C72.84,100 127.16,0 200,0 S327.16,100 400,100" | ||
|
||
groups = re.findall(r"(([A-Z ]+)([0-9.]+)[, ]+([0-9.]+))", base_curve) | ||
scaled = [] | ||
for g in groups: | ||
scaled.append(scale(g, 5, 540, 20, 126)) | ||
|
||
# Prints scaled curve | ||
print("".join(scaled)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.