Skip to content

Commit

Permalink
Upload files
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernst79 authored Nov 25, 2019
1 parent 2336d83 commit 3513b4b
Show file tree
Hide file tree
Showing 7 changed files with 615 additions and 0 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Xiaomi Mi Temperature and Humidity Monitor (BLE) sensor platform
This custom component is an alternative for the standard build in [mitemp_bt](https://www.home-assistant.io/integrations/mitemp_bt/) integration that is available in Home Assistant. Unlike the original `mitemp_bt` integration, which is getting its data by polling the device with a default five-minute interval, this custom component is parsing the Bluetooth Low Energy packets payload that is emitted each second by the sensor. The packets payload contains temperature/humidity and battery data. Advantage of this integration is that it doesn't affect the battery as much as the built-in integration. It also solves connection issues some people have with the standard integration.

![sensor](/sensor.jpg)

## HOW TO INSTALL
**1. Install bluez-hcidump**
- The package `bluez-hcidump` needs to be installed first. `bluez-hcidump` reads raw the data coming from and going to your Bluetooth device. You can install it with the following command
```shell
sudo apt-get install bluez-hcidump
```

**2. Allow hcitool and hcidump to run without root access:**
- This custom component uses a hcitool and hcidump commands to receive the data. Run the following commands to allow hcitool and hcidump to run without root access:
```shell
sudo setcap 'cap_net_raw+ep' `readlink -f \`which hcidump\``
sudo setcap 'cap_net_raw+ep' `readlink -f \`which hcitool\``
```
**3. Install the custom component:**
- The easiest way is to install it with [HACS](https://hacs.netlify.com/). First install [HACS](https://hacs.netlify.com/) if you don't have it yet. After installation you can find this custom component in the HACS store under integrations.
Alternatively, you can install it manually. Just copy paste the content of the `sensor.mitemp_bt/custom_components` folder in your `config/custom_components` directory.
As example you will get the `sensor.py` file in the following path: `/config/custom_components/mitemp_bt/sensor.py`.
**4. Restart Home Assistant:**
- A restart is required to unload the build in component and load the custom component. Do this before step 5, as Home Assistant will otherwise complain that your configuration is not ok (as it still uses the build in `mitemp_bt` integration), and won't restart when hitting restart in the server management menu.


**5. Add the platform to your configuration.yaml file (see [below](#CONFIGURATION))**


**6. Restart Home Assistant again:**
- A second restart is required to load the component. After a few minutes, the sensors should be added to your home-assistant automatically.


## CONFIGURATION
Add the following to your `configuration.yaml` file.

```yaml
sensor:
- platform: mitemp_bt
```

IMPORTANT. If you used the standard Home Assistant built ['mitemp_bt'](https://www.home-assistant.io/integrations/mitemp_bt/) integration, make sure you delete the additional parameters, like `mac:` and `monitored_conditions:`.

## Credits
Credits and a big thanks should be given to [@tsymbaliuk](https://community.home-assistant.io/u/tsymbaliuk) and [@Magalex](https://community.home-assistant.io/u/Magalex). The main python code for this component was originally developed by [@tsymbaliuk](https://community.home-assistant.io/u/tsymbaliuk) and later modified by [@Magalex](https://community.home-assistant.io/u/Magalex).
1 change: 1 addition & 0 deletions custom_components/mitemp_bt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Xiaomi Mi temperature and humidity monitor integration."""
11 changes: 11 additions & 0 deletions custom_components/mitemp_bt/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"domain": "mitemp_bt",
"name": "Xiaomi Mi temperature and humidity monitor",
"documentation": "https://www.home-assistant.io/integrations/mitemp_bt",
"requirements": [],
"dependencies": [],
"codeowners": [
"@Ernst79",
"@Magalex2x14"
]
}
Loading

0 comments on commit 3513b4b

Please sign in to comment.