Skip to content

Commit

Permalink
Merge pull request #74 from Minims/dev
Browse files Browse the repository at this point in the history
0.2.5
  • Loading branch information
Minims authored Jan 5, 2023
2 parents 08967d4 + 1914103 commit 5c5ac84
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 25 deletions.
2 changes: 1 addition & 1 deletion somfyProtect2Mqtt/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"
services:
somfyprotect2mqtt:
build: .
image: somfyprotect2mqtt:v0.2.4
image: somfyprotect2mqtt:v0.2.5
volumes:
- ./config:/config

1 change: 1 addition & 0 deletions somfyProtect2Mqtt/homeassistant/ha_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"slidedoor",
"window",
"externdoor",
"interndoor",
"slidewindow",
"garage",
],
Expand Down
18 changes: 5 additions & 13 deletions somfyProtect2Mqtt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from somfy_protect.api import SomfyProtectApi
from somfy_protect.websocket import SomfyProtectWebsocket

VERSION = "0.2.4"
VERSION = "0.2.5"


def somfy_protect_loop(somfy_protect_2_mqtt):
Expand All @@ -39,12 +39,8 @@ def somfy_protect_wss_loop(somfy_protect_websocket):

# Read Arguments
PARSER = argparse.ArgumentParser()
PARSER.add_argument(
"--verbose", "-v", action="store_true", help="verbose mode"
)
PARSER.add_argument(
"--configuration", "-c", type=str, help="config file path"
)
PARSER.add_argument("--verbose", "-v", action="store_true", help="verbose mode")
PARSER.add_argument("--configuration", "-c", type=str, help="config file path")
ARGS = PARSER.parse_args()
DEBUG = ARGS.verbose
CONFIG_FILE = ARGS.configuration
Expand All @@ -59,14 +55,10 @@ def somfy_protect_wss_loop(somfy_protect_websocket):
SSO = init_sso(config=CONFIG)
API = SomfyProtectApi(sso=SSO)
MQTT_CLIENT = init_mqtt(config=CONFIG, api=API)
WSS = SomfyProtectWebsocket(
sso=SSO, debug=DEBUG, config=CONFIG, mqtt_client=MQTT_CLIENT, api=API
)
WSS = SomfyProtectWebsocket(sso=SSO, debug=DEBUG, config=CONFIG, mqtt_client=MQTT_CLIENT, api=API)

try:
SOMFY_PROTECT = SomfyProtect2Mqtt(
api=API, mqtt_client=MQTT_CLIENT, config=CONFIG
)
SOMFY_PROTECT = SomfyProtect2Mqtt(api=API, mqtt_client=MQTT_CLIENT, config=CONFIG)

except SomfyProtectInitError as exp:
LOGGER.error(f"Unable to init: {exp}")
Expand Down
14 changes: 4 additions & 10 deletions somfyProtect2Mqtt/somfy_protect/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Somfy Protect Api"""
import base64
import logging
from json import JSONDecodeError
from typing import Any, Callable, Dict, List, Optional, Union

Expand All @@ -14,10 +15,10 @@
Site,
)

### NEW ###

from somfy_protect.sso import SomfyProtectSso, read_token_from_file

LOGGER = logging.getLogger(__name__)


BASE_URL = "https://api.myfox.io"
# Don't know how it works for now.
Expand Down Expand Up @@ -225,9 +226,6 @@ def update_device(

# Clean Settings Dict
settings.pop("object")
# settings.pop('disarmed')
# settings.pop('partial')
# settings.pop('armed')

payload = {"settings": settings, "label": device_label}
response = self.put(
Expand All @@ -251,11 +249,7 @@ def camera_snapshot(self, site_id: str, device_id: str) -> Device:
json={"refresh": 10},
)
response.raise_for_status()
# path = "file.jpeg"
if response.status_code == 200:
# with open(path, "wb") as f:
# for chunk in response:
# f.write(chunk)
return response

def camera_refresh_snapshot(self, site_id: str, device_id: str) -> Device:
Expand Down Expand Up @@ -293,7 +287,7 @@ def get_devices(
content = response.json()
except JSONDecodeError:
response.raise_for_status()

LOGGER.debug(f"Devices Capabilities: {response.json()}")
devices += [
Device(**d)
for d in content.get("items")
Expand Down
5 changes: 4 additions & 1 deletion somfyProtect2Mqtt/somfy_protect_2_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ def __init__(
if site.label in self.my_sites:
LOGGER.info(f"Storing Site ID for {site.label}")
self.my_sites_id.append(site.id)
else:
LOGGER.info(
f"Site '{site.label}' is not set in configuration, Update it if you want to add this Site"
)

def close(self) -> None: # pylint: disable=no-self-use
"""Close"""
return

def loop(self) -> None:
"""Main Loop"""
Expand Down

0 comments on commit 5c5ac84

Please sign in to comment.