Xiaomi Mijia bluetooth temperature & humidity sensor compatibility

How did you get this nice graph?

I have just added the sensor to HA and it’s working fine. But it fills my log with:

Update of sensor.mitemp_bt_temperature is taking over 10 seconds

Is it possible to get raid of this error?

Same here… tons of errors about this…

I’ve also gotten the sensor to work with Hass.IO on a Pi3, but the log is filled with errors (mainly update of sensor took more than 10 seconds).
However, I’m unable to log the data in an automation. states.sensor.<sensor name>.state provides me with nothing (not None, but just a blank string I think).

Hi, currently it is not possibile. The sensor timeout can’t be set at configuration level, but will be in future

Hi! I’ts really easy, but you have to set up InfluxDb and Grafana Complete guide on setting up Grafana/InfluxDB with Home assistant using official Docker images

A plus with this approach is that you can remove your Home Assistant history (purge keep days on recorder component), and only get the last week for debugging purpose.

It works with my component. Did you use the official one?

1 Like

Yes, I’m using the official one, inserted code snippet at the end of this post.
I’m using a bit of a non-default (I guess) setup though. I have a VM (under Proxmox) and a Pi3, both running Hass.IO. Pi3 only runs Octoprint addon and Bluetooth, everything else (including automations) I’d like to run on the VM. MQTT Statestream and eventstream is used to send data from Pi3 to VM (tried both separatly, now they both run).
The data is stored in a Google Spreadsheet using IFTTT, so I guess that’s another point of failure, but that part works for my other temperature sensors (Xiaomi Aqara).
I’ll try to place the automation on the Pi3, and see if that’s where the issue is.

sensor:
- platform: mitemp_bt
    mac: !secret mi_temp_mac
    name: Hallway
    force_update: true
    median: 1
    monitored_conditions:
      - temperature
      - humidity
      - battery
2 Likes

I have three of this sensor connected to home assistant. Everything works fine except one thing. The range… If the sensor and raspberry is in the same room Everything works well but if I move the sensor in the other room, nothing doesn’t work. There is way to solve this problem? Maybe a BLE extender or I don’t know what?

No idea for range extension?

@mr-varga
I had the same issue with bluetooth range and could not sort it. I’m now using a second RPI3 (works with Pi Zero as well) with HASS.io to improve the coverage. The 2nd RPI is sending the data via MQTT to the main RPI. I’m currently using this for device_tracker but it should work for other bluetooth solutions as well.

I have te Xiaomi Temp sensor as well.

  • Can you explain how you connected the BT sensor with RPI?
  • Can you share your config ?

Dear xx_Nexus_xx,

I followed this homeassistant guide:

2 Likes

Thanks a lot , I was thinking too complicated :wink: … not aware its already sorted

Hi there.

I use mitemp_bt with the Xiaomi sensor. It works well, WHEN the temperature is 10 degrees and above. As soon as it goes under 10, temperature reading is locked on 10 or what ever the last reading was, and humidity lock’s up as well. Battery looks similar.
When the temperature rises above 10, readings resume. Looks the same in the HA overview.

I tried this with 2 different HA setups, and 2 different sensors. Same problem every time.

Am I the only one?

Tried with the official docker image, and Hass.io on a RPI 3
Tried median: 1 & 3

sensor:
  - platform: mitemp_bt
        mac: 'XXX'
        name: Room
        force_update: true
        median: 1
        monitored_conditions:
          - temperature
          - humidity
          - battery
1 Like

I’m having the same issue with no reading below 10 degress :unamused:

I’m having the same issue as @thesailor. I checked with the Mi Home app and the sensor is connected and operating as expected (it was reading 8.0degC and 71.6% humidity), but with the HomeAssistant app the values are frozen at temps below 10degC. I even tried moving my Pi3 next to the sensor to test if the range was affected at low temperatures but the values still won’t read. Suspect there’s a single digit temp issue but not even sure where the code base is to have a look - hopefully I can find it later tonight.

Hi @randomdisco & @xx_Nexus_xx.

Looks like we now have a solid case :wink:
My educated guess is that this is a relatively simple parsing problem. I don’t know what the sensor returns as a value when under 10 - the digital screen shows “09.3”. That starting ‘0’ could be the problem.

@randomdisco, you can find the codebase here: https://github.com/flavio20002/mitemp_bt

Cheers.

Awesome - thanks. I’m not a Python coder (yet - if only I had time) but it looks like this might be the culprit:

    # Parse the output
    res = re.search("( [0-9a-fA-F][0-9a-fA-F])+", result)

which is in
def write_readnotif_ble(mac, handle, value, retries=3, timeout=20, adapter=‘hci0’):
and
def read_ble(mac, handle, retries=3, timeout=20, adapter=‘hci0’):

Appears as if it needs to have 2 values for both… But if the display is returning a 0 in front this should work. Wondering if the parse of the handle from the sensor (in format 0xXX) is only returning 1 rather than 2 values…

Will try and setup a debug environment tonight to figure it out. Any tips on setting such an environment up on a PI3 would be appreciated (or I’ll just google later) :slight_smile:

@thesailor opened an issue with the developer too. Suspect he/she might be able to debug this quicker than me (if they have time): https://github.com/flavio20002/mitemp_bt/issues/2

Disaster @thesailor @xx_Nexus_xx ; that was the wrong code base. I fixed it though and updated the GitHub issue. Found the real code and posted another issue with where the error is. I can’t figure out what type the data is for the code to work though so I’m struggling to work out a fix. Watch this space… https://github.com/ratcashdev/mitemp/issues/2

Update: worked out a fix (just needed a break for a coffee) Will test overnight…