I’ve tried to make sensor with your recomendations, but still have no in it.
Also I try to change mqtt setting - earlier it was like z2m:
MQTT_HOST: mqtt://core-mosquitto
now it’l like in mqtt explorer:
MQTT_HOST: 192.168.31.160
And i still can see info in mqtt topic via mqtt explorer, but not in sensor
Summary
- platform: mqtt
name: "Nika Weight"
state_topic: "miscale/Nika/weight"
value_template: "{{ value_json.weight }}"
# value_template: "{{ value_json['weight'] }}"
unit_of_measurement: "kg"
# json_attributes_topic: "miscale/Nika/weight"
icon: mdi:scale-bathroom
# Below lines only needed if long term statistics are required
state_class: "measurement"
- platform: mqtt
name: "Nika BMI"
state_topic: "miscale/Nika/weight"
# value_template: "{{ value_json['bmi'] }}"
value_template: "{{ value_json.bmi }}"
icon: mdi:human-pregnant
unit_of_measurement: "kg/m2"
# Below lines only needed if long term statistics are required
state_class: "measurement"
2022-03-04 21:29:12 - Starting Xiaomi mi Scale...
2022-03-04 21:29:12 - Loading Config From Add-On Options...
2022-03-04 21:29:12 - Config Loaded...
2022-03-04 21:29:12 - Discovery Completed...
2022-03-04 21:29:13 - Publishing data to topic miscale/Nika/weight: {"weight":95.60,"weight_unit":"kg","bmi":41.38,"basal_metabolism":1589.55,"visceral_fat":13.37,"lean_body_mass":59.45,"body_fat":49.59,"water":36.00,"bone_mass":2.92,"muscle_mass":45.28,"protein":11.36,"body_type":"Thick-set","metabolic_age":80,"impedance":386,"timestamp":"2022-03-04T21:29:12+00:00"}
2022-03-04 21:29:13 - Data Published ...
2022-03-04 21:30:58 - Publishing data to topic miscale/Nika/weight: {"weight":95.60,"weight_unit":"kg","bmi":41.38,"basal_metabolism":1589.55,"visceral_fat":13.37,"lean_body_mass":59.41,"body_fat":49.63,"water":35.97,"bone_mass":2.92,"muscle_mass":45.24,"protein":11.35,"body_type":"Thick-set","metabolic_age":80,"impedance":392,"timestamp":"2022-03-04T21:30:58+00:00"}
2022-03-04 21:30:58 - Data Published ...
Summary
And in the same time i used HACS addon https://github.com/dckiller51/bodymiscale
Sensors (with different names):
- platform: template
sensors:
weight_nika:
friendly_name: "Вес Ника"
value_template: >-
{% set weight = states('sensor.ble_weight_mi_scale') | float(0) %}
{% if 70.0 <= weight < 100.0 %}
{{ states("sensor.ble_weight_mi_scale") }}
{% else %}
{{ states("sensor.weight_nika") }}
{% endif %}
unit_of_measurement: 'kg'
icon_template: mdi:weight-kilogram
- platform: template
sensors:
impedance_nika:
friendly_name: "ИМТ Ника"
value_template: >-
{% set weight = states('sensor.ble_weight_mi_scale') | float(0) %}
{% if 70.0 <= weight < 100.0 %}
{{ states("sensor.ble_impedance_mi_scale") }}
{% else %}
{{ states("sensor.impedance_nika") }}
{% endif %}
unit_of_measurement: 'Ohm'
icon_template: mdi:omega
And they are working!
And I still don’t understand, whats wrong with my mqtt-based sensors =(
MQTT addon configuration is more flexible for multiple users…