bodymiscale icon indicating copy to clipboard operation
bodymiscale copied to clipboard

skip all measurements below 80Kg ?

Open criticallimit opened this issue 2 years ago • 9 comments

This is more a question.

Is it possible to skip all data/update/states/attributes when a person is using a scale who is below 80Kg?

Reason is: Me, main user of the intergration, is above 80Kg. But all others in our household are below 80Kg nd they are not interested in details exept weight the scale is showing when they use it. But that destroyes my longterm data. So, it is possible to avoid all data transferred or stored when the user is below 80Kg?

Of course, a multi user arrangment would be better, but for the beginning that would help to skip all below 80Kg.

Thanx

criticallimit avatar Oct 31 '21 19:10 criticallimit

The idea of ​​the component is to have one addition per user. Your problem is certainly related to the backup problem when you restart. Look for my node red to solve the problem.

dckiller51 avatar Oct 31 '21 19:10 dckiller51

backup problem is solved when restart HA.

I´m asking for a small hint to avoid measurements transferred to HA when another user is using the scale.

Node red is no option.

can you point me to code and file, where I can enter a small code to avoid transferring data when user is below 80Kg?

For me, your inetrgation is working fine and I love it. But I have a wife and a kid using the scale as well. So my graph and daily, weekly, monthly statistics are destroyed by these users. ;-)

criticallimit avatar Oct 31 '21 20:10 criticallimit

You can create a model sensor. This is the one you add to bodymiscale.

#- platform: template
  sensors:
    weight_username:
      friendly_name: "Weight User name"
      value_template: >-
        {% set weight = states('sensor.xiaomi_mi_scale_weight') | float %}
          {% if 80 <= weight <= 120 %}
            {{ states("sensor.xiaomi_mi_scale_weight") }}
          {% else %}
            {{ states("sensor.weight_username") }}
          {% endif %}
      unit_of_measurement: 'kg'
      icon_template: mdi:weight-kilogram

dckiller51 avatar Oct 31 '21 23:10 dckiller51

that´s what I also think about.

But all other attributes are changing as well, like BMI, body_fat etc.

wouldn't it be easier to implement a weight-range in the bodymiscale.yaml?

like this:

` Dirk: sensors: weight: sensor.waage_weight impedance: sensor.waage_impedance height: 189 weight: 90 born: "1966-09-13" gender: "male" model_miscale: "181B"

Mo: sensors: weight: sensor.waage_weight impedance: sensor.waage_impedance height: 155 weight: 40 born: "2010-11-12" gender: "male" model_miscale: "181B" ` due to weight attribute in both profiles you can set a range range for "Dirk": 90 +-5 range for "Mo": 40 +-5

your Integration can now decide if the data is to write to bodymiscale.dirk or bodymiscale.Mo ?

I´m not able to prog these changes, but maybe you can think about it and implement a multi user option...

in the meantime I will play with template sensors in HA. Maybe there is a solution in a template sensor I can´t see at the moment...

But thanx anyway for your quick reply!

criticallimit avatar Oct 31 '21 23:10 criticallimit

I understand but this is the reverse of this components. It should read your weight sensor. So you must have an independent weight sensor for each user.

dckiller51 avatar Nov 01 '21 00:11 dckiller51

The Xiaomi App can handle this and automatically put the Data to the Person. Don´t know on which base, but I think it´s weight in relation to impedance. But I did it now with template sensors for 3 Persons, which is working fine. 3 pairs of weight/impedance, one for every user. No matter who is on the scale, the data is going automatically to the right person. this, of course, is not working when a 4th person (guest) is using the scale. For that I have to put a switch to select a person. But that means, that every time you have to select a person before weighing. An automatic selection solution I haven´t found, because weight and impedance is to close together for male or female humans.

Thank you for pointing me in the right direction. Learned a lot, and slowly come into HA, Yaml, py Thanx!

criticallimit avatar Nov 01 '21 11:11 criticallimit

I understand but this is the reverse of this components. It should read your weight sensor. So you must have an independent weight sensor for each user.

But what you could (probably) easily do is split up the configuration such that

scale_name:
  model_miscale: "181B"
  sensors:
    weight: sensor.ble_weight
    impedance: sensor.ble_impedance
 stats_user1:
   name: user1
   height: 182
   born: "1964-04-10"
   gender: "male"
   min_weight: 60
   max_weight: 70
 stats_user2:
   name: user2
   height: 182
   born: "1964-04-10"
   gender: "male"
   min_weight: 70
   max_weight: 90

Granted the user must not let the weight ranges overlap.

I also think each person's stats should be a device with each attribute being an entity

borpin avatar Nov 11 '21 20:11 borpin

If you use an ESP with ESPHome to collect the data, you can set this in the ESPHome config:

  - platform: xiaomi_miscale
    mac_address: "50:FB:19:17:34:96"
    weight:
      name: "Xiaomi Mi Scale Weight"
      id: weight_miscale
      on_value:
        then:
          - lambda: |-
              if (id(weight_miscale).state >= 69 && id(weight_miscale).state <= 77.49) {
                return id(weight_user2).publish_state(x);}
              else if (id(weight_miscale).state >= 77.50 && id(weight_miscale).state <= 83) {
                return id(weight_user1).publish_state(x);}
    impedance:
      name: "Xiaomi Mi Scale Impedance"
      id: impedance_xiaomi
      on_value:
        then:
          - lambda: |-
              if (id(weight_miscale).state >= 69 && id(weight_miscale).state <= 77.49) {
                return id(impedance_user2).publish_state(x);}
              else if (id(weight_miscale).state >= 77.50 && id(weight_miscale).state <= 83) {
                return id(impedance_user1).publish_state(x);}
  - platform: template
    name: Weight Martijn
    id: weight_user1
    unit_of_measurement: "kg"
    state_class: "measurement"
    icon: mdi:weight-kilogram
    accuracy_decimals: 2
  - platform: template
    name: Impedance Martijn
    id: impedance_user1
    unit_of_measurement: "ohm"
    icon: mdi:omega
    accuracy_decimals: 0
  - platform: template
    name: Weight Marleen
    id: weight_user2
    unit_of_measurement: "kg"
    icon: mdi:weight-kilogram
    state_class: "measurement"
    accuracy_decimals: 2
  - platform: template
    name: Impedance Marleen
    id: impedance_user2
    unit_of_measurement: "ohm"
    icon: mdi:omega
    accuracy_decimals: 0

69 kg to 77.49 kg is assigned to Marleen 77.5 kg to 83 kg is assigned to Martijn

All other values are ignored.

You could also include the impedance to further finetune it, but in my case they are too close to each other to be useful.

TheFes avatar Dec 16 '21 12:12 TheFes

C'est plus une question.

Est-il possible d'ignorer toutes les données/mises à jour/états/attributs lorsqu'une personne utilise une balance de moins de 80 kg ?

La raison est la suivante : moi, principal utilisateur de l'intégration, je pèse plus de 80 kg. Mais tous les autres membres de notre foyer pèsent moins de 80 kg et ils ne sont pas intéressés par les détails, sauf le poids que la balance affiche lorsqu'ils l'utilisent. Mais cela détruit mes données à long terme. Alors, est-il possible d'éviter toutes les données transférées ou stockées lorsque l'utilisateur est en dessous de 80Kg ?

Bien sûr, un arrangement multi-utilisateurs serait préférable, mais pour le début, cela aiderait à sauter tout en dessous de 80 kg.

Merci

Did you solve your problem?

dckiller51 avatar Jan 14 '23 10:01 dckiller51