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

Support of "Xiaomi Mijia Temperature and Humidity Sensor" #74

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

aqualx
Copy link
Contributor

@aqualx aqualx commented Feb 7, 2019

What's new:

  • Added support of "Xiaomi Mijia Temperature and Humidity Sensor"

Solution tested in Debian Stretch with python 3.5 (stable).

Notes:

  • Configuration file config.ini changed.
  • Added handling of exceptions 'BTLEException, RuntimeError, BrokenPipeError" as they sometimes raises from calling Bluetooth wrappers. Maybe this is due to Python 3.5. Anyway they can appear only several times a day and script doesn't fail on next retry.

aqualx and others added 17 commits January 14, 2019 00:40
Added information about Xiaomi Mijia Temperature and Humidity Sensor
* switched library 'Mijia Bluetooth Temperature Smart Humidity' from mitemp_bt to mithermometer
* fixed schema generation for openHAB
* set 'retain=True' for mqtt messages for homeassistant-mqtt
* other minor fixes
Hey, thanks for your great work - I have started using this branch and I very much like it.
However I would like propose update of config.ini.dist:

In config.ini.dist there is the following information:

# The MQTT base topic to publish all Mi Flora sensor data topics under.
# Default depends on the configured reporting_method
#base_topic = miflora                   # Default for: mqtt-json, mqtt-smarthome
#base_topic = homie                     # Default for: mqtt-homie
#base_topic = homeassistant             # Default for: homeassistant-mqtt
#base_topic = v1/devices/me/telemetry   # Default for: thingsboard-json
#base_topic =                           # Default for: wirenboard-mqtt

So as log as I use mqtt-json the default toppic should be miflora.

While the default toppic is no longer **miflora** but **misensor** - what makes total sense cause we no longer use only miflora sensors - also it was already implemented in miflora-mqtt-daemon.py:

if reporting_mode == 'mqtt-homie':
    default_base_topic = 'homie'
elif reporting_mode == 'homeassistant-mqtt':
    default_base_topic = 'homeassistant'
elif reporting_mode == 'thingsboard-json':
    default_base_topic = 'v1/devices/me/telemetry'
elif reporting_mode == 'wirenboard-mqtt':
    default_base_topic = ''
else:
    default_base_topic = 'misensor'

Hope you dont mind my changes
Fixing default base_topic to misensor based on implementation
@igorbljahhin
Copy link

I use these changes since this spring and I had no issues. Could this pull request be merged into the master?

@ThomDietrich
Copy link
Owner

Hey guys! This is a cool but also big PR. I did not yet get around to review it... but if the addition works for you guys, there is no need to wait any further. @aqualx could you please point me to the 1-2 areas of the change that I might be interested to review, as they change existing functionality or might become an issue later? Thanks

@CWempe
Copy link

CWempe commented Sep 25, 2019

@aqualx
You might want to update the PR to include the last three commits from your master branch.

Especially the new OUIs (MAC prefixes) are important for users with new devices.
aqualx@7fe9e78

@CWempe
Copy link

CWempe commented Jan 27, 2020

Any update on This?

It would be great is this could be merged so the users of this devices can use this maim project and don't have to use the other fork.

@ThomDietrich
Copy link
Owner

ThomDietrich commented Jan 27, 2020

Hey @CWempe and @aqualx, I had big plans to further improve this daemon! Sadly I didn't have much time the last couple of months. I'm definitely willing to apply these changes. @CWempe if I resolved the conflicts in this PR and provided a merge-ready state, would you be able to test with both devices?

@CWempe
Copy link

CWempe commented Jan 27, 2020

I could test the Temp/Humidity device.
But my only flower recently died, so I cannot test the flower sensor currently. 😄

@onebavarian
Copy link

I can help. I have 9 MiFlora and 2 Temp/Hum devices.

@ThomDietrich
Copy link
Owner

ThomDietrich commented Mar 28, 2020

Fyi in an attempt to merge this eventually I went ahead and merged smaller unrelated pieces from this PR in #105, aside many further PRs and improvements from my side.

In general my concern with this PR is the bloating (doubling in some areas) of the existing structure, and the threading approach. Before the script is bloated more I would want to refactor the hell out of it. This project grew out of its original hacky scope almost immediately and I never took the time to follow a proper design. Every convention and every sensor deserves its own class, this could be combined with adding a new sensor type - that's where this PR comes into play.

@StohanzlMart
Copy link

Dear @aqualx, dear @ThomDietrich!

I believe forming this whole project into a "MQTT Thingy Interface" on top of Passive BLE Beacon Monitor will make you both happy 💞!

What do you think? @onebavarian @CWempe

Gratefully for everything,
Martin

@CWempe
Copy link

CWempe commented Apr 10, 2021

btw: I just found this project:
https://github.com/zewelor/bt-mqtt-gateway

It does not support as many Xiaomi devices as Passive BLE Beacon Monitor but some senors are supported.
zewelor/bt-mqtt-gateway#151

@StohanzlMart
Copy link

btw: I just found this project:
https://github.com/zewelor/bt-mqtt-gateway

They even seem to have the "force update"-feature I'm looking for on Pull since 2019 :P
zewelor/bt-mqtt-gateway#48

Still, bt-mqtt-gateway uses miflora-git and such polling and not BLE Bacon broadcast monitor which - to me - seems fundamentally better suited for battery usage:

[...] 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 constantly emitted by the sensor. The packets payload may contain temperature/humidity/battery and other data. Advantage of this integration is that it doesn't affect the battery as much as the built-in integration. [...]

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

Successfully merging this pull request may close these issues.

7 participants