tangled
alpha
login
or
join now
zzstoatzz.io
/
solux
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
add debug logging
zzstoatzz.io
1 month ago
75d0c3bb
923d77e7
+8
1 changed file
expand all
collapse all
unified
split
src
solux
controller.py
+8
src/solux/controller.py
···
166
166
transition_seconds: float = 60.0,
167
167
) -> None:
168
168
"""apply light state to groups."""
169
169
+
print(f"DEBUG apply_state: groups={groups!r}, type={type(groups)}")
169
170
bridge = get_bridge()
170
171
171
172
if groups is None:
172
173
all_groups = bridge.get_group()
174
174
+
print(f"DEBUG all_groups type={type(all_groups)}, value={all_groups!r}")
173
175
if isinstance(all_groups, list):
174
176
# hue api returns errors as a list, e.g. [{"error": {"description": "..."}}]
175
177
errors = []
176
178
for item in all_groups:
179
179
+
print(f"DEBUG item={item!r}, type={type(item)}")
177
180
if isinstance(item, dict) and isinstance(item.get("error"), dict):
178
181
errors.append(item["error"].get("description", str(item["error"])))
179
182
if errors:
···
186
189
for gid, info in all_groups.items()
187
190
if isinstance(info, dict) and info.get("name") not in ("all", "Custom group for $lights")
188
191
]
192
192
+
print(f"DEBUG resolved groups={groups!r}")
189
193
194
194
+
print(f"DEBUG iterating over groups={groups!r}")
190
195
for group_name in groups:
196
196
+
print(f"DEBUG setting group_name={group_name!r}, type={type(group_name)}")
191
197
bridge.set_group(
192
198
group_name,
193
199
{"on": light_state.on, "bri": light_state.bri, "ct": light_state.ct},
···
198
204
def update(groups: list[str] | None = None) -> None:
199
205
"""main update - checks state, applies lights."""
200
206
external = load_state()
207
207
+
print(f"DEBUG update: external.groups={external.groups!r}, type={type(external.groups)}")
201
208
light_state, description = resolve_state(external)
202
209
target_groups = external.groups or groups
210
210
+
print(f"DEBUG update: target_groups={target_groups!r}, type={type(target_groups)}")
203
211
204
212
print(f"[{description}] bri={light_state.bri}, ct={light_state.ct}, on={light_state.on} | {target_groups}")
205
213
apply_state(light_state, target_groups)