bodymiscale icon indicating copy to clipboard operation
bodymiscale copied to clipboard

Multiuser Support

Open stefangries opened this issue 3 years ago • 18 comments

Hello! Thank you for your work on the integration, it is great.

I have a suggestion how to improve the integration even more. This is about multiuser support. For example, the users could be distinguished by the measured weight.

You could configure it like this for example:

bodymiscale:
  model_miscale: "181B"
  sensors:
    weight: sensor.weight_aurelien
    impedance: sensor.impedance_aurelien
  users:
    - name: "Username 1"
      height: 176
      born: "1990-04-10"
      gender: "male"
      weight_low: 70
      weight_heigh: 100
    - name: "Username 2"
      height: 170
      born: "1990-01-12"
      gender: "female"
      weight_low: 0
      weight_heigh: 70

Each user would then get his own entity. For this to be possible, the values would probably also have to be persisted in core.restore_state.

stefangries avatar May 23 '21 14:05 stefangries

Hello, at the beginning I was part in this direction then my wife and I we have a weight too close. So I went with this solution. In addition it keeps the data well after a restart.

https://community.home-assistant.io/t/exemple-xiaomi-miscale-select-the-person-who-weighs-himself-notif-action/299321

dckiller51 avatar May 23 '21 15:05 dckiller51

ESPHOME has a way to do this on sensor scale:

https://esphome.io/components/sensor/xiaomi_miscale2.html

You can add as many users as you want, granted they differ in weight ranges.

sendorm avatar Jun 05 '21 04:06 sendorm

Hello, at the beginning I was part in this direction then my wife and I we have a weight too close. So I went with this solution. In addition, it keeps the data well after a restart.

https://community.home-assistant.io/t/exemple-xiaomi-miscale-select-the-person-who-weighs-himself-notif-action/299321

Hello,

There is a solution to do this without nodered? Example with input?

norbertjoni avatar Oct 19 '21 05:10 norbertjoni

Multiuser would be fine without nodered.

Anyone got this working without node red?

Best would be that dckiller can implement this. If it is only a thing of changing the conig.yaml, can somebody give examples how to do?

criticallimit avatar Oct 30 '21 21:10 criticallimit

I'll add a Plus one - this seems like the most logical extension of this.

borpin avatar Nov 11 '21 20:11 borpin

plus 1 from my side as well!

posreg avatar Jan 30 '22 22:01 posreg

My solution is to take the readings from the scale, pass through Node-RED to check who it is and then send to their own weight/imp sensors. It also solves the retained issue at the same time.

borpin avatar Jan 31 '22 10:01 borpin

You must create one bodymiscale per user. The component is based on https://www.home-assistant.io/integrations/plant/

dckiller51 avatar Jan 31 '22 12:01 dckiller51

Dear @dckiller51, Thanks a lot for your work! Can you please provide an example of configuration for this?

You must create one bodymiscale per user. The component is based on https://www.home-assistant.io/integrations/plant/

JGAguado avatar Jul 06 '22 23:07 JGAguado

Dear @dckiller51, Thanks a lot for your work! Can you please provide an example of configuration for this?

You must create one bodymiscale per user. The component is based on https://www.home-assistant.io/integrations/plant/

hello, your request should not be here. but here is an example

https://community.home-assistant.io/t/exemple-xiaomi-miscale-select-the-person-who-weighs-himself-notif-action/299321

dckiller51 avatar Jul 07 '22 00:07 dckiller51

Hello , if i create one bodymiscale per user. Only one card show statistic but others are unavailable ,till next messure, then new is showed other are unavailable. https://ibb.co/mG2Fnrk https://ibb.co/YbLhsHG

supperka avatar Apr 25 '23 21:04 supperka

Hello , if i create one bodymiscale per user. Only one card show statistic but others are unavailable ,till next messure, then new is showed other are unavailable. https://ibb.co/mG2Fnrk https://ibb.co/YbLhsHG

Hello, Any updates on this? I have the same issue.

SkyTakes avatar Oct 26 '23 04:10 SkyTakes

plus 1

s3tFlag avatar Nov 13 '23 18:11 s3tFlag

plus 1

What is your configuration? it is important to have a weight and impedance sensor for each user.

dckiller51 avatar Nov 13 '23 18:11 dckiller51

I use templates to create a new weight sensor per person, then add that sensor to the person's bodymiscale instance. Here's an example that assigns the new scale values to the closest weight sensor:

template:
  - trigger:
      - platform: state
        entity_id:
          - sensor.mi_smart_scale_mass
    sensor:
      - name: "Person 1 Mass"
        unit_of_measurement: "kg"
        state: >
          {% set weight = states('sensor.mi_smart_scale_mass') | float %}
          {% set distance_a = (states('sensor.person_1_mass') | float - weight) | abs %}
          {% set distance_b = (states('sensor.person_2_mass') | float - weight) | abs %}
          {% if distance_a < 5 and distance_a < distance_b %}
            {{ weight }}
          {% else %}
            {{ states('sensor.person_1_mass') }}
          {% endif %}
      - name: "Person 2 Mass"
        unit_of_measurement: "kg"
        state: >
          {% set weight = states('sensor.mi_smart_scale_mass') | float %}
          {% set distance_a = (states('sensor.person_1_mass') | float - weight) | abs %}
          {% set distance_b = (states('sensor.person_2_mass') | float - weight) | abs %}
          {% if distance_b < 5 and distance_b < distance_a %}
            {{ weight }}
          {% else %}
            {{ states('sensor.person_2_mass') }}
          {% endif %}

Eskander avatar Nov 26 '23 14:11 Eskander

How about more users, like e.g. 4?

maciek188 avatar Mar 20 '24 15:03 maciek188

@maciek188, Following the same logic, something like this should work for 4 people:

Note: since HA doesn't initially know the values of sensor.person_1_mass, sensor.person_2_mass, sensor.person_3_mass and sensor.person_4_mass, they'll all be zeroes at first. You should set their proper values in Developer Tools.

template:
  - trigger:
      - platform: state
        entity_id:
          - sensor.mi_smart_scale_mass
    sensor:
      - name: "Person 1 Mass"
        unit_of_measurement: "kg"
        state: >
          {% set weight = states('sensor.mi_smart_scale_mass') | float %}
          {% set delta_a = (states('sensor.person_1_mass') | float - weight) | abs %}
          {% set delta_b = (states('sensor.person_2_mass') | float - weight) | abs %}
          {% set delta_c = (states('sensor.person_3_mass') | float - weight) | abs %}
          {% set delta_d = (states('sensor.person_4_mass') | float - weight) | abs %}
          {% if delta_a == [delta_a, delta_b, delta_c, delta_d, 5] | min %}
            {{ weight }}
          {% else %}
            {{ states('sensor.person_1_mass') }}
          {% endif %}
      - name: "Person 2 Mass"
        unit_of_measurement: "kg"
        state: >
          {% set weight = states('sensor.mi_smart_scale_mass') | float %}
          {% set delta_a = (states('sensor.person_1_mass') | float - weight) | abs %}
          {% set delta_b = (states('sensor.person_2_mass') | float - weight) | abs %}
          {% set delta_c = (states('sensor.person_3_mass') | float - weight) | abs %}
          {% set delta_d = (states('sensor.person_4_mass') | float - weight) | abs %}
          {% if delta_b == [delta_a, delta_b, delta_c, delta_d, 5] | min %}
            {{ weight }}
          {% else %}
            {{ states('sensor.person_2_mass') }}
          {% endif %}
      - name: "Person 3 Mass"
        unit_of_measurement: "kg"
        state: >
          {% set weight = states('sensor.mi_smart_scale_mass') | float %}
          {% set delta_a = (states('sensor.person_1_mass') | float - weight) | abs %}
          {% set delta_b = (states('sensor.person_2_mass') | float - weight) | abs %}
          {% set delta_c = (states('sensor.person_3_mass') | float - weight) | abs %}
          {% set delta_d = (states('sensor.person_4_mass') | float - weight) | abs %}
          {% if delta_c == [delta_a, delta_b, delta_c, delta_d, 5] | min %}
            {{ weight }}
          {% else %}
            {{ states('sensor.person_3_mass') }}
          {% endif %}
      - name: "Person 4 Mass"
        unit_of_measurement: "kg"
        state: >
          {% set weight = states('sensor.mi_smart_scale_mass') | float %}
          {% set delta_a = (states('sensor.person_1_mass') | float - weight) | abs %}
          {% set delta_b = (states('sensor.person_2_mass') | float - weight) | abs %}
          {% set delta_c = (states('sensor.person_3_mass') | float - weight) | abs %}
          {% set delta_d = (states('sensor.person_4_mass') | float - weight) | abs %}
          {% if delta_d == [delta_a, delta_b, delta_c, delta_d, 5] | min %}
            {{ weight }}
          {% else %}
            {{ states('sensor.person_4_mass') }}
          {% endif %}

Eskander avatar Mar 20 '24 15:03 Eskander

I am using BLE monitor and this integration and it shows me on the lovelace card correct data. But i want to use now 2 multi user data registered on separate lovelace card. Now i have followed this topic but don't really understand how i can do that. Can someone please help me?

terslowe avatar Mar 21 '24 19:03 terslowe