Mi Band 3/Amazfit BIP Integration [Updated 10/01/2019]

Very very nice, thanks a lot for sharing!

1 Like

Thanks, was looking for this! Great stuff.

Could you share the background lovelace image ( google_fit_1.png)?

EDIT: Nevermind found it here. :slight_smile:

1 Like

I have found a way do dynamically calculate BMI. No need to hardcode it :slight_smile:
You already have all the data that’s needed, height and weight.

The sensor I’ve made:

sensor:
  - platform: template
    sensors:
      bmi_freakshock:
        friendly_name: "BMI Freakshock"
        value_template: "{{ ((states.sensor.weight.state | float) / (((states.sensor.height.state) | float /100)*((states.sensor.height.state) | float /100))) | round(1)}}"
2 Likes

@freakshock thanks you beat me to it I haven’t added this to the docs yet but literally added this to my config yesterday. Thanks for reminding me to add to repo.

It seems you have also customized the sensor icons in customize.yaml? Could you add that too, in case it’s not on your to do list yet :wink: ?

@freakshock I use icons from Font Awesome you can access through this custom component will add to repo also

1 Like

@jimpower hello again, my amazfit bib arrives today, i am trying to follow your tutorial, but i cant do this step:
"You will need to restart HA, upon restart you will be prompted to authorize "

the authorize not show me…
any input?

@Rodolfo_Vieira Can you reboot again, and once it starts up look at your logs and tell me what google_fit component says?

Thanks, for the meantime I used these material icons.
For BMI and body fat there are not really good ones, ah well :wink:

sensor.heartrate:
  icon: mdi:heart-pulse
sensor.weight:
  icon: mdi:scale-bathroom
sensor.bmi:
  icon: mdi:finance
sensor.body_fat:
  icon: mdi:cupcake
1 Like

ok @jimpower i solve the problem:
i put this on my configuration.yaml

google:
  client_id: 72xxxxxxxr.apps.googleusercontent.com
  client_secret: Von1sbxxxxx

now, i will configure the tasker.

1 Like

@jimpower ok, now i need you help… on this step.

com.mc.miband.stepsGot i have amazfit bip, what name i should put here?

@freakshock I like the use of cupcake for body fat lol I might steal this

@Rodolfo_Vieira can you open up your notify & fitness app go to settings the icon on the top far right, click on tools scroll down to tasker integration and show me screen shots of "receiving events from notify app I think they should be the same but would like to confirm.

Tasker integration
If you don't know what is Tasker, please check it here Tasker on Play Store

There are many other Tasker compatible apps you can use too:
Automate
AutomateIt
...

Doing actions on Notify app
Disable button (Mi Band 2 only)
Action: com.mc.miband.buttonDisable
Enable button (Mi Band 2 only)
Action: com.mc.miband.buttonEnable
Resend last notification
Action: com.mc.miband.resendLastNotificationByTasker
Dismiss last notification
Action: com.mc.miband.stopLastNotificationByTasker
Disable sleep heart monitor
Action: com.mc.miband.sleepHeartDisable
Enable sleep heart monitor
Action: com.mc.miband.sleepHeartEnable
Disable Mi Band 2 wrist to turn on display
Action: com.mc.miband.miband2WristDisable
Enable Mi Band 2 wrist to turn on display
Action: com.mc.miband.miband2WristEnable
Disable sleeping time settings (include weekends)
Action: com.mc.miband.sleepingTimeDisable
Enable sleeping time settings (include weekends)
Action: com.mc.miband.sleepingTimeEnable
Toggle workout pause
Action: com.mc.miband.workoutTogglePauseTasker
Connect to band (if not already connected)
Action: com.mc.miband.connectToBand
Re-connect to band (force reconnection)
Action: com.mc.miband.reconnectToBand
Set Notify silence mode
Action: com.mc.miband.setNotifyMode.disableAll
Set Notify normal mode
Action: com.mc.miband.setNotifyMode.enable
Enable Mi Band 2 disconnection notification on band
Action: com.mc.miband.miband2DisconnectionEnable
Disable Mi Band 2 disconnection notification on band
Action: com.mc.miband.miband2DisconnectionDisable
Sync data from Mi Band (since 6.10.9 app version)
Action: com.mc.miband.syncData
Please notice: if you sync data before wake up you may see wrong sleep statistics


Receiving events from Notify app
Get realtime measured heart value
After band has measure heart rate, you will receive this intent
Action: com.mc.miband.heartRateGot
Extras: value - contains measured heart rate (integer)
Get realtime measured steps
To receive current day steps number, you will receive this intent
Action: com.mc.miband.stepsGot
Extras: value - contains steps number (integer)
Get band battery value
After the Notify app get the band battery value, you will receive this intent
Action: com.mc.miband.batteryStatGot
Extras: value - contains battery value (integer)
Receive the intent when an early bird alarms starts
When an early bird alarm starts, you will receive this intent
Action: com.mc.miband.smartAlarmRun
Receive the intent when wake me up alarm starts
When wake me up alarm starts, you will receive this intent
Action: com.mc.miband.startWakeUp
Receive the intent when band get connected
Action: com.mc.miband.connected
Receive the intent when band get disconnected
Action: com.mc.miband.disconnected
Receive the intent when you fell asleep (Mi Band 2 and Amazfit Bip only)
Action: com.mc.miband.tasker.fellAsleep
Receive the intent when you woke up (Mi Band 2 and Amazfit Bip only)
Action: com.mc.miband.tasker.wokeUp
Receive the intent when you reache the steps goal (Mi Band 2 and Amazfit Bip only)
Action: com.mc.miband.tasker.stepsGoalReached
Receive the intent when you stop wearing the band (Mi Band 2 and Amazfit Bip only)
Action: com.mc.miband.tasker.notWearing

@jimpower update:

I create the sensor:

  - platform: mqtt
    name: "Rodolfo Steps"
    state_topic: "steps/rodolfo/oukitel"

And the result is:
image

but i dont have the sensors:
height
weight
distance
calories etc…

2019-01-09 22:29:06 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 324, in wrapper
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 324, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/sensor/google_fit.py", line 306, in update
    self._update_steps_data()
  File "/config/custom_components/sensor/google_fit.py", line 423, in _update_steps_data
    get(userId='me', dataSourceId=STEPS_DATA_SOURCE, datasetId=DATA_SET). \
  File "/usr/local/lib/python3.6/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/googleapiclient/http.py", line 842, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/fitness/v1/users/me/dataSources/derived%3Acom.google.step_count.delta%3Acom.google.android.gms%3Aestimated_steps/datasets/1546992000000000000-1547072945000000000?alt=json returned "Access Not Configured. Fitness has not been used in project 726385772693 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/fitness.googleapis.com/overview?project=726385772693 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.">

@Rodolfo_Vieira I think the app for Notify and fitness is different for Mi Band and Amazfit can you double check you have this app installed.

Yes i have that app version

Looks a lot like my Fitbit card on sharethelove :wink:

Edit: I see you gave @ludeeus credit for my card in the repo. Classic ludeeus, playing my work off as his own :rofl:

1 Like

@inatrich yes indeed your fitbit card was inspiration for this layout sorry if the wrong person gets credit :slight_smile: I assume he is the one who maintains sharethelove site lol. Happy if you provide me a link to your repo I will give credit where its due :metal: :wink: :metal:

No, I contributed it to the community sharethelove site. Ludeeus started it but anyone can contribute

And not a huge deal. I just came across this and said to myself “that looks a lot like mine” :slight_smile: I’m glad others are get use/inspiration from it. I’ve broken my Fitbit since then :cry: Maybe I need a mi band 3

1 Like