Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shift SimpliSafe integration (alarm and lock) to websocket #31029

Closed
2 tasks done
bachya opened this issue Jan 20, 2020 · 3 comments
Closed
2 tasks done

Shift SimpliSafe integration (alarm and lock) to websocket #31029

bachya opened this issue Jan 20, 2020 · 3 comments

Comments

@bachya
Copy link
Contributor

bachya commented Jan 20, 2020

simplisafe-python recently gained the ability to talk to SimpliSafe's cloud-based websocket. I want to shift the HASS SimpliSafe integration over to using it.

This appears very straightforward re: alarm_control_panels. The question is with locks: since I don't own one, I'm not sure whether their state updates are communicated over the websocket. So, it may be necessary to keep the REST API around to manage them.

Keeping this issue to manage the work:

  1. Convert the alarm_control_panel to use the websocket.
  2. Pending feedback from a user who has one, convert the lock to use the websocket.

(2) is where I could use feedback/help from any user who has a SimpliSafe lock.

@bachya
Copy link
Contributor Author

bachya commented Jan 21, 2020

Posting some notes as I think of them.

The SimpliSafe websocket returns payloads that look like this: https://simplisafe-python.readthedocs.io/en/latest/websocket.html#response-format:

{
  "eventId": 1231231231,
  "eventTimestamp": 1231231231,
  "eventCid": 1231,
  "zoneCid": "3",
  "sensorType": 0,
  "sensorSerial": "",
  "account": "xxxxxxxx",
  "userId": 123123,
  "sid": 123123,
  "info": "System Armed (Home) by Remote Management",
  "pinName": "",
  "sensorName": "",
  "messageSubject": "SimpliSafe System Armed (home mode)",
  "messageBody": "System Armed (home mode)",
  "eventType": "activity",
  "timezone": 2,
  "locationOffset": -420,
  "videoStartedBy": "",
  "video": {}
}

State changes for alarm control panels (and locks, we think) can be covered by the messageSubject field. However, many of the attributes used (gsm_strength, rf_jamming, etc.) don't seem to come through the websocket. This indicates to me that a solution using the websocket will still require regular polling of the REST API, too (to get updated attribute values).

So, since a websocket solution still requires the REST API, the question is, "What do we gain by adding the websocket?" Initial thoughts:

Pros

  • Near-realtime updates to state value
  • "Resolves" the use case of altering system from keypad/SimpliSafe website/etc. and not having to wait for a polling interval to see those updates in HASS
  • Lay the foundation for a hopeful future state where the websocket carries more data

Cons

  • Complexity – can't pick one or the other

Things to Consider

  • In addition to regular polling, should the REST API be queried again (in part or full) each time the websocket communicates a state change?

@bachya
Copy link
Contributor Author

bachya commented Jan 27, 2020

Now that #31060 has been merged, SimpliSafe no longer goes straight to an Armed state when arming the system; instead, it goes to Arming immediately, then to Armed when the next polling cycle sees data that implies a fully armed state. Depending on how long the Arming state is configured to last within SimpliSafe, it could be quite some time before HASS shows an Armed state. Therefore, I think it's critical to insert websocket functionality for the alarm's state.

@bachya
Copy link
Contributor Author

bachya commented Feb 4, 2020

We have a draft PR in place: #31424

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant