Skip to content

Commit

Permalink
Merge pull request #33 from kaffetorsk/brightness
Browse files Browse the repository at this point in the history
Add brightness to camera commands
  • Loading branch information
kaffetorsk authored Dec 30, 2024
2 parents 5c20872 + 81811c3 commit 071b74f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Payload in a simple string.
```
"START" and "STOP": Starts and stops active stream
"SNAPSHOT": Requests snapshot to be taken
"BRIGHTNESS X": Set video brightness to X (integer from -2 to 2)
```
##### Base Stations
JSON payload, all keys are optional.
Expand Down
24 changes: 19 additions & 5 deletions camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,28 @@ async def mqtt_control(self, payload):
"""
Handles incoming MQTT commands
"""
match payload.upper():
case 'START':
match payload.strip().upper().split():
case ['START']:
await self.set_state('streaming')
case 'STOP':
case ['STOP']:
await self.set_state('idle')
case 'SNAPSHOT':
case ['SNAPSHOT']:
await self.event_loop.run_in_executor(
None, self._arlo.request_snapshot)
None, self._arlo.request_snapshot
)
case ['BRIGHTNESS', value]:
try:
value = int(value)
if not (-2 <= value <= 2):
raise ValueError
await self.event_loop.run_in_executor(
None, lambda: setattr(
self._arlo, 'brightness', int(value)
)
)
logging.info(f"{self.name} brightness set to: {value}")
except ValueError:
logging.warning(f"Invalid value for brigthness: {value}")

async def _create_idle_video(self, image_path):
"""
Expand Down

0 comments on commit 071b74f

Please sign in to comment.