Don’t think that’s possible unless they are really having different weights
My idea was to have 10 phystical MQTT buttons, press yours before stepping on. It would be even better if I don’t have to add buttons for each new person.
I do see possibilities with those buttons. Without them it will only work if there is no overlap in weights
hi, is there a chance to get this fixed - i think i dont understand the solution:
i have 2 users
both with impedance and weight:
{% set weight = states(‘sensor.mi_body_composition_scale_acf7_mass’) | float %}
{% if 93 <= weight <= 112.99 %}
{{ states(“sensor.mi_body_composition_scale_acf7_impedance”) }}
{% else %}
{{ states(“sensor.impedanz_user1”) }}
{% endif %}
Sensor None has device class ‘None’, state class ‘measurement’ unit ‘ohm’ and suggested precision ‘None’ thus indicating it has a numeric value; however, it has the non-numeric value: ‘unknown’ (<class ‘str’>)
Test this code…
{% set weight = states('sensor.mi_body_composition_scale_acf7_mass') | float(0) %}
{% if 93 <= weight <= 112.99 %}
{{ states('sensor.mi_body_composition_scale_acf7_impedance') }}
{% else %}
{{ states('sensor.impedanz_user1') }}
{% endif %}
What’s the current state of sensor.impedanz_user1
it is “unknown”
and sensor.mi_body_composition_scale_acf7_impedance is 425
i did some restarts …
The last measured weight is probably either below 93, or above 113, so it wants to use the current state of the sensor itself.
However, as that is unknown
it doesn’t accept that.
This will resolve itself after the person weighing above 93 and below 113 used the scale.
Can you post your full code?
it needs to be a trigger based template sensor, you can’t use a template helper for this.
hi. i have it all in gui as template sensors - how should i post as code?
i copied it out:
impedanz_user1:
{% set weight = states('sensor.mi_body_composition_scale_acf7_mass') | float %}
{% if 93 <= weight <= 112.99 %}
{{ states("sensor.mi_body_composition_scale_acf7_impedance") }}
{% else %}
{{ states("sensor.impedanz_user1") }}
{% endif %}
impedanz_user2
{% set weight = states('sensor.mi_body_composition_scale_acf7_mass') | float %}
{% if 80 <= weight <= 92.99 %}
{{ states("sensor.mi_body_composition_scale_acf7_impedance") }}
{% else %}
{{ states("sensor.impedanz_user2") }}
{% endif %}
gewicht_user1
{% set weight = states('sensor.mi_body_composition_scale_acf7_mass') | float %}
{% if 93 <= weight <= 112.99 %}
{{ states("sensor.mi_body_composition_scale_acf7_mass") }}
{% else %}
{{ states("sensor.gewicht_user1") }}
{% endif %}
gewicht_user2
{% set weight = states('sensor.mi_body_composition_scale_acf7_mass') | float %}
{% if 80 <= weight <= 92.99 %}
{{ states("sensor.mi_body_composition_scale_acf7_mass") }}
{% else %}
{{ states("sensor.gewicht_user2") }}
{% endif %}
well, that’s your problem. It doesn’t work if you create it in the GUI.
You need to create a trigger based template sensor for this solution to work, which can not be done in the GUI.
I use a trigger based template sensor in my solution to store the weight of the different persons using the scale.
If you don’t use a trigger based template sensor, my weight sensor will be unavailable after my girlfriend used the scale (or when the weight sensor of the scale itself loses it’s state).
so i have to delete it and create it via yaml.
Would you be so nice to share your code
my code was already linked here
thanks
this helpers are filled external?
input_number.weight_martijn_min & max
yes, they make it easier to change the thresholds without adjusting the configuration for the template sensors.
nice i found that you @TheFes have a good splitted configuration.
OLD:
Now i am struggeling how to copy it to my world
I have some templates directly in configuration.yaml
is it possible to outsource the miscale part to an extra file AND untouch my current templates in configuration.yaml?
i have tried with template: !include xiaomi_scale_person.yaml
but I’ve got “duplicate key”
i read Splitting up the configuration - Home Assistant but it did not help me
NEW: i found a way.
after check yaml before restart if got in log:
Logger: homeassistant.config
Quelle: config.py:622
Erstmals aufgetreten: 10:16:26 (2 Vorkommnisse)
Zuletzt protokolliert: 10:27:27
Invalid config for 'template' at configuration.yaml, line 86: expected a dictionary '', got [{'trigger': [{'platform': 'state', 'entity_id': 'sensor.mi_body_composition_scale_acf7_impedance', 'not_to': 'unavailable'}], 'sensor': [{'unit_of_measurement': 'kg', 'icon': 'mdi:weight-kilogram', 'state_class': 'measurement', 'state': "{% set type = ['impedance', 'weight'] | select('in', this.entity_id) | join %} {% set w = states('sensor.mi_body_composition_scale_acf7_mass') | float(0) %} {% set i = states('sensor.mi_body_composition_scale_acf7_impedance') | float(0) %} {% set s = i if ty...
so maybe i have a typo or something missing?
Is it enough to delete my old templates and create 4 input helper for min and max or is there anything else i have to create?
my configurationyaml part of template is:
template:
- !include xiaomi_scale_person.yaml
- sensor:
- name: "Gaszähler m³"
unit_of_measurement: m³
device_class: gas
icon: mdi:meter-gas
state: "{{ states ('counter.gaspuls') | float * 0.01}}"
state_class: "total_increasing"
- name: Gaspreis (m³)
state: "{{ ((((states ('input_number.gaspreis') | float) | float * (states ('input_number.gas_zustandszahl') | float)) | float * (states ('input_number.gas_brennwert') | float)) | round(4)) }}"
unit_of_measurement: "€/m³"
.
.
. etc.
i am now one stop further.
i pasted it in configurationyaml - next time i will try splitted
weight for me was set correct but impedance got the same value:
- trigger:
- platform: state
entity_id: sensor.mi_body_composition_scale_acf7_impedance
not_to: "unavailable"
sensor:
- unique_id: 8523c401-c2a0-48d9-9669-3fdbe51ba8c4
name: Gewicht Jan
<<: &config_weight
unit_of_measurement: kg
icon: mdi:weight-kilogram
<<: &config_general
state_class: measurement
state: >
{% set type = ['impedance', 'weight'] | select('in', this.entity_id) | join %}
{% set w = states('sensor.mi_body_composition_scale_acf7_mass') | float(0) %}
{% set i = states('sensor.mi_body_composition_scale_acf7_impedance') | float(0) %}
{% set s = i if type == 'impedance' else w %}
{%- if states('input_number.gewicht_jan_min') | float < w <= states('input_number.gewicht_jan_max') | float %}
{% set name = 'jan' %}
{%- elif states('input_number.gewicht_steffi_min') | float < w <= states('input_number.gewicht_steffi_max') | float %}
{% set name = 'steffi' %}
{%- else %}
{% set name = 'no update' %}
{%- endif %}
{{ s if name in this.entity_id and s != 0 else this.state }}
- trigger:
- platform: state
entity_id: sensor.mi_body_composition_scale_acf7_impedance
not_to: "unavailable"
sensor:
- unique_id: 3721a548-59e5-445a-bfa4-4872da3d9b2e
name: Gewicht Steffi
<<: *config_weight
<<: *config_general
- trigger:
- platform: state
entity_id: sensor.mi_body_composition_scale_acf7_impedance
not_to: "unavailable"
sensor:
- unique_id: 97f05a38-a889-4363-8fe3-362a9c801040
name: Impedanz Jan
<<: &config_impedance
unit_of_measurement: ohm
icon: mdi:omega
<<: *config_general
- trigger:
- platform: state
entity_id: sensor.mi_body_composition_scale_acf7_impedance
not_to: "unavailable"
sensor:
- unique_id: 8d23659c-0745-4f72-acae-ee9fca525e6f
name: Impedanz Steffi
<<: *config_impedance
<<: *config_general
Could it be some problem of translations?!
would someone be so kind and paste a simpler version of template sensors for the scales for 3 persons?
the one in the github link I was not able to make it work way too smart for me to handle
Sorry for the stupid question, but where does this go? It’s not an automation, does this entire snippet go into configuration.yaml?