Skip to content

Commit

Permalink
Fix bug getting lamp status
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Nov 25, 2023
1 parent 8d6e513 commit cf68afa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Next version

### 🔧 Fixed

* Fixed a bug getting the lamp status after switching to the new `lvmnps` actor.


## 0.6.14 - November 24, 2023

### ✨ Improved
Expand Down
17 changes: 6 additions & 11 deletions python/lvmscp/delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,22 +310,17 @@ async def get_lamps(self):
"""Retrieves lamp information."""

lvmnps = self.actor.config.get("lvmnps", "lvmnps")
cmd = await self.command.send_command(
lvmnps,
"status",
time_limit=10,
)
cmd = await self.command.send_command(lvmnps, "status", time_limit=10)

# The config file includes the names of the lamps that should be present.
lamps = self.actor.config.get("lamps", [])

try:
status = cmd.replies.get("status")
for switch in status:
for outlet in status[switch]:
if outlet in lamps:
state = "ON" if status[switch][outlet]["state"] == 1 else "OFF"
self.header_data[outlet.upper()] = state
outlets = cmd.replies.get("outlets")
for outlet in outlets:
if outlet["name"] in lamps:
state = "ON" if outlet["state"] else "OFF"
self.header_data[outlet["name"].upper()] = state
except Exception as err:
self.command.warning(f"Failed retrieving lamp status: {err}")

Expand Down

0 comments on commit cf68afa

Please sign in to comment.