Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/sync-tag-definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
id: fetch
run: python3 scripts/fetch_tag_types.py new_tag_types.json

- name: Generate updated tag_types.py
- name: Generate updated const.py
id: generate
run: |
python3 scripts/generate_tag_types.py new_tag_types.json
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
branch: 'automated/sync-tag-definitions'
delete-branch: true
add-paths: |
custom_components/opendisplay/tag_types.py
custom_components/opendisplay/const.py
labels: |
automated
dependencies
Expand Down
95 changes: 95 additions & 0 deletions custom_components/opendisplay/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,98 @@
SIGNAL_AP_UPDATE = f"{DOMAIN}_ap_update"
OEPL_CONFIG_URL = "https://config.openepaperlink.org/"
ATC_CONFIG_URL = "https://atc1441.github.io/ATC_BLE_OEPL_Image_Upload.html"

# Fallback tag type definitions
# These definitions are automatically synced from OpenEPaperLink repository
# See: https://github.com/OpenEPaperLink/OpenEPaperLink/tree/master/resources/tagtypes
FALLBACK_TAG_DEFINITIONS = {
0: {"version": 4, "name": "M2 1.54\"", "width": 152, "height": 152},
1: {"version": 5, "name": "M2 2.9\"", "width": 296, "height": 128},
2: {"version": 5, "name": "M2 4.2\"", "width": 400, "height": 300},
3: {"version": 6, "name": "M2 2.2\"", "width": 212, "height": 104},
4: {"version": 4, "name": "M2 2.6\"", "width": 296, "height": 152},
5: {"version": 4, "name": "M2 7.4\"", "width": 640, "height": 384},
6: {"version": 4, "name": "Opticon 2.2\"", "width": 250, "height": 128},
7: {"version": 4, "name": "Opticon 2.9\"", "width": 296, "height": 128},
8: {"version": 2, "name": "Opticon 4.2\"", "width": 400, "height": 300},
9: {"version": 2, "name": "Opticon 7.5\"", "width": 640, "height": 384},
17: {"version": 3, "name": "M2 2.9\" (UC8151)", "width": 296, "height": 128},
18: {"version": 3, "name": "M2 4.2\" UC", "width": 400, "height": 300},
33: {"version": 2, "name": "ST‐GM29XXF 2.9\"", "width": 296, "height": 128},
34: {"version": 2, "name": "M2 2.7\"", "width": 264, "height": 176},
38: {"version": 1, "name": "M2 7.5\" BW", "width": 640, "height": 384},
39: {"version": 3, "name": "ST‐GM29MT1 2.9\"", "width": 296, "height": 128},
40: {"version": 2, "name": "M3 1.6\" BWRY", "width": 168, "height": 168},
41: {"version": 1, "name": "M3 2.4\" BWRY", "width": 296, "height": 168},
42: {"version": 1, "name": "M3 3.0\" BWRY", "width": 400, "height": 168},
43: {"version": 1, "name": "M3 2.9\" BWRY", "width": 384, "height": 168},
44: {"version": 1, "name": "M3 4.3\" BWRY", "width": 522, "height": 152},
45: {"version": 2, "name": "M3 12.2\"", "width": 960, "height": 768},
46: {"version": 5, "name": "M3 9.7\"", "width": 960, "height": 672},
47: {"version": 4, "name": "M3 4.3\"", "width": 522, "height": 152},
48: {"version": 2, "name": "M3 1.6\"", "width": 200, "height": 200},
49: {"version": 1, "name": "M3 2.2\"", "width": 296, "height": 160},
50: {"version": 1, "name": "M3 2.6\"", "width": 360, "height": 184},
51: {"version": 3, "name": "M3 2.9\"", "width": 384, "height": 168},
52: {"version": 2, "name": "M3 4.2\"", "width": 400, "height": 300},
53: {"version": 2, "name": "M3 6.0\"", "width": 600, "height": 448},
54: {"version": 5, "name": "M3 7.5\"", "width": 800, "height": 480},
55: {"version": 3, "name": "M3 11.6\"", "width": 960, "height": 640},
60: {"version": 3, "name": "M3 4.2\" BWY", "width": 400, "height": 300},
64: {"version": 1, "name": "M3 2.9\" BW", "width": 384, "height": 168},
65: {"version": 1, "name": "M3 5.85\"", "width": 792, "height": 272},
66: {"version": 1, "name": "M3 5.85\" BW", "width": 792, "height": 272},
67: {"version": 2, "name": "M3 1.3\" Peghook", "width": 144, "height": 200},
68: {"version": 2, "name": "M3 5.81\" BW", "width": 720, "height": 256},
69: {"version": 3, "name": "M3 2.2 Lite\"", "width": 250, "height": 128},
70: {"version": 1, "name": "M3 2.2\" BW", "width": 296, "height": 160},
71: {"version": 4, "name": "M3 2.7\"", "width": 300, "height": 200},
72: {"version": 1, "name": "M3 5.81\" BWR", "width": 720, "height": 256},
73: {"version": 2, "name": "M3 5.81\" V2 BWR", "width": 720, "height": 256},
74: {"version": 1, "name": "M3 1.6\" 200px BWRY", "width": 200, "height": 200},
75: {"version": 1, "name": "M3 2.2\" BWRY", "width": 296, "height": 160},
76: {"version": 1, "name": "M3 7.5\" BWRY", "width": 800, "height": 480},
77: {"version": 3, "name": "M3 11.6\" BWRY", "width": 960, "height": 640},
78: {"version": 2, "name": "M3 2.6\" BW", "width": 360, "height": 184},
80: {"version": 2, "name": "HD150 5.83\" BWR", "width": 648, "height": 480},
84: {"version": 4, "name": "HS BW 2.13\"", "width": 256, "height": 128},
85: {"version": 5, "name": "HS BWR 2.13\"", "width": 256, "height": 128},
86: {"version": 6, "name": "HS BWR 2.66\"", "width": 296, "height": 152},
87: {"version": 3, "name": "TLSR BWR 1.54\"", "width": 200, "height": 200},
88: {"version": 3, "name": "TLSR BW 2.13\"", "width": 256, "height": 128},
89: {"version": 3, "name": "TLSR BWR 2.13\"", "width": 264, "height": 136},
90: {"version": 1, "name": "HS BW 2.13\" LowRes", "width": 212, "height": 104},
96: {"version": 6, "name": "HS BWY 3.5\"", "width": 384, "height": 184},
97: {"version": 4, "name": "HS BWR 3.5\"", "width": 384, "height": 184},
98: {"version": 4, "name": "HS BW 3.5\"", "width": 384, "height": 184},
99: {"version": 6, "name": "TLSR BWR 4.2\"", "width": 400, "height": 300},
102: {"version": 2, "name": "HS BWY 7,5\"", "width": 800, "height": 480},
103: {"version": 3, "name": "HS 2.00\" BWY", "width": 152, "height": 200},
104: {"version": 4, "name": "HS BWY 3.46\"", "width": 480, "height": 176},
105: {"version": 4, "name": "TLSR BW 2.13\"", "width": 250, "height": 136},
106: {"version": 1, "name": "HS BWR 5,83\"", "width": 648, "height": 480},
107: {"version": 3, "name": "HS BWRY 7,5\"", "width": 800, "height": 480},
108: {"version": 3, "name": "HS BWRY 2,00\"", "width": 152, "height": 200},
109: {"version": 3, "name": "HS BWRY 3,5\"", "width": 384, "height": 184},
110: {"version": 3, "name": "HS BWRY 2,9\"", "width": 296, "height": 128},
111: {"version": 2, "name": "HS BWRY 2,60\"", "width": 296, "height": 152},
128: {"version": 1, "name": "Chroma 7.4\"", "width": 640, "height": 384},
129: {"version": 2, "name": "Chroma Aeon 74 7.4\"", "width": 800, "height": 480},
130: {"version": 2, "name": "Chroma29 2.9\"", "width": 296, "height": 128},
131: {"version": 2, "name": "Chroma42 4.2\"", "width": 400, "height": 300},
176: {"version": 5, "name": "Gicisky BLE EPD BW 2.13\"", "width": 250, "height": 128},
177: {"version": 5, "name": "Gicisky BLE EPD BWR 2.13\"", "width": 250, "height": 128},
178: {"version": 2, "name": "Gicisky BLE EPD BW 2.9\"", "width": 296, "height": 128},
179: {"version": 2, "name": "Gicisky BLE EPD BWR 2.9\"", "width": 296, "height": 128},
181: {"version": 2, "name": "Gicisky BLE EPD BWR 4.2\"", "width": 400, "height": 300},
186: {"version": 5, "name": "Gicisky BLE TFT 2.13\"", "width": 250, "height": 136},
189: {"version": 2, "name": "BLE EPD BWR 2.9\" Silabs", "width": 384, "height": 168},
190: {"version": 1, "name": "ATC MiThermometer BLE", "width": 6, "height": 8},
192: {"version": 2, "name": "BWRY example", "width": 360, "height": 180},
226: {"version": 1, "name": "LILYGO TPANEL 4\"", "width": 480, "height": 480},
227: {"version": 1, "name": "GDEM1085Z51 10.85\"", "width": 1360, "height": 480},
228: {"version": 1, "name": "BLE TFT 128x128", "width": 128, "height": 128},
229: {"version": 1, "name": "TFT 240x320", "width": 320, "height": 172},
240: {"version": 2, "name": "SLT‐EM007 Segmented", "width": 0, "height": 0},
250: {"version": 1, "name": "ConfigMode", "width": 0, "height": 0},
}
95 changes: 2 additions & 93 deletions custom_components/opendisplay/tag_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import storage
from .const import DOMAIN
from .const import DOMAIN, FALLBACK_TAG_DEFINITIONS

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -475,99 +475,8 @@ def _load_fallback_types(self) -> None:
The fallback types include all tag definitions from the OpenEPaperLink
repository at: https://github.com/OpenEPaperLink/OpenEPaperLink/tree/master/resources/tagtypes
"""
fallback_definitions = {
0: {"version": 4, "name": "M2 1.54\"", "width": 152, "height": 152},
1: {"version": 5, "name": "M2 2.9\"", "width": 296, "height": 128},
2: {"version": 5, "name": "M2 4.2\"", "width": 400, "height": 300},
3: {"version": 6, "name": "M2 2.2\"", "width": 212, "height": 104},
4: {"version": 4, "name": "M2 2.6\"", "width": 296, "height": 152},
5: {"version": 4, "name": "M2 7.4\"", "width": 640, "height": 384},
6: {"version": 4, "name": "Opticon 2.2\"", "width": 250, "height": 128},
7: {"version": 4, "name": "Opticon 2.9\"", "width": 296, "height": 128},
8: {"version": 2, "name": "Opticon 4.2\"", "width": 400, "height": 300},
9: {"version": 2, "name": "Opticon 7.5\"", "width": 640, "height": 384},
17: {"version": 3, "name": "M2 2.9\" (UC8151)", "width": 296, "height": 128},
18: {"version": 3, "name": "M2 4.2\" UC", "width": 400, "height": 300},
33: {"version": 2, "name": "ST‐GM29XXF 2.9\"", "width": 296, "height": 128},
34: {"version": 2, "name": "M2 2.7\"", "width": 264, "height": 176},
38: {"version": 1, "name": "M2 7.5\" BW", "width": 640, "height": 384},
39: {"version": 3, "name": "ST‐GM29MT1 2.9\"", "width": 296, "height": 128},
40: {"version": 2, "name": "M3 1.6\" BWRY", "width": 168, "height": 168},
41: {"version": 1, "name": "M3 2.4\" BWRY", "width": 296, "height": 168},
42: {"version": 1, "name": "M3 3.0\" BWRY", "width": 400, "height": 168},
43: {"version": 1, "name": "M3 2.9\" BWRY", "width": 384, "height": 168},
44: {"version": 1, "name": "M3 4.3\" BWRY", "width": 522, "height": 152},
45: {"version": 2, "name": "M3 12.2\"", "width": 960, "height": 768},
46: {"version": 5, "name": "M3 9.7\"", "width": 960, "height": 672},
47: {"version": 4, "name": "M3 4.3\"", "width": 522, "height": 152},
48: {"version": 2, "name": "M3 1.6\"", "width": 200, "height": 200},
49: {"version": 1, "name": "M3 2.2\"", "width": 296, "height": 160},
50: {"version": 1, "name": "M3 2.6\"", "width": 360, "height": 184},
51: {"version": 3, "name": "M3 2.9\"", "width": 384, "height": 168},
52: {"version": 2, "name": "M3 4.2\"", "width": 400, "height": 300},
53: {"version": 2, "name": "M3 6.0\"", "width": 600, "height": 448},
54: {"version": 5, "name": "M3 7.5\"", "width": 800, "height": 480},
55: {"version": 3, "name": "M3 11.6\"", "width": 960, "height": 640},
60: {"version": 3, "name": "M3 4.2\" BWY", "width": 400, "height": 300},
64: {"version": 1, "name": "M3 2.9\" BW", "width": 384, "height": 168},
65: {"version": 1, "name": "M3 5.85\"", "width": 792, "height": 272},
66: {"version": 1, "name": "M3 5.85\" BW", "width": 792, "height": 272},
67: {"version": 2, "name": "M3 1.3\" Peghook", "width": 144, "height": 200},
68: {"version": 2, "name": "M3 5.81\" BW", "width": 720, "height": 256},
69: {"version": 3, "name": "M3 2.2 Lite\"", "width": 250, "height": 128},
70: {"version": 1, "name": "M3 2.2\" BW", "width": 296, "height": 160},
71: {"version": 4, "name": "M3 2.7\"", "width": 300, "height": 200},
72: {"version": 1, "name": "M3 5.81\" BWR", "width": 720, "height": 256},
73: {"version": 2, "name": "M3 5.81\" V2 BWR", "width": 720, "height": 256},
74: {"version": 1, "name": "M3 1.6\" 200px BWRY", "width": 200, "height": 200},
75: {"version": 1, "name": "M3 2.2\" BWRY", "width": 296, "height": 160},
76: {"version": 1, "name": "M3 7.5\" BWRY", "width": 800, "height": 480},
77: {"version": 3, "name": "M3 11.6\" BWRY", "width": 960, "height": 640},
78: {"version": 2, "name": "M3 2.6\" BW", "width": 360, "height": 184},
80: {"version": 2, "name": "HD150 5.83\" BWR", "width": 648, "height": 480},
84: {"version": 4, "name": "HS BW 2.13\"", "width": 256, "height": 128},
85: {"version": 5, "name": "HS BWR 2.13\"", "width": 256, "height": 128},
86: {"version": 6, "name": "HS BWR 2.66\"", "width": 296, "height": 152},
87: {"version": 3, "name": "TLSR BWR 1.54\"", "width": 200, "height": 200},
88: {"version": 3, "name": "TLSR BW 2.13\"", "width": 256, "height": 128},
89: {"version": 3, "name": "TLSR BWR 2.13\"", "width": 264, "height": 136},
90: {"version": 1, "name": "HS BW 2.13\" LowRes", "width": 212, "height": 104},
96: {"version": 6, "name": "HS BWY 3.5\"", "width": 384, "height": 184},
97: {"version": 4, "name": "HS BWR 3.5\"", "width": 384, "height": 184},
98: {"version": 4, "name": "HS BW 3.5\"", "width": 384, "height": 184},
99: {"version": 6, "name": "TLSR BWR 4.2\"", "width": 400, "height": 300},
102: {"version": 2, "name": "HS BWY 7,5\"", "width": 800, "height": 480},
103: {"version": 3, "name": "HS 2.00\" BWY", "width": 152, "height": 200},
104: {"version": 4, "name": "HS BWY 3.46\"", "width": 480, "height": 176},
105: {"version": 4, "name": "TLSR BW 2.13\"", "width": 250, "height": 136},
106: {"version": 1, "name": "HS BWR 5,83\"", "width": 648, "height": 480},
107: {"version": 3, "name": "HS BWRY 7,5\"", "width": 800, "height": 480},
108: {"version": 3, "name": "HS BWRY 2,00\"", "width": 152, "height": 200},
109: {"version": 3, "name": "HS BWRY 3,5\"", "width": 384, "height": 184},
110: {"version": 3, "name": "HS BWRY 2,9\"", "width": 296, "height": 128},
111: {"version": 2, "name": "HS BWRY 2,60\"", "width": 296, "height": 152},
128: {"version": 1, "name": "Chroma 7.4\"", "width": 640, "height": 384},
129: {"version": 2, "name": "Chroma Aeon 74 7.4\"", "width": 800, "height": 480},
130: {"version": 2, "name": "Chroma29 2.9\"", "width": 296, "height": 128},
131: {"version": 2, "name": "Chroma42 4.2\"", "width": 400, "height": 300},
176: {"version": 5, "name": "Gicisky BLE EPD BW 2.13\"", "width": 250, "height": 128},
177: {"version": 5, "name": "Gicisky BLE EPD BWR 2.13\"", "width": 250, "height": 128},
178: {"version": 2, "name": "Gicisky BLE EPD BW 2.9\"", "width": 296, "height": 128},
179: {"version": 2, "name": "Gicisky BLE EPD BWR 2.9\"", "width": 296, "height": 128},
181: {"version": 2, "name": "Gicisky BLE EPD BWR 4.2\"", "width": 400, "height": 300},
186: {"version": 5, "name": "Gicisky BLE TFT 2.13\"", "width": 250, "height": 136},
189: {"version": 2, "name": "BLE EPD BWR 2.9\" Silabs", "width": 384, "height": 168},
190: {"version": 1, "name": "ATC MiThermometer BLE", "width": 6, "height": 8},
192: {"version": 2, "name": "BWRY example", "width": 360, "height": 180},
226: {"version": 1, "name": "LILYGO TPANEL 4\"", "width": 480, "height": 480},
227: {"version": 1, "name": "GDEM1085Z51 10.85\"", "width": 1360, "height": 480},
228: {"version": 1, "name": "BLE TFT 128x128", "width": 128, "height": 128},
229: {"version": 1, "name": "TFT 240x320", "width": 320, "height": 172},
240: {"version": 2, "name": "SLT‐EM007 Segmented", "width": 0, "height": 0},
250: {"version": 1, "name": "ConfigMode", "width": 0, "height": 0},
}
self._tag_types = {
type_id: TagType(type_id, data) for type_id, data in fallback_definitions.items()
type_id: TagType(type_id, data) for type_id, data in FALLBACK_TAG_DEFINITIONS.items()
}
self._last_update = datetime.now()
_LOGGER.warning("Loaded fallback tag definitions")
Expand Down
26 changes: 13 additions & 13 deletions scripts/generate_tag_types.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python3
"""Generate updated tag_types.py from fetched tag type definitions.
"""Generate updated const.py from fetched tag type definitions.

Reads a JSON file of tag type definitions (produced by fetch_tag_types.py),
compares them against the current fallback definitions in tag_types.py,
compares them against the current fallback definitions in const.py,
and updates the file if there are changes.

Sets GitHub Actions outputs for downstream workflow steps.
Expand All @@ -14,9 +14,9 @@
import sys


TAG_TYPES_PATH = "custom_components/opendisplay/tag_types.py"
CONST_PATH = "custom_components/opendisplay/const.py"
FALLBACK_PATTERN = re.compile(
r"( fallback_definitions = \{)\n(.*?)\n( \})", re.DOTALL
r"(FALLBACK_TAG_DEFINITIONS = \{)\n(.*?)\n(\})", re.DOTALL
)
ENTRY_PATTERN = re.compile(r"\s+(\d+):")

Expand All @@ -29,10 +29,10 @@ def load_new_tag_types(input_file):


def parse_current_definitions(content):
"""Extract current fallback definitions from tag_types.py content."""
"""Extract current fallback definitions from const.py content."""
match = FALLBACK_PATTERN.search(content)
if not match:
print("Error: Could not find fallback_definitions in tag_types.py")
print("Error: Could not find FALLBACK_TAG_DEFINITIONS in const.py")
sys.exit(1)

current_types = {}
Expand Down Expand Up @@ -67,20 +67,20 @@ def compute_changes(current_types, new_tag_types):


def generate_fallback_content(new_tag_types):
"""Generate the new fallback_definitions dict content."""
"""Generate the new FALLBACK_TAG_DEFINITIONS dict content."""
lines = []
for type_id in sorted(new_tag_types.keys()):
type_data = new_tag_types[type_id]
line = f" {type_id}: {json.dumps(type_data, ensure_ascii=False)},"
line = f" {type_id}: {json.dumps(type_data, ensure_ascii=False)},"
lines.append(line)
return "\n".join(lines)


def update_tag_types_file(content, new_fallback):
"""Replace fallback_definitions content in tag_types.py."""
"""Replace FALLBACK_TAG_DEFINITIONS content in const.py."""
match = FALLBACK_PATTERN.search(content)
if not match:
print("Error: Could not find fallback_definitions in tag_types.py")
print("Error: Could not find FALLBACK_TAG_DEFINITIONS in const.py")
sys.exit(1)

start = match.start(2)
Expand Down Expand Up @@ -119,12 +119,12 @@ def set_github_output(changed, summary):


def main():
"""Generate updated tag_types.py from fetched definitions."""
"""Generate updated const.py from fetched definitions."""
input_file = sys.argv[1] if len(sys.argv) > 1 else "new_tag_types.json"

new_tag_types = load_new_tag_types(input_file)

with open(TAG_TYPES_PATH, "r") as f:
with open(CONST_PATH, "r") as f:
content = f.read()

current_types = parse_current_definitions(content)
Expand All @@ -138,7 +138,7 @@ def main():
new_fallback = generate_fallback_content(new_tag_types)
new_content = update_tag_types_file(content, new_fallback)

with open(TAG_TYPES_PATH, "w") as f:
with open(CONST_PATH, "w") as f:
f.write(new_content)

summary = build_summary(added, removed, modified)
Expand Down
Loading
Loading