Your code looks fine, so just an idea: since you don’t define a unique_id; if you change the details of the sensor and reload the yaml, HA will think you’ve defined a new sensor. If you didn’t change the name, HA will add an _2 or _3 etc to the entity ID to avoid conflicting with the first one.
So the scenario is:
you created the YAML sensor, unknowingly made a mistake in the template, and reloaded the YAML.
Saw that the sensor called sensor.v_my_weight2 was “unknown” so went back into the code and fixed the template and reloaded the yaml
Looked at the original sensor entity ID and saw that sensor.v_my_weight2 was still unknown without realizing that you should instead be looking at an entitiy ID that is sensor.v_my_weight2_2
That template isn’t going to achieve anything, but I’m not sure what your end goal is either.
If you want to track every weight that is below 80 on one entity, and every weight that is above (or equal to 80) on another entity, this would be one option:
Well, yours is certainly shorter (nicer), but mine did work, if the weight was below 80, it did not update v_my_weight. I planned to duplicate that for another that is below 80.
Anyway, thanks for your script, there is a lot of new stuff such as this.state
Mine sends both weight and impedance. The impedance is used for statistics like muscle mass.
The weight sensor is updated first and then the impedance sensor. By triggering on the impedance sensor I ensure I combine both weight and impedance of the same person. Otherwise it could be that I use the weight of one person, and the impedance of the person who used the scale earlier
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.
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’>)