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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- [Device Types](#device-type)
- [UUID Update Notes](#uuid-update-notes)
- [Air Purifier BLE open API](/devicetypes/airpurifier.md)
- [Art Frame 2 and E Ink Photo Magnet BLE open API](/devicetypes/artframe2.md)
- [Blind Tilt BLE open API](/devicetypes/blindtilt.md)
- [Bot BLE open API](/devicetypes/bot.md)
- [Color Bulb BLE open API](/devicetypes/colorbulb.md)
Expand Down Expand Up @@ -82,9 +83,11 @@ byte. Most products have a `0x00…` and a `0x01…` form. These are the Product
| Device Type | Product ID |
|----------------------------|------------|
| Art Frame | 0x00113e10, 0x01113e10 |
| Art Frame 2 | 0x0011f1c0, 0x0111f1c0 |
| Candle Warmer Lamp | 0x001122b8, 0x011122b8 |
| Circulator Fan Pro | 0x0011b340, 0x0111b340 |
| Climate Panel | 0x0010f3d8, 0x0110f3d8 |
| E Ink Photo Magnet | 0x001295d0, 0x011295d0 |
| Floor Lamp | 0x0010d0b0, 0x0110d0b0 |
| Hub3 | 0x0010b940, 0x0110b940 |
| Hub4 | 0x00128248, 0x01128248 |
Expand Down
88 changes: 88 additions & 0 deletions devicetypes/artframe2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Art Frame 2 and E Ink Photo Magnet BLE open API

Art Frame 2 (Product ID `0x0011f1c0` / `0x0111f1c0`) and E Ink Photo Magnet (Product ID
`0x001295d0` / `0x011295d0`) share one protocol. They have no single-byte Device Type; see
[Device Types](../README.md#device-types) for how Product IDs are read. This is what
[pySwitchbot](https://github.com/sblibs/pySwitchbot) implements (`switchbot/adv_parsers/image_frame.py`,
`switchbot/devices/art_frame2.py`). It does not cover the original Art Frame.

## Broadcast Message

### Manufacturer Data

Byte offsets count from the start of the manufacturer data payload, after the 2-byte company ID
`0x0969`.

<table>
<thead>
<tr><th>Byte</th><th>Field</th><th>Value</th></tr>
</thead>
<tbody>
<tr><td>0~5</td><td>MAC Address</td><td>Device MAC address</td></tr>
<tr><td>6</td><td>Sequence Number</td><td>Increases when the broadcast data is updated</td></tr>
<tr><td>7</td><td>Battery</td><td>bit7: charging<br>bit6-0: battery 0~100%</td></tr>
<tr><td>8~9</td><td>Image ID</td><td>ID of the image on screen, little-endian</td></tr>
<tr><td>10</td><td>Display</td><td>bit7-4: display size<br>bit3: display mode<br>bit2: last network status<br>bit1: orientation</td></tr>
</tbody>
</table>

## Commands

Both products use an encrypted connection: commands are sent with the account's key ID and
encryption key, as implemented by `SwitchbotEncryptedDevice` in pySwitchbot. The commands below are
shown before encryption. A response status (Byte 0) of `0x01` means OK.

<table>
<thead>
<tr><th>Command</th><th>Bytes</th></tr>
</thead>
<tbody>
<tr><td>Get basic info</td><td><code>0x5702</code></td></tr>
<tr><td>Next image</td><td><code>0x570f7a0701</code></td></tr>
<tr><td>Previous image</td><td><code>0x570f7a0700</code></td></tr>
<tr><td>Show image</td><td><code>0x570f7a02</code> + image ID (2 bytes, little-endian)</td></tr>
<tr><td>Read image list</td><td><code>0x570f7b07</code> + packet number (1 byte, from <code>0x00</code>)</td></tr>
</tbody>
</table>

### Basic info

<table>
<thead>
<tr><th>Byte</th><th>Field</th><th>Value</th></tr>
</thead>
<tbody>
<tr><td>0</td><td>Status</td><td><code>0x01</code> OK</td></tr>
<tr><td>1</td><td>Battery</td><td>bit7: charging<br>bit6-0: battery 0~100%</td></tr>
<tr><td>2</td><td>Firmware</td><td>Firmware version × 10</td></tr>
<tr><td>3</td><td>Hardware</td><td>Hardware version</td></tr>
<tr><td>4</td><td>Display</td><td>bit7-4: display size<br>bit3: display mode<br>bit2: last network status</td></tr>
<tr><td>5~6</td><td>Current image ID</td><td>Little-endian</td></tr>
<tr><td>7~8</td><td>Number of images</td><td>Little-endian</td></tr>
<tr><td>9</td><td>Orientation</td><td>Orientation</td></tr>
</tbody>
</table>

### Image list

The stored images are a bitmap sent over one or more packets. Read packet `0x00` first, then each
following packet until the total reported in Byte 1. Each response is:

<table>
<thead>
<tr><th>Byte</th><th>Field</th><th>Value</th></tr>
</thead>
<tbody>
<tr><td>0</td><td>Status</td><td><code>0x01</code> OK</td></tr>
<tr><td>1</td><td>Total packets</td><td>Number of packets in the bitmap (at least 1)</td></tr>
<tr><td>2</td><td>Packet number</td><td>Same as the requested packet number</td></tr>
<tr><td>3~</td><td>Bitmap</td><td>Next bytes of the image bitmap</td></tr>
</tbody>
</table>

Join the bitmap bytes of all packets in order. Bit `b` (bit0 first) of bitmap byte `i` set means
image ID `i × 8 + b + 1` is stored. pySwitchbot rejects a bitmap longer than 2560 bytes. The
image IDs in this list are the values the Show image command takes.

### Back to [Home](https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/)
### Back to [Device Types](../README.md)
20 changes: 18 additions & 2 deletions devicetypes/lock.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ start of the manufacturer data payload, after the 2-byte company ID `0x0969`. Th
<tr><td>6</td><td>Sequence Number</td><td>Increases when the broadcast data is updated</td></tr>
<tr><td>7</td><td>Lock Info</td><td>bit7: calibrated (0 no, 1 yes)<br>bit6-3: lock status (see <a href="#lock-status">Lock status</a>)<br>bit2-0: reserved</td></tr>
<tr><td>8</td><td>Door Info</td><td>bit7-6: update from secondary lock<br>bit5: door open, reported by the secondary lock<br>bit4: door open (0 closed, 1 open)<br>bit3: automatic locking paused<br>bit2-0: reserved</td></tr>
<tr><td>9</td><td>Battery</td><td>bit7: reserved<br>bit6-0: battery 0~100%</td></tr>
<tr><td>9</td><td>Battery</td><td>bit7: charging (Lock Pro only; reserved on the others)<br>bit6-0: battery 0~100%</td></tr>
<tr><td>10</td><td>Double Lock</td><td>bit7: double lock mode<br>bit6: this is the secondary lock<br>bit5: manual unlock linkage<br>bit4-0: reserved</td></tr>
<tr><td>11</td><td>Alarms</td><td>bit7: unclosed door alarm<br>bit6: unlocked alarm<br><b>Lock Pro / Lock Pro WiFi:</b> bit5: low temperature alarm, bit2: left battery compartment alarm, bit1: right battery compartment alarm<br><b>Lock Ultra / Ultra Max / UWB Lock / Vision Pro:</b> bit4: power alarm, bit2-0: battery status</td></tr>
<tr><td>11</td><td>Alarms</td><td>bit7: unclosed door alarm<br>bit6: unlocked alarm<br><b>Lock Pro:</b> bit5: low temperature alarm, bit4: power alarm, bit3: door magnet alarm, bit2: left battery compartment alarm, bit1: right battery compartment alarm<br><b>Lock Pro WiFi:</b> bit5: low temperature alarm, bit2: left battery compartment alarm, bit1: right battery compartment alarm<br><b>Lock Ultra / Ultra Max / UWB Lock / Vision Pro:</b> bit4: power alarm, bit2-0: battery status</td></tr>
</tbody>
</table>

Expand Down Expand Up @@ -128,6 +128,22 @@ The lock info and enable-notification commands end with a model byte:
| Lock Vision, Lock Vision Pro | `0x570f4f8102` | `0x570e01001e00008102` |
| Lock Pro WiFi | `0x570f4f810a` | `0x570e01001e0000810a` |

### Lock Pro battery bays

The Lock Pro reads the level of each of its two battery bays with `0x570f4f0409` (pySwitchbot
implements it for the Lock Pro only). The response is:

<table>
<thead>
<tr><th>Byte</th><th>Field</th><th>Value</th></tr>
</thead>
<tbody>
<tr><td>0</td><td>Status</td><td><code>0x01</code> OK, <code>0x06</code> OK with a low battery</td></tr>
<tr><td>1</td><td>Left bay</td><td>bit7: battery present (0 empty bay)<br>bit6-0: battery 0~100%</td></tr>
<tr><td>2</td><td>Right bay</td><td>bit7: battery present (0 empty bay)<br>bit6-0: battery 0~100%</td></tr>
</tbody>
</table>

### Lock info data

The lock info response (after the status byte) and status notifications carry the same lock info
Expand Down
168 changes: 168 additions & 0 deletions devicetypes/meter.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,174 @@ the Service Data. Byte offsets count from the start of the manufacturer data pay

The battery is read from Service Data Byte 2 (bit6-0).

## Meter Pro and Meter Pro CO2 Settings

Meter Pro (`4`) and Meter Pro CO2 (`5`) settings are read with `0x570f69…` commands and written
with `0x570f68…` commands, unencrypted. Byte 0 of every response is the status; `0x01` means OK.
This is what [pySwitchbot](https://github.com/sblibs/pySwitchbot) implements
(`switchbot/devices/meter_pro.py`). Multi-byte numbers are big-endian unless noted.

Temperatures use the same encoding as [0x31](#0x31-read-the-display-mode-and-value-of-the-meter):
an integer byte with bit7 set for a positive value (bit6-0: integer part, °C) and a separate 0~9
tenths value.

### Weather

The weather shown on the screen when a zone's source is Network.

| Command | Bytes |
| ------- | ----- |
| Read weather | `0x570f6906` |
| Write weather | `0x570f680601` + icon + response Bytes 2~4 |

<table>
<thead>
<tr><th>Byte</th><th>Field</th><th>Value</th></tr>
</thead>
<tbody>
<tr><td>1</td><td>Icon</td><td>0 none, 1 sunny, 2 cloudy, 3 overcast, 4 light rain, 5 heavy rain, 6 light snow, 7 heavy snow</td></tr>
<tr><td>2</td><td>Temperature decimal</td><td>bit3-0: tenths 0~9</td></tr>
<tr><td>3</td><td>Temperature</td><td>bit7: sign (1 positive, 0 negative)<br>bit6-0: integer part, °C</td></tr>
<tr><td>4</td><td>Humidity</td><td>bit7: temperature shown in °F<br>bit6-0: humidity 1~99%, 0 when not set</td></tr>
</tbody>
</table>

pySwitchbot reads the weather first and keeps the bits it does not change (Byte 2 bit7-4, Byte 4
bit7) in the write.

### Calibration

| Command | Bytes |
| ------- | ----- |
| Read calibration | `0x570f6903` |
| Write calibration | `0x570f6803` + Bytes 1~3 below |

<table>
<thead>
<tr><th>Byte</th><th>Field</th><th>Value</th></tr>
</thead>
<tbody>
<tr><td>1</td><td>Temperature correction</td><td>bit7: sign (1 positive, 0 negative)<br>bit6-0: integer part, °C</td></tr>
<tr><td>2</td><td>Humidity correction</td><td>bit7: sign (1 positive, 0 negative)<br>bit6-0: 0~99 %RH</td></tr>
<tr><td>3</td><td>Temperature correction decimal</td><td>bit3-0: tenths 0~9</td></tr>
</tbody>
</table>

A zero correction is read back with the sign bit cleared.

### Display

| Command | Bytes |
| ------- | ----- |
| Read display settings | `0x570f690701` |
| Set a zone | `0x570f680701` + zone (`0x01` middle, `0x02` bottom) + icon (`0xFF` keeps it) + source + source MAC (6 bytes) |
| Set zone icons | `0x570f68070103` + middle icon + bottom icon (`0x0F` keeps an icon) |
| Set data update interval | `0x570f68070105` + seconds (2 bytes); the app offers 300, 600 and 1800 |
| Set date format | `0x570f68070107` + `0x00` month/day or `0x01` day/month |
| Set battery icon | `0x570f68070108` + `0x00` only when low or `0x01` always |
| Set temperature unit | `0x570f68070109` + `0x00` °C or `0x01` °F |
| Read button functions | `0x570f690704` |
| Set button functions | `0x570f68070106` + unit switch + source switch (`0xFF` keeps a function) |

Zone icon: `1` indoor, `2` outdoor. Zone source: `0` none, `1` Meter, `2` Meter Plus, `3`
Indoor/Outdoor Thermo-Hygrometer, `4` Hub 2 or Hub Mini Matter, `5` Meter Pro (this device when
the MAC is all zeros), `6` Network (the [weather](#weather) values), `8` Weather Station, `9` Hub 3.
The MAC is all zeros for none, Network and this device. The screen applies a new zone at the next
data update.

Display settings response:

<table>
<thead>
<tr><th>Byte</th><th>Field</th><th>Value</th></tr>
</thead>
<tbody>
<tr><td>1</td><td>Zone icons</td><td>bit7-4: middle<br>bit3-0: bottom</td></tr>
<tr><td>2</td><td>Zone sources</td><td>bit7-4: middle<br>bit3-0: bottom</td></tr>
<tr><td>3~8</td><td>Middle source MAC</td><td>All zeros when none</td></tr>
<tr><td>9~14</td><td>Bottom source MAC</td><td>All zeros when none</td></tr>
<tr><td>15~16</td><td>Data update interval</td><td>Seconds</td></tr>
<tr><td>17</td><td>Date format</td><td><code>0x00</code> month/day, <code>0x01</code> day/month</td></tr>
<tr><td>18</td><td>Reserved</td><td></td></tr>
<tr><td>19</td><td>Battery icon</td><td><code>0x00</code> only when low, <code>0x01</code> always</td></tr>
</tbody>
</table>

pySwitchbot treats Bytes 15~19 as optional (a shorter response leaves them unset).

Button functions (read response Bytes 1~2, and the write): unit switch `0x00` allowed, `0x01`
not allowed; source switch `0x01` allowed, `0x00` not allowed.

### Comfort level and temperature/humidity alarm

| Command | Bytes |
| ------- | ----- |
| Read comfort level | `0x570f69020101` |
| Read temperature/humidity alarm | `0x570f69020100` |
| Write comfort level | `0x570f680201` + `0x88` (custom) or `0x80` (default) + limits |
| Write temperature/humidity alarm | `0x570f680201` + alarm conditions (bit7 clear) + limits |
| Read alarm mode and volume | `0x570f690204` |
| Write alarm mode and volume | `0x570f680204` + volume (`0xFF` keeps it) + mode |

Both reads return Byte 1 (comfort: `0x00` default, `0x01` custom; alarm: conditions), the limits
in Bytes 2~6, and a status in Byte 7. The limits are:

<table>
<thead>
<tr><th>Limits byte</th><th>Field</th><th>Value</th></tr>
</thead>
<tbody>
<tr><td>0</td><td>High temperature</td><td>bit7: sign (1 positive)<br>bit6-0: integer part, °C</td></tr>
<tr><td>1</td><td>High humidity</td><td>bit6-0: 0~99%</td></tr>
<tr><td>2</td><td>Temperature decimals</td><td>bit7-4: high temperature tenths<br>bit3-0: low temperature tenths</td></tr>
<tr><td>3</td><td>Low temperature</td><td>bit7: sign (1 positive)<br>bit6-0: integer part, °C</td></tr>
<tr><td>4</td><td>Low humidity</td><td>bit6-0: 0~99%</td></tr>
</tbody>
</table>

Alarm conditions (bit flags): `0x01` temperature low, `0x02` temperature high, `0x04` temperature
in range, `0x10` humidity low, `0x20` humidity high, `0x40` humidity in range.

Byte 7 of the comfort response, bit1-0: `0` comfortable, `1` dry, `2` wet, `3` unavailable. Byte 7
of the alarm response: bit5-4 temperature alarm, bit1-0 humidity alarm, each `0` none, `1` low,
`2` high, `3` in range.

Alarm mode and volume response: Byte 1 volume (`1` off, `2` low, `3` medium, `4` high), Byte 2
mode (`0` disabled, `1` flash only, `2` sound and flash).

### CO2 (Meter Pro CO2 only)

| Command | Bytes |
| ------- | ----- |
| Take a CO2 sample now | `0x570f680b04` |
| Start CO2 calibration | `0x570f680b02` |
| Read USB power state | `0x570f690b02` (Byte 1: `0x01` USB-C power connected, `0x00` not) |
| Read USB-powered update interval | `0x570f690b03` (Bytes 1~2: seconds) |
| Write USB-powered update interval | `0x570f680b01` + seconds (2 bytes, 1~65535) |
| Read battery-powered update interval | `0x570f690b04` (Bytes 1~2: seconds) |
| Write battery-powered update interval | `0x570f680b06` + seconds (2 bytes, 1~65535) |
| Read CO2 alarm | `0x570f69020301` |
| Write CO2 alarm | `0x570f68020301` + Bytes 1~5 below |
| Read CO2 level thresholds | `0x570f69020302` (Bytes 1~2: green-to-yellow ppm, Bytes 3~4: yellow-to-red ppm) |
| Write CO2 level thresholds | `0x570f68020302` + green-to-yellow ppm (2 bytes) + yellow-to-red ppm (2 bytes), in 100 ppm steps |

Before calibrating, place the meter outdoors in a well-ventilated area for one minute, and keep it
still during the five-minute calibration.

CO2 alarm response:

<table>
<thead>
<tr><th>Byte</th><th>Field</th><th>Value</th></tr>
</thead>
<tbody>
<tr><td>1</td><td>Conditions</td><td>Bit flags: <code>0x01</code> low, <code>0x02</code> high, <code>0x04</code> in range, <code>0x08</code> custom setting</td></tr>
<tr><td>2~3</td><td>High limit</td><td>ppm</td></tr>
<tr><td>4~5</td><td>Low limit</td><td>ppm</td></tr>
<tr><td>6</td><td>Status</td><td>bit1-0: <code>0</code> none, <code>1</code> low, <code>2</code> high, <code>3</code> in range</td></tr>
</tbody>
</table>

### Other

This section is for devices that don't quite fit the general
Expand Down