Lovelace: Body Miscale Card 5.6.0

I created a custom components Custom_component bodymiscale [For Xiaomi Miscale 1& 2] Esphome or BLE Monitor for your body score. I now want to make this data available on a card to easily read this data.

Features

  • View the information about your Xiaomi Miscale ( Required bodymiscale custom components)
  • Buttons for user selection functions
  • Optional background image

v5.6.0

  • add a switch to convert kg to lbs

v5.5.0

  • Partial integration of bar card options for the body part. (thanks to the contributors of bar-card https://github.com/custom-cards/bar-card )

    Options = Partial (Does not work = animation, columns, decimal, complementary, direction) (work = color, height, max, min, positions, severity, target, width) Severity

    Options = OK (from, to, color) Positions Options = OK (icon, name, minmax, value (inside, outside, off))To know the start, destination, color and target values, open your Mi Fit app on your smartphone.

v5.0.0

  • Conversion to Typescript language (Lit 2)
  • Adding the number format according to your system language
  • In case of a sensor error the alert icon flashes red
  • If no sensor problem the alert icon disappears
  • Added chevron-up and chevron-down icons to show or hide measurement details

v4.6.1

  • fix

v4.6.0

  • added NL language (thanks to @llewy)
  • update of the elements and translation of the configuration map
  • replace the model choice with a switch (Warning: if you upgrade from 4.5.0 to 4.6.0, you must activate a return trip to take into account )

special thanks to @typxxi for his help in developing the new update and for his extensive testing.

v4.5.0

  • add BMI Label

v4.1.1

  • fix

v4.1.0

  • added DE language
  • replace the icons of materialdesignicons by the official “mifit” icons for the score body

v4.0.0

v3.1.0

  • Complete translation of card elements
  • Added pt-BR language

3.0.3

  • added card configuration support
  • added automatic translation EN/FR (please contribute to add your language)

2.1.0

  • Click on the icon to show or hide your score

2.0.0

  • add the states (on the left)
  • move the attributes of the body score “body” (on the bottom)

1.0.1

  • add the attributes of the body score “body” (for the moment on the left)
    example customize:
    body:
    water:
    label: 'Water: ’
  • add the customize icon

1.0.0

  • Initial release

Important

I’m going to need your help to finish this map as I don’t have the skills to do it. All the basic work of this card is taken from benct and its Simple Xiaomi Vacuum Card.

example card manual (My final wish)

Sans titre

Card Manual Basic

9 Likes

That would be so coooooool! I can help you test if needed.

Congratulations for the great job, how do you distinguish the weight for two users with the same scale? The sensor is always the same?

Hello,

Look here. Custom_component bodymiscale [For Xiaomi Miscale 1& 2] Esphome or BLE Monitor

Tks a lot my friend :wink:

HELP ME

I would like to add the entity of each user. The idea is that when we click on the icon it shows the data of this user.

    const buttons = {
        user1: {
            entity: 'bodymiscale.user1'
            label: 'User1',
            icon: 'mdi:alpha-u-circle',
            service: 'input_boolean.toggle',
        },
        user2: {
            show: false,
            entity: 'bodymiscale.user2'
            label: 'User2',
            icon: 'mdi:alpha-u-circle',
            service: 'input_boolean.toggle',
        },
        user3: {
            show: false,
            entity: 'bodymiscale.user3'
            label: 'User3',
            icon: 'mdi:alpha-u-circle',
            service: 'input_boolean.toggle',
        },
        user4: {
            show: false,
            entity: 'bodymiscale.user4'
            label: 'User4',
            icon: 'mdi:alpha-u-circle',
            service: 'input_boolean.toggle',
        },
        user5: {
            show: false,
            entity: 'bodymiscale.user5'
            label: 'User5',
            icon: 'mdi:alpha-u-circle',
            service: 'input_boolean.toggle',
        },
    };

when I press user, a user is always fixed and does not change person.
there is possibility to change?

I am looking for a solution. At the moment you can use the manual version.

Hi,

sorry, I my installation does not work at all. I get zero figures, so the sensor’s ‘bodymiscale.aurelien’ attribute is “emtpy” even though the BLE Monitor is working ( I can watch the weight and points when I went onto the scale ).
My HA is running on Pi 4 via docker and scale is 181D (without the 4 dots on top of the scale).

I installed the card code once from the paste bin link you had provided, deleted that and then I added it from hacs. And even afer another reinstall I had no luck to get it working.

I have installed

  • the pict in /local/img/miscale2.jpg and that works
  • the bodymiscale.yaml in the /custom_components NOT /components
  • and therefore added to [configuration.yaml] this line
    bodymiscale: !include custom_components/bodymiscale.yaml

One point to mention: I did NOT install the bodymiscale.yaml in that /components you had mentioned once on github - maybe it was a typo and you had meant /custom_components

I put it in the usual /custom_components (your code installed by hacs is in the subdir /custom_components/bodymiscale)
I did not get errors during start up / restart.

The errors I had gotten are shown below in the pic for the ‘missing entity Siham’ and the 2 triangles as overlay on the pic where you had letter icons put on top.
image

The entity “bodymiscale.aurelien” has these attributs where “sensors” itself is empty and that is the cause for all the issues while your example pic on github showed a lot more values.

problem: none
sensors:
weight: sensor.weight_aurelien
model_miscale: 181D
height: 180
gender: male
age: 51
weight: null
friendly_name: aurelien
icon: mdi:humanempty.

But I have at least 2 languages for you in the following 2 orders.

Portuguese is from Ricardo’s card which of cause also isn’t working cause “bodymiscale.aurelien” has no values.
except these attributs
problem: none
sensors:
weight: sensor.weight_aurelien
model_miscale: 181D
height: 180
gender: male
age: 51
weight: null
friendly_name: aurelien
icon: mdi:humanempty.

PORTUGUESE           ENGLISH            GERMAN
BMI                = BMI              = BMI
Gordura            = fat              = Fett
Aqua               = water            = Wasser
Basal metabolism   = basal metabolism = Grundumsatz
Visceral fat       = visceral fat     = Bauchfett
Músculo            = muscles mass     = Muskelmasse
Proteína           = protein          = Protein
Massa óssea        = bone mass        = Knochenmasse
Peso               = weight           = Gewicht
pontuação do corpo = body score       = Körperzustand 

ENGLISH
BMI
fat
water
basal metabolism
visceral fat
muscles mass
protein
bone mass
weight
body score

PORTUGUESE
BMI
Gordura
Aqua
Basal metabolism
Visceral fat
Músculo
Proteína
Massa óssea
Peso
pontuação do corpo

GERMAN
BMI
Fett
Wasser
Grundumsatz
Bauchfett
Muskelmasse
Protein
Knochenmasse
Gewicht
Körperzustand

Hope you have an idea, the HA installation is the most recent one, same for raspbian and HA is running fine.

Wolf

did you install the custom components?

For translations I am interested in your full German and Portuguese translation (if different from Brazilian Portuguese)

DE Is the translation good?

{
    "common": {
      "name": "Bodymiscale Card",
      "description": "Mit der bodymiscal-Karte können Sie Ihren Körperwert anzeigen.",
      "not_available": "Bodymiscale ist nicht verfügbar",
      "toggle_power": "Punktzahl anzeigen / Punktzahl ausblenden"
    },
    "state": {
      "ok": "OK",
      "problem": "Problem",
      "none": "Nein",
      "weight unavailable": "Nicht verfügbares Gewicht",
      "impedance unavailable": "Impedanz nicht verfügbar",
      "weight unavailable, impedance unavailable": "Gewicht nicht verfügbar, Impedanz nicht verfügbar"
    },
    "attributes": {
      "weight: ": "Gewicht: ",
      "impedance: ": "Impedanz: ",
      "height: ": "Schnitt: ",
      "age: ": "Alter: ",
      "gender: ": "Nett: "
    },
    "attributes_value": {
      "male": "Mann",
      "female": "Frauen",
      "unavailable kg": "nicht verfügbar",
      "unavailable ohm": "nicht verfügbar"
    },
    "body": {
      "water": "Wasser",
      "visceral_fat": "Bauchfett",
      "body_fat": "Körperfett",
      "bmi": "BMI",
      "muscle_mass": "Muskelmasse",
      "protein": "Protein",
      "basal_metabolism": "Grundumsatz",
      "bone_mass": "Knochenmasse",
      "metabolic_age": "Körperalter",
      "ideal": "Ideal",
      "body_type": "Körpertyp"
    },
    "body_value": {
      "Skinny": "Dünn",
      "Balanced-skinny": "Balanced-dünn",
      "Skinny-muscular": "Skinny-muskulös",
      "Balanced": "Ausgeglichen",
      "Balanced-muscular": "Ausgewogen-muskulös",
      "Lack-exerscise": "Bewegungsmangel",
      "Thick-set": "Stämmig",
      "Obese": "Fettleibig",
      "Overweight": "Übergewicht"
    },
    "unit": {
      " years": " jahre"
    },
    "error": {
      "missing_entity": "Bitte definieren Sie eine Entity.",
      "missing_enttity_bodymiscale": "Bitte definieren Sie eine bodymiscale Entity.",
      "missing_model": "Bitte definieren Sie ein gültiges Maßstabsmodell."
    },
    "editor": {
      "entity": "Entity (erforderlich)",
      "show_name": "Name anzeigen",
      "show_name_aria_label_on": "Namen anzeigen anschalten",
      "show_name_aria_label_off": "Namen anzeigen ausschalten",
      "show_state": "Status anzeigen",
      "show_state_aria_label_on": "Status anzeigen anschalten",
      "show_state_aria_label_off": "Status anzeigen ausschalten",
      "show_attributes": "Attribute anzeigen anschalten",
      "show_attributes_aria_label_on": "Attribute anzeigen anschalten",
      "show_attributes_aria_label_off": "Attribute anzeigen ausschalten",
      "show_body": "Körperwert anzeigen",
      "show_body_aria_label_on": "Körperwert anzeigen anschalten",
      "show_body_aria_label_off": "Körperwert anzeigen ausschalten",
      "show_buttons": "Taste anzeigen anschalten",
      "show_buttons_aria_label_on": "Taste anzeigen anschalten",
      "show_buttons_aria_label_off": "Taste anzeigen ausschalten",
      "show_toolbar": "Symbolleiste anzeigen",
      "show_toolbar_aria_label_on": "Symbolleiste anzeigen anschalten",
      "show_toolbar_aria_label_off": "Symbolleiste anzeigen ausschalten",
      "code_only_note": "Bitte beachten: Aktionen und Status Optionen sind nur im Code Editor verfügbar."
    }
  }

UPDATE + SHORTCUT
For all those who come across and might follow my issues: I had made a simple mistake you can avoid easily. Check your bodymiscale.yaml file for the third line there cause that one had cause all the issues.
The file itself is responsible for the integration or connection of your physical scale into HA. First of all the bodymiscale.yaml file will create a kind of sensor platform called bodymiscale. This file will generate a first sensor called wolf in this case due to the first line. If your scale will be used by mulitple users you will have to define additionals accounts here which I describe later in depth.
Weight itself will be the attribute which mean the bodymiscale.wolf sensor has an attribute that represents the weight and more which you can check easily in the developr tool section by typing weight cause all sensors will appear that have weight in their name or such attribute.

wolf:
  sensors:
    weight:       'sensor.ble_weight_mi_scale2'

But here is a short cut to a full explanation of the whole set up in detail. If you follow these lines you should be able to avoid all the struggles I had to go through and you will also jump over all our translation work we had done here too.

END OF UPDATE

I have installed the integration bodmiscale first which is stored in

/custom_components/bodymiscale

I installed bodymiscale.yaml in the folder component you mentioned
Then I added these lines to configuration.yaml

bodymiscale: !include components/bodymiscale.yaml

I checked the installation and found it here
/custom_components/bodymiscale

Then I tried to add the Lovelace Body Miscale Card via HACS, but Hacs did no find it, so I had to do it manually cause I could not find any “body” as you can see here

Finally I added these lines to configuration.yaml
lovelace:
resources:
- url: /local/body-miscale-card.js?v=1.0.0
type: module

and moves the file body-miscale-card.js to /www/

It did not work, whatever I changed , even full manual installation.

Finally I found out how to add the Body miscale Card repository to HACS and then to install it. Now he body-miscale-card.js was installed in /www/community/lovelace-body-miscale-card and I checked the lovelace script paths that were installed right i guess as

/custom_components/lovelace-body-miscale-card/body-miscale-card.js
/hacsfiles/lovelace-body-miscale-card/body-miscale-card.js

But I can remember that I had seen there before something like “- url: …js” which I had not seen before and found strange.

I also had refreshed ctrl + F5 and rebooted and even cleaned browser cache.
But nothing worked - I always stranded here
image

As mentioned I am just 3 weeks into HA adventure but that more or less full time cause we have holidays now.

Regarding translation I did not know that there was more text but no problem, I will check the translations once it is running here cause I need to see it running to make sure that the translation or terms fits to the context it appears.

Ok no problem, I’ll help you. 1st step the bodymiscale.name components must be in your development tools / states / entity

Do you also have a weight sensor and an optional impedance sensor?

If ok then you need to create a bodymiscale.yaml file in the components folder.
In this file you must put this

aurelien:
  sensors: 
    weight: sensor.weight_aurelien
    impedance: sensor.impedance_aurelien
  height: 176
  born: "1984-06-07"
  gender: "male"
  model_miscale: "181B"

aurelien = your name without capital letters, without spaces and without accents
model_miscale: “181B” = if sensor impedance otherwise delete the line sensor.impedance _ ***** and put in model 181D

thanks for your quick reply.
All of that is done …
bodymiscale.aurelien is in he development visible as entity and has even the icon in it I had added. You can see that in my first post I guess cause I had done a screenshot and mentioned there that this is the indicator that the basic script is not working cause in your reference example or screenshot I had seen all the data you have and I had nothing.

The bodymiscale is there and with the right content cause I had downloaded yours. And this also will be read succesfully cause the aurelien sensor is showing these values.
I have the model without the 4 points on top and that is the 181D.
I do not know what impedance means but I have checked i with your picures of both. My white one is a and impedance lines had been deleted.

All those points are as described in your github documentation even though I had wondered why there is another component folder or if you had meant custom_component. But I moved the yaml file to the component folder and had that connected succesfully. If there is a typo or so you will get an error cause I had missed a letter ones.

Finally: If it works will it show also the old / previous data or only those that data that will be created when the integration is fully working ?
I guess the sensor will only get future data and not those of the past even though the are already stored in the bodyscale sensor.

thanks so far - good night

ok while viewing your screens i realize that you are using my manual card with my automatic card. You must choose either one or the other. So try to set it to automatic, you should have a bodymiscal card in the list. From there you can select your bodymiscal entity. tick all the boxes. Even if there is no data you should see a problem weight unavailable stats, your height, age and gender should appear.

Maybe, but I did not know that there were 2 different versions available. I had only read about the switcher for 2 persons or so but that is not the point cause this scale is for a relative who is using it alone. So I do not need it.

What is the wrong point ?
the Body Miscale Card JS file.

Do you mean I should have it in the list of available cards on the homepage ?
I did not find it before but now there has appeared as the last item Body Mi Scale Card but guess what I get when I select it.

The Card is empty but I will try to copy your code from github into that editor and hope I get a bit further or try to replace that file. But I can remember that I also had bin on that paste bin side that you had linked to and copied that code too.

And here again my guess that it is right now about the BodyMiScale and not the card cause if the BodyMiScale script would work then the aurelien sensor would be full of data, but it is empty therefore your card and that from ricardo is empty too , not a single figure is displayed except the name aurelien

do you have a real sensor.weight or did you register it without it existing? you should have sensor.weight unavailable and not null.

Have you connected your scale?

Just by clicking on the bodymiscal card I got it without doing anything more.


I have a connection created with that BLE MINI tool and from there I got 3 sensors:

  1. weight
  2. unstabilized weight and
  3. weight difference or so and those contain the values like date and time.

I had cleaned all the folders on my HA installation and reinstalled it using hacs again.

I guess I will do a full manual installation tomorrow without any Hacs involved. This is a new Home Assistant installation, just 5 days old or so. Your card looks nice, I just have the picture of the scale with 2 triangles.