Lovelace: Body Miscale Card 5.6.0

Hi,
i have written a separate reply to your github hints over there on github

And after that I have created a new, well structured state template which structured all the topics in these 3 categories

  1. translations
  2. general configuration
  3. not to forget

UPDATE 22nd of June: further topic "scale account selector buttons"

I have a question regarding the upcoming multi user integration and the current 0622-01 DEV version. Here I have added 5 buttons in the code editor
image

Those 5 buttons appear already but when being pressed without anything else happening. I had assumed that pressing any of such button would update the whole detail section with the data of the chosen scale account.
But this did not happen or - what else do I have to do to make that change work ?

Here you might see that I have pressed the second “1” button counted from the right border cause that white round button with a black ‘1’ has a slightly lighter rounded shadow where that ‘1’ is linked to Lara inside that card. I had hoped that at least the age would been updated in that huge lower section.

Any ideas to get this working or to become able to play with that feature and see if that is working or might need some additional translations ?

thx
image

Aurelien,
I had to digg into the whole number format thing a bit deeper and thanks to Pedro I found at least a bit to understand what is causing what.

So that being said you can set on each of your devices the number format settings (lower left corner / icon and then number format where you can choose Auto (language settings) or System settings or by selection of your own choice like “1.234.567,89”)

Which effect does that have?
that depends as always but I will try to explain that in a simple example of a temperature sensor.
The sensor sends the data and HA always stores them as 23.5. And then those client based user settings (if you log in on a device like an echo spot for the very first time you have to set up these settings right) kick in and will do what ?

Show the temperature right as 23,5 °C

or wrong as 23.5°C on the exact same dashboard page and without me having manipulate anything.

Have a look here on the temperature on the left and on the right and ask yourself how that could be on the same machine same moment on the same dashboard.

Now, how could that have happen?

The system or built in templates are supporting the international standards while the other do not know or do not care about that point and HA had not taken much love and emphasize to provide a kind of standard routine / object / guide line that all cards will have to support the international standards. I would not wanna use the stuff that ignores the international standards and force me or users to follow other standards.

And that would mean we have to figure out where to find such standards for custom card templates cause I guess that is a basic requirement to follow standards. I have lost already some whatever integrations and cards that had not followed the guide lines and then were forced to leave by HA as far as I understood is cause I got warning like “no longer supported” or “will be depreciated from July first”. And you would not wann hear about that from end users like me cause I had used the xiaomi gateway radio till first warnings appeared in my log that the service will be depreciated cause the developer had missed to setup a right version number.

Ok, so I am not into that Lovelace card development, but I had already to deal with those separators and make things work at least for sensors in the configuration.yaml.

Here is for example a thousand separator that had worked for me in the template checker

“{{ ‘{0:.0f}’.format(state_attr(‘bodymiscale.wolf’, ‘basal_metabolism’ ) | int).replace(’’, ‘.’)}}”

or in your case
“{{ ‘{0:.0f}’.format(state_attr(‘bodymiscale.aurelien’, ‘basal_metabolism’ ) | int).replace(’’, ‘.’)}}”

But I guess you might ask in the lovealace section for help or support how to deal with the international number formats the best way cause we 2 know already at least 3 different kinds how to display a “1.234.567,89€” the right way with “.” or “,” or " "

I guess it is better to think about that topic as a whole from the beginning instead of discussing if that is necessary or not cause that will occure not only for kcal but for every weight and other figure with decimals. Sooner or later HA will recognice the whole issue as a risk and start to enforce rules for supporting the international standards.

May be not that good right now cause it will take time and efforst but better now then suddenly out of nowhere months or years later. I still hope that there is a guide or routine of how to implement the standards like the built in do it already.

1 Like

Colleagues, some great and serious discussion over here!

I’m not so deep in to technical stuff, I’m trying to set the component and the card and struggling with similar (I think) issues that @typxxi had at the beginning.
Component works, I have the bodymiscale.yaml

darek:
  sensors:
    weight: sensor.daros_weight
  height: 181
  born: "1984-03-04"
  gender: "male"
  model_miscale: "181B"

then the weight sensor (normally showing the data)

 #Miscale
  - platform: mqtt
    name: "Daros"
    state_topic: "miscale/Daros/weight"
    value_template: "{{ value_json['weight'] }}"
    unit_of_measurement: "kg"
    unique_id: Daros_weight
    json_attributes_topic: "miscale/Daros/weight"
    icon: mdi:scale-bathroom

bodymiscale.darek is always “unkown”

image
any advice where to start please :)?

You are sure of your sensor.daros_weight. Does he return a figure of more than 10kg?

no, sorry that can not be true, cause I have not used mqtt .

But I can not see the basic sensor that the scale provides in your yaml file.
Maybe you might try first to get the basic scale running and after that move on to that mqtt integration.

Therefore check the basic scale sensor ‘sensor.ble_weight_mi_scale2’ in your developer tool when you had weight yourself regarding weight figures.
If that shows a valid weight figure then go on and replace the sensor in the bodymiscale.yaml file with the basic configuration to find out if that then might work too.

darek:
  sensors:
    weight: sensor.ble_weight_mi_scale2

and not “weight: sensor.daros_weight” cause that has obviously no connection to the scale sensor right now.

Once you have updated the yaml file, restarted HA and weight yourself again you should check in the developer tool section for the bodymiscale.darek weight value.

If that is working fine then move on to the mqtt platform cause maybe there the issue can been found in the unique_id cause that starts with an uppercase letter “Daros_weight” where I am always carefull since I had issues with those uppercase letters in sensor names.

I would go the save way and that starts with the basic implementation using sensor.ble_weight_mi_scale2 in your bodymiscale.yaml file.

That was my core issue, the wrong sensor, cause I simply had copied aurelien’s yaml file and had not changed it to the basic which are

darek:
  sensors:
    weight: sensor.ble_weight_mi_scale2

The scale itself is working if you find a valid weight figure for the sensor

Good luck

just to make all things clear from the beginning:

#1
you need to have BLE monitor installed and setup right which means of cause the right BT Mac adress and not a copied one. I have finally have installed the BLE monitor using hacs.

ble_monitor:
  ###   MAC ADRESS RASPI   ###
  bt_interface:     'AA:AA:AA:05:99:98'
  discovery:        True
  active_scan:      False
  report_unknown:   False
  # batt_entities:  False = depreciated
  decimals:         '1'
  period:           '60'
  log_spikes:       False
  use_median:       False
  restore_state:    False

  devices:
    - mac:              'BB:CC:DD:BB:48:C7'
      name:             'MI SCALE2'
      decimals:         2   
      use_median:       False
      restore_state:    default

#2
now you need to add this line to your [configuration.yaml]

bodymiscale: !include components/bodymiscale.yaml

#3
This is the link to the following file and sensor configuration file

bodymiscale.yaml
in /config/components/

#4
the bodymiscale will create the bodymiscale entity as a sensor plattform cause every user / account else will get such a section in that file, so you can create 5 of such sensors or better user accounts that all will start with 'bodymiscale." followed by the sensor name like
bodymiscale.darek
bodymiscale.lara

And these sensors will have at least the attritbut weight and that attribut weight will get its value from the Xiaomi Scale sensor sensor.ble_weight_mi_scale2 …

ATTENTION: I have a 181D and not the 181B you seem to have. If you have to check what sensors your scale offers in particular just go to the developer tool and type in scale cause there you will find all the available scale sensors - where I had found 3.

this is how your bodymiscale.yaml should look like for 2 users / accounts

darek:
  sensors:
    weight: sensor.ble_weight_mi_scale2
  height: 181
  born: "1984-03-04"
  gender: "male"
  model_miscale: "181B"
lara:
  sensors:
    weight: sensor.ble_weight_mi_scale2
  height: 177
  born: "1988-08-08"
  gender: "female"
  model_miscale: "181B"

#5
once you have done all this please restart HA and press ctrl + F5 to reload the page.
Now jump on the scale, then back to the browser and check in the developer tool section what weight values the scale sensor shows
sensor.ble_weight_mi_scale2

and what your own
bodymiscale.darek

That is more or less a copy of the first which will be used by your card later.
Both have to show the same values, even if you have prepared 4 users for the scale each sensor will get and show the same value from just 1 measurement.

Once you have achiedved that you can add an entity card and select bodymiscale.darek as sensor to be displayed, but make also sure to choose weight as the attribute you want to have shown there.

Once that is achieved you can go on with all the other attributes offered by your scale.

My wife has asked me to create this card last week which I now personally use
image

Weight, history, BMI and kcal basal metabolism based on the figures defined in bodymiscale.yaml like age and height.

But we have 2 scales and 2 different accounts so we do not have to switch accounts.

yes, sensor working as expected

image

tonight I will perform all the steps explained by @typxxi (thank you!) and I will let you know the status

I am not sure what might have changed but the sensor looks like to have a different name cause I had copied that and can remember darek

Now it is Daros_Weight which can be just a friendly name for “bodymiscale.darek” based on the configuration file.

Would be good if you can figure out what really had cause the issue in your setup cause others will learn from what had been going wrong on your installation.

All I had written was for a not working sensor and does not really help in case that is working. Just the explanation for all the stuff that is going on and can go wrong like on my journey where the fault had been only in the sensor definition and it took ages and a lot of effort to figure out what was going wrong and how the bits and pieces of the integration do work together in detail.

But finally you have gotten it right and now you might need the mqtt or scale changer in case you will use the scale for more than 1 person.

I think you have edited your post too fast :slight_smile:
nothing changed
daros_weight is the MQTT sensor and it is working fine as on the screen above (question from @dckiller51 )
bodymiscale.darek has daros_weight as a weight sensor inside, with this sensor bodymiscale.darek show unknown all the time

however probably you got the reason of failure correct - within bodymiscale sensor I should use the weight sensor directly from the Scale (I switched to MQTT only because of low signal of BT/BLE, which as a result causes scale to drop the connection)

I will confirm soon

THanks!

a cheap solution is to go through esphome with an esp32. This allows you to put this card next to the scale and send the info by wifi.

For your first question, your mqtt sensor must start with sensor.xxxxx

I had summed it up for all those who might come across that topic too, where the BodyMiscale Card would not seem to work but that might have been caused by the sensor and not the card like in my case you had referred to.

And far above when I had started my topic I added an UPDATE section to my initial comment that is linking to that explanation I had written for you. That would make it a lot shorter to get behind. I am not into that whole ESP world cause when I had bought 2 back then our energy monitor had to been replaced and was no longer needed.

What is the purpose of that ESP32 integration ?
Is it a kind of bridge connecting the scale to the esp32 that hen connects via WiFi or is it that logic that switches between accounts based on measurement results or can / is it both ?

thx

I have an issue with the buttons (for more details and changing users) in firefox and the home assistant iOS app. They simply don’t do anything. Not even an error in the browser console.

Is anyone else experiencing the same? (i scanned the entire thread but didn’t see anyone mention it)
I already created an issue (before I found this thread).

New version available.

Small screen of the next version with integration of bar card for the score part.

3 Likes

Can someone tell me if it’s still possible to find this card in HACS? I have the integration running and working great just can’t find the card in HACS. Is manual install for now only supported?

Hello, you must add the address using the 3 dots at the top right then add a personal deposit.

1 Like

Thanks. When I tried to add https://github.com/dckiller51/lovelace-body-miscale-card as a custom frontend repo, HA popped up and said the card “was already in the store” and then whamo, it appeared. Installed now, thank you.

@thomasloven hello, In view of your expertise in the field of cards, I would like to ask you because I have a technical question on my card. I am missing an element that I wanted to put in place but that I am unable to implement. Do you have any idea how to set up several users selected by a switch.

Part of the code allows me to operate a service with a button. the ideal would be to place it here.

  renderButton(data: any) {
    if (!this.config.show_buttons) {
      return html``;
    }

    return data && data.show !== false
      ? html`<ha-icon-button
          @click="${() => this.callService(data.service, data.service_data)}"
          icon="${data.icon}"
          title="${data.label || ''}"
          style="${this.config.styles.icon}"
        ></ha-icon-button>`
      : null;
  }
export const buttons = {
  user1: {
    show: false,
    label: 'User1',
    icon: 'mdi:alpha-u-circle',
  },
  user2: {
    show: false,
    label: 'User2',
    icon: 'mdi:alpha-u-circle',
  },
  user3: {
    show: false,
    label: 'User3',
    icon: 'mdi:alpha-u-circle',
  },
  user4: {
    show: false,
    label: 'User4',
    icon: 'mdi:alpha-u-circle',
  },
  user5: {
    show: false,
    label: 'User5',
    icon: 'mdi:alpha-u-circle',
  },
};

Here I know that you are already very busy with all your projects but if you have an idea to help me. Thank you

Hi,

Thanks for the great work, but I’m having some trouble.
I’ve copied the icons to www/images/bodyscoreIcon.
But I can’t see them at all.

Can you look at what F12 select an element gives