Lovelace: Body Miscale Card 5.6.0

I have seen that the file has been uploaded and I opened it in raw and I copied and paste it but again I can not see any difference.
It is still the 0620 with no a or marker that could convince me that I really got the new code.

And here is the screenshot with all the old mistakes and I guess you would send it to me with improvements, right?

I suggest you might add the number every time that while adding I can always be sure that I am on the latest code and you might consider to add the 6.20 number at least for the DEV version next to the scale icon cause right now i am completely blind and always have to trust that i for sure got a new version till I realize that out of 8 or 10 nothing has changed.

Could it be caused by a false release number I had to add in the repository ?

I had updated that to the number you had mentioned before.

You do not need to touch the YAML file. Thanks for the link to the translator, I have downloaded the .exe. It will be very useful for my daily work.

You have to keep in mind that the custom_components are card independent.

The custom_compoents is basically the calculator.
The card is there to format the custom_components

For the versions of the card. The official one is the one from HACS. The DEV version is just to help us find the right translation of the card. Once this is done you can delete it permanently.

Tuto

  1. Download the new file here https://github.com/dckiller51/lovelace-body-miscale-dev/tree/main/dist
  2. Replace the existing file in /config/www/body-miscale-dev
  3. Go to the resources menu, search /local/body-miscale-dev/body-miscale-dev.js?v=XXXX
    replace XXXX by the number you have chosen, add +1 for each new version to be tested.
    Click on update at the bottom right
  4. Go to your dashboard where the card is located and press F5

This is how I test my updates

Yes, deepl.com is the best free translation service even though you can hit limits and then have to split things up, but very good results at least for all the german - english stuff.

Unfortunatelly something is broken with this version cause if I copy and save it the size is far, far bigger - factor 9

Here you can see my previous versions and the most recent one which is far bigger.

I simply click your link, I check the release time and then I do open RAW and then I do mark all and copy before I paste it in the body-miscale-dev.js file and save it.

Here is my ressource link that should be right too cause it had been working till 2 hours ago. local means /HomeAssistent/www/
and there it is below community/lovelave----dev/ directory so it looks quite right.

/local/community/lovelace-body-miscale-dev/body-miscale-dev.js?v=0.1.2

Can you please check the filesize of your upload cause it is far different from those versions before.

Edit the *.js file and copy the new content.
I confirm the file is 596kb
However, you must keep the initial name body-miscale-dev.js
Adapt the links according to where you copy your file

I have used always the same filename and if I get a new one I create a copy and that gets the number.

So the new file is 10 times bigger for just a few translation fixes ?
pretty weird, but I can try it again.

What did you have changed cause right now I found each time 0 improvements ?

yes, look at my post 1h ago you must have two new options in the map configuration.
You can edit your file and replace the inside with the new version.

Sorry, but it does not work cause it always showed me the old code even though that file had been completely renamed.

I can not download the code via that link. I always have to use the RAW and then mark and copy everything to paste it into the js file.
It hat been working out before but right now it did not. I even rebooted the Pi4 and still I get the old code.

Did you change the build number 0620 to something different ?
I still get the same number and I do not get it.
Ressource location has been the same - except the version number cause for that I copied the one you had send to me.
Now I am stuck and have to wait for tomorrow I guess

Start over:

  1. Delete your lovelace-body-miscale-dev directory
  2. Delete in ressource /local/community/lovelace-body-miscale-dev/body-miscale-dev.js?v=0.1.2
  3. create lovelace-body-miscale-dev directory in /www/
  4. create a body-miscale-dev.js file in /www/lovelace-body-miscale-dev
    Edit the file and copy the content to a RAW version https://github.com/dckiller51/lovelace-body-miscale-dev/blob/main/dist/body-miscale-dev.js
  5. add a js module in ressouce with the link /local/lovelace-body-miscale-dev/body-miscale-dev.js?v=1.0.0 (Never reuse an old number)
  6. Add the dev card to your dashboard
1 Like

I did every single step and it did finally work out when I had changed the number at the end in the repository which i had not been aware of to change it each and every time. Lesson learned, hopefully next time it will work that way too in 2 minutes instead of hours.

I have updated the github page with all the issues that need to be fixed too.

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