Skip to content

Unofficial bridge between SmartRent and an MQTT broker

Notifications You must be signed in to change notification settings

robert-friedland/SmartRent-MQTT-Bridge

 
 

Repository files navigation

This software is provided for free to do whatever you want with, I make no guarantees about it but it has worked well for me for the past few months. I had SmartRent devices installed in my apartment but SmartRent does not provide any sort of API for residents to use, so I made my own solution to integrate their devices with Home Assistant. It's pretty hacky, but it works!

How it Works:

When the container starts, a Chrome is launched as a Selenium driver and navigates to the SmartRent login page, logs you in, then navigates to the home control page. Chrome is configured to proxy the connection through mitmproxy with the smartrent-bridge.py script set to manipulate the WebSocket connection. smartrent-bridge.py will translate MQTT publications to WebSocket messages and vice-versa.

How to use it:

The easiest way to run this is with Docker: docker build . -t smartrent-mqtt-bridge docker run --env-file --restart always smartrent.env -it smartrent-mqtt-bridge

Occasionally, the connection to Smartrent times out. This is configured with a health check, and running it in a swarm will take advantage of the health check to restart when necessary. docker service create --name=smartrent-mqtt-bridge --env-file smartrent.env smartrent-mqtt-bridge

Configure your Devices:

I found my device IDs by watching the messages in the logs as I interacted with each device (either physically or via the SmartRent app/web). In Chrome, open the Network tab and click on the websocket? request. The channel ID will be the first value in the array of the request.

Set these Environment Variables in smartrent.env:

Variable Example Purpose
SMARTRENT_EMAIL user@example.com Used to automatically log into your SmartRent account with Selenium
SMARTRENT_PASSWORD aS$ecureP4ssw0rd ^
DEVICES {"devId": ["friendly name", "device_mqtt_topic", "device type", "channel"]} Monitors and updates those Smartrent devices
MQTT_HOST mqtt.example.com IP/Hostname of your MQTT Broker
MQTT_PORT 8883 MQTT broker defaults are 1883 and 8883 for TLS
MQTT_TLS True Whether communication with MQTT Broker should be encrypted
MQTT_USER mqtt_user MQTT Username
MQTT_PASS example_pass MQTT Password
MQTT_TOPIC_PREFIX smartrent Prefix for all MQTT topics

MQTT Topics

<device_mqtt_topic> is determined by the devices variable configuration.

Thermostat Topics

MQTT Topic Purpose Values
<MQTT_TOPIC_PREFIX>/<device_mqtt_topic>/target The current target temperature Integer
<MQTT_TOPIC_PREFIX>/<device_mqtt_topic>/target/set Set the the desired target temperature Integer
<MQTT_TOPIC_PREFIX>/<device_mqtt_topic>/current The current actual temperature Integer
<MQTT_TOPIC_PREFIX>/<device_mqtt_topic>/mode The curent operation mode "off","heat"
<MQTT_TOPIC_PREFIX>/<device_mqtt_topic>/mode/set Set the desired operation mode "off","heat"

Lock Topics

MQTT Topic Purpose Values
<MQTT_TOPIC_PREFIX>/<device_mqtt_topic>/status The current state of the lock "locked","unlocked"
<MQTT_TOPIC_PREFIX>/<device_mqtt_topic>/set Set whether the door should be lock "true"
<MQTT_TOPIC_PREFIX>/<device_mqtt_topic>/detail Details about the last lock interaction String

More on SmartRent's System

Websocket Message Formats

A list of the important WebSocket messages exchanged between the web client and SmartRent's service can be found here (WIP)

The Hub

The hub provided by SmartRent is a device made by Zipato called the ZipaMicro. This hub connects to all of the devices over Z-Wave local RF, and connects them to ZipaMicro's cloud-services, which then are called by SmartRent's service. The hub comes with a USB LTE dongle to keep it connected if you decide not to connect it to your LAN.

On the LAN interface, the hub has a Dropbear SSH server listening on port 22, and a REST API on port 8080. I'm not sure what ports are open over the LTE connection.

Hub Exterior Hub Interior Hub Ports Hub Bottom

The Lock

The lock that was installed on my door is made by Yale. It has a touch-panel keypad and no physical key. The lock reports the USER_ID associated with the PIN used to unlock the door, the current state of the lock, and the method used to lock/unlock the door (keypad, network, thumbturn, inside/outside). From this it is easy to infer the arrival/departure times of residents.

Lock Outside Lock Inside

About

Unofficial bridge between SmartRent and an MQTT broker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 83.3%
  • Dockerfile 9.1%
  • Shell 7.6%