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
2 changes: 2 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
0.8.0b7:
Allow more MQTT config.
Fix headers.
Distinguish between user/shared location.
Fix missing event issue.
Tidy capture code.
Expand Down
3 changes: 3 additions & 0 deletions pyaarlo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ class PyArlo(object):
based on camera model. Can also be `v1`, `v2` or `v3`. Use `v3` for the new location API.
* **reconnect_every** - Time, in minutes, to close and relogin to Arlo.
* **snapshot_timeout** - Time, in seconds, to stop the snapshot attempt and return the camera to the idle state.
* **mqtt_host** - specify the mqtt host to use, default mqtt-cluster.arloxcld.com
* **mqtt_hostname_check** - disable MQTT host SSL certificate checking, default True
* **mqtt_transport** - specify either `websockets` or `tcp`, default `tcp`

**Attributes**

Expand Down
15 changes: 10 additions & 5 deletions pyaarlo/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,17 +501,22 @@ def _mqtt_main(self):

# Create and set up the MQTT client.
self._event_client = mqtt.Client(
client_id=self._event_client_id, transport="websockets"
client_id=self._event_client_id, transport=self._arlo.cfg.mqtt_transport
)
self._event_client.on_log = self._mqtt_on_log
self._event_client.on_connect = self._mqtt_on_connect
self._event_client.on_message = self._mqtt_on_message
self._event_client.tls_set_context(ssl.create_default_context())
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = self._arlo.cfg.mqtt_hostname_check
self._event_client.tls_set_context(ssl_context)
self._event_client.username_pw_set(f"{self._user_id}", self._token)
self._event_client.ws_set_options(path=MQTT_PATH, headers=headers)
self.debug(f"mqtt: host={self._arlo.cfg.mqtt_host}, "
f"check={self._arlo.cfg.mqtt_hostname_check}, "
f"transport={self._arlo.cfg.mqtt_transport}")

# Connect.
self._event_client.connect(MQTT_HOST, port=443, keepalive=60)
self._event_client.connect(self._arlo.cfg.mqtt_host, port=443, keepalive=60)
self._event_client.loop_forever()

except Exception as e:
Expand Down Expand Up @@ -671,7 +676,7 @@ def _auth(self):
"Source": "arloCamWeb",
"User-Agent": self._user_agent,
"x-user-device-id": self._user_id,
"x-user-device-name": "QlJPV1NFUg==",
"x-user-device-automation-name": "QlJPV1NFUg==",
"x-user-device-type": "BROWSER",
}

Expand Down Expand Up @@ -822,7 +827,7 @@ def _validate(self):
"User-Agent": self._user_agent,
"Source": "arloCamWeb",
"x-user-device-id": self._user_id,
"x-user-device-name": "QlJPV1NFUg==",
"x-user-device-automation-name": "QlJPV1NFUg==",
"x-user-device-type": "BROWSER",
}

Expand Down
13 changes: 13 additions & 0 deletions pyaarlo/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .constant import (
DEFAULT_AUTH_HOST,
DEFAULT_HOST,
MQTT_HOST,
PRELOAD_DAYS,
TFA_CONSOLE_SOURCE,
TFA_DEFAULT_HOST,
Expand Down Expand Up @@ -59,6 +60,18 @@ def host(self):
def auth_host(self):
return self._kw.get("auth_host", DEFAULT_AUTH_HOST)

@property
def mqtt_host(self):
return self._kw.get("mqtt_host", MQTT_HOST)

@property
def mqtt_hostname_check(self):
return self._kw.get("mqtt_hostname_check", True)

@property
def mqtt_transport(self):
return self._kw.get("mqtt_transport", "tcp")

@property
def dump(self):
return self._kw.get("dump", False)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def readme():
'click',
'pycryptodome',
'unidecode',
'cloudscraper>=1.2.64',
'cloudscraper>=1.2.71',
'paho-mqtt',
'cryptography'
],
Expand Down