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

Mi Flora support #175

Merged
merged 17 commits into from
Apr 20, 2022
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
74 changes: 53 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
[![verified-by-homebridge](https://badgen.net/badge/homebridge/verified/purple)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)
[![npm](https://img.shields.io/npm/v/homebridge-mi-hygrothermograph.svg)](https://www.npmjs.com/package/homebridge-mi-hygrothermograph) ![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/hannseman/homebridge-mi-hygrothermograph/CI/master) [![Coveralls github](https://img.shields.io/coveralls/github/hannseman/homebridge-mi-hygrothermograph/master.svg)](https://coveralls.io/github/hannseman/homebridge-mi-hygrothermograph?branch=master)

[Homebridge](https://github.com/nfarina/homebridge) plugin for exposing measured temperature and humidity from Xiaomi sensors as [HomeKit](https://www.apple.com/ios/home/) accessories.
[Homebridge](https://github.com/nfarina/homebridge) plugin for exposing measured temperature, humidity and plant metrics from Xiaomi sensors as [HomeKit](https://www.apple.com/ios/home/) accessories.

Supported sensors:

* [Xiaomi Mi Bluetooth Temperature and Humidity Sensor / LYWSD02](https://www.xiaomistore.pk/mi-bluetooth-temperature-humidity-monitor.html) shown below.
* The [E-Ink sensor / CGG1](https://cleargrass.com/cg_temp_rh_monitor/overview)
* [E-Ink clock / LYWSD02MMC](https://item.mi.com/product/9542.html).
* The [Hygrothermograph 2 / LYWSD03MMC](https://in.c.mi.com/forum.php?mod=viewthread&tid=2047050) is supported but have encryption enabled. See the [Encryption](#encryption) for more details.
* The [Xiaomi HHCC Mi Flora Flower Care sensor](http://www.huahuacaocao.com/product)

![alt text](images/hygrothermograph.png "Xiaomi Mi Bluetooth Temperature and Humidity Sensor")

Expand Down Expand Up @@ -59,26 +60,33 @@ Update your Homebridge `config.json` file. See [config-sample.json](config-sampl
]
```

| Key | Default | Description |
|-------------------------|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `accessory` | | Mandatory. The name provided to Homebridge. Must be "Hygrotermograph". |
| `name` | | Mandatory. The name of this accessory. This will appear in your Home-app. |
| `address` | | Optional. The address of the device. Used when running multiple devices. |
| `timeout` | `15` | Time in minutes after last contact when the accessory should be regarded as unreachable. If set to `0`, timeout will be disabled. |
| `humidityName` | `"Humidity"` | Name of the humidity sensor as it will appear in your Home-app. |
| `temperatureName` | `"Temperature"` | Name of the temperature sensor as it will appear in your Home-app. |
| `fakeGatoEnabled` | `false` | If historical data should be reported to the Elgato Eve App. |
| `fakeGatoStoragePath` | | Optional. Custom path where to save fakegato history. |
| `fakeGatoOptions` | | Optional. Configuration options passed straight to fakegato-history. See the [documentation](https://github.com/simont77/fakegato-history#fakegato-history) for details about the options. |
| `mqtt` | | Optional. Configuration for publishing values to an MQTT-broker. See the [MQTT](#mqtt) section for details. |
| `forceDiscovering` | `true` | Retry start scanning for devices when stopped. For some users scanning will be stopped when connecting to other BLE devices. Setting `forceDiscovering` to `true` will start scanning again in these cases. |
| `forceDiscoveringDelay` | `2500` | The delay for when to start scanning again when stopped. Only applicable if `forceDiscovering` is `true`. |
| `updateInterval` | | By default values will be updated as they come in. Often this is once per second, if this is not desired `updateInterval` can be set to how often updates should be made. Accepts values in seconds. |
| `lowBattery` | `10` | At what battery percentage Homekit should start warning about low battery. |
| `disableBatteryLevel` | `false` | If battery level should not be exposed to Homekit. New E-Ink sensors do currently not support sending battery levels and setting this to `true` will make Elgato Eve not warn about it. |
| `temperatureOffset` | `0` | An offset to apply to temperature values for calibration if measured values are incorrect. |
| `humidityOffset` | `0` | An offset to apply to humidity values for calibration if measured values are incorrect. |
| `bindKey` | | A key which is used to decrypt data sent by sensors with encryption. |
| Key | Default | Description |
|-------------------------|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `accessory` | | Mandatory. The name provided to Homebridge. Must be "Hygrotermograph". |
| `type` | `"Hygrotermograph"` | Optional. The type of accessory. `"Hygrotermograph"` or `"MiFlora"` |
| `name` | | Mandatory. The name of this accessory. This will appear in your Home-app. |
| `address` | | Optional. The address of the device. Used when running multiple devices. |
| `timeout` | `15` | Time in minutes after last contact when the accessory should be regarded as unreachable. If set to `0`, timeout will be disabled. |
| `humidityName` | `"Humidity"` | Name of the humidity sensor as it will appear in your Home-app. Only for Hydrothermograph accessory `type`. |
| `temperatureName` | `"Temperature"` | Name of the temperature sensor as it will appear in your Home-app. |
| `moistureName` | `"Moisture"` | Name of the moisture sensor as it will appear in your Home-app. Only For MiFlora accessory `type`. |
| `fertilityName` | `"Fertility"` | Name of the fertility sensor as it will appear in your Home-app. Only for MiFlora accessory `type`. |
| `illuminanceName` | `"Illuminance"` | Name of the illuminance sensor as it will appear in your Home-app. Only for MiFlora accessory `type`. |
| `fakeGatoEnabled` | `false` | If historical data should be reported to the Elgato Eve App. |
| `fakeGatoStoragePath` | | Optional. Custom path where to save fakegato history. |
| `fakeGatoOptions` | | Optional. Configuration options passed straight to fakegato-history. See the [documentation](https://github.com/simont77/fakegato-history#fakegato-history) for details about the options. |
| `mqtt` | | Optional. Configuration for publishing values to an MQTT-broker. See the [MQTT](#mqtt) section for details. |
| `forceDiscovering` | `true` | Retry start scanning for devices when stopped. For some users scanning will be stopped when connecting to other BLE devices. Setting `forceDiscovering` to `true` will start scanning again in these cases. |
| `forceDiscoveringDelay` | `2500` | The delay for when to start scanning again when stopped. Only applicable if `forceDiscovering` is `true`. |
| `updateInterval` | | By default values will be updated as they come in. Often this is once per second, if this is not desired `updateInterval` can be set to how often updates should be made. Accepts values in seconds. |
| `lowBattery` | `10` | At what battery percentage Homekit should start warning about low battery. |
| `disableBatteryLevel` | `false` | If battery level should not be exposed to Homekit. New E-Ink sensors do currently not support sending battery levels and setting this to `true` will make Elgato Eve not warn about it. |
| `temperatureOffset` | `0` | An offset to apply to temperature values for calibration if measured values are incorrect. |
| `humidityOffset` | `0` | An offset to apply to humidity values for calibration if measured values are incorrect. Only for Hydrothermograph accessory `type`. |
| `moistureOffset` | `0` | An offset to apply to moisture values for calibration if measured values are incorrect. Only for MiFlora accessory `type`. |
| `fertilityOffset` | `0` | An offset to apply to fertility values for calibration if measured values are incorrect. Only for MiFlora accessory `type`. |
| `illuminanceOffset` | `0` | An offset to apply to illuminance values for calibration if measured values are incorrect. Only for MiFlora accessory `type`. |
| `bindKey` | | A key which is used to decrypt data sent by sensors with encryption. |


### Multiple sensors
Expand All @@ -103,6 +111,12 @@ Update your Homebridge `config.json` and specify the `address` key:
"accessory": "Hygrotermograph",
"name": "Room 2",
"address": "2c:34:b3:d4:a1:61"
},
{
"accessory": "Hygrotermograph",
"type": "MiFlora",
"name": "Garden",
"address": "2f:34:b5:d4:a2:20"
}
]
```
Expand Down Expand Up @@ -193,6 +207,21 @@ Basic configuration:
}
```

Basic configuration for Mi Flora:

```json
{
"mqtt": {
"url": "mqtt://test.mosquitto.org",
"temperatureTopic": "sensors/temperature",
"moistureTopic": "sensors/moisture",
"fertilityTopic": "sensors/fertility",
"illuminanceTopic": "sensors/illuminance",
"batteryTopic": "sensors/battery"
}
}
```

If one is interested in only publishing a specific value just skip configuring the topics wished to ignore:

```json
Expand Down Expand Up @@ -287,6 +316,9 @@ Some hardware combinations are problematic and may cause weird troubles like sen
* Asus BT-400 bluetooth dongle (at least in combination with older RPi 2B)
* Raspbian Stretch is known to get recurring timeouts with certain RPi-models. Upgrade to Buster or newer and if not possible one can mitigate this by triggering a `hcitool lescan`. Automate this by adding the following to your crontab file: `0 * * * * sudo timeout -s INT 1s hcitool lescan`.

## Mi Flora Fertility level notice
Soil Fertility measures in `μS/cm`. Plugin will expose it as a separate [Light sensor](https://developers.homebridge.io/#/service/LightSensor) and show `lux` instead, due to lack of suitable Characteristic types in HomeKit.

## Legal

*Xiaomi* and *Mi* are registered trademarks of BEIJING XIAOMI TECHNOLOGY CO., LTD.
Expand Down
15 changes: 14 additions & 1 deletion config-sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,29 @@
"port": 51826,
"pin": "031-45-154"
},
"description": "This is an example configuration file with one Hygrotermograph accessory. You can use this as a template for creating your own configuration file containing devices you actually own.",
"description": "This is an example configuration file with one Hygrotermograph accessory and one MiFlora accessory. You can use this as a template for creating your own configuration file containing devices you actually own.",
"accessories": [
{
"accessory": "Hygrotermograph",
"type": "Hygrotermograph",
"name": "Temperature & Humidity",
"address": "4c:64:a8:d0:ae:65",
"timeout": 15,
"temperatureName": "Temperature",
"humidityName": "Humidity",
"fakeGatoEnabled": true
},
{
"accessory": "Hygrotermograph",
"type": "MiFlora",
"name": "Zamioculcas",
"address": "cd:ef:4b:62:69:99",
"timeout": 15,
"temperatureName": "Temperature",
"moistureName": "Moisture",
"fertilityName": "Fertility",
"illuminanceName": "Plant light",
"fakeGatoEnabled": true
}
]
}
Loading