Thanks for answering man. I have it working a couple of days now but it gets errors in the logs sometimes and also it is like this is not a real sensor somehow. Like its a float that get erased after restart.
some of the errors
Error doing job: Exception in callback _async_at_core_state.<locals>._matched_event(<Event homeassistant_start[L]>) at /usr/src/homeassistant/homeassistant/helpers/start.py:37
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 616, in state
numerical_value = int(value)
^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 619, in state
numerical_value = float(value)
^^^^^^^^^^^^
ValueError: could not convert string to float: ''
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/usr/src/homeassistant/homeassistant/core.py", line 1236, in _onetime_listener
self._hass.async_run_job(listener, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 719, in async_run_job
return self.async_run_hass_job(HassJob(target), *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 671, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/helpers/start.py", line 40, in _matched_event
hass.async_run_hass_job(at_start_job, hass)
File "/usr/src/homeassistant/homeassistant/core.py", line 671, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 478, in _async_template_startup
result_info.async_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1035, in async_refresh
self._refresh(None)
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1215, in _refresh
self.hass.async_run_hass_job(self._job, event, updates)
File "/usr/src/homeassistant/homeassistant/core.py", line 671, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 429, in _handle_results
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 745, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 845, in _async_write_ha_state
state, attr = self._async_generate_attributes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 786, in _async_generate_attributes
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 751, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 623, in state
raise ValueError(
ValueError: Sensor sensor.filtered_weight_gnf has device class 'None', state class 'None' unit 'kg' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: '' (<class 'str'>)
Logger: homeassistant.helpers.event
Source: helpers/event.py:296
First occurred: December 15, 2023 at 12:39:58 (2 occurrences)
Last logged: December 15, 2023 at 12:39:58
Error while dispatching event for sensor.mi_body_composition_scale_7dc3_mass to <Job track state_changed event {'sensor.mi_body_composition_scale_7dc3_mass'} HassJobType.Callback <bound method TrackTemplateResultInfo._refresh of <TrackTemplateResultInfo {Template<template=({{ states.sensor.mi_body_composition_scale_7dc3_mass.state if ((states.sensor.mi_body_composition_scale_7dc3_mass.state) | int) < 60 }}) renders=8>: <RenderInfo Template<template=({{ states.sensor.mi_body_composition_scale_7dc3_mass.state if ((states.sensor.mi_body_composition_scale_7dc3_mass.state) | int) < 60 }}) renders=8> all_states=False all_states_lifecycle=False domains=frozenset() domains_lifecycle=frozenset() entities=frozenset({'sensor.mi_body_composition_scale_7dc3_mass'}) rate_limit=None has_time=False exception=None is_static=False>}>>>
Error while dispatching event for sensor.mi_body_composition_scale_7dc3_mass to <Job track state_changed event {'sensor.mi_body_composition_scale_7dc3_impedance', 'sensor.mi_body_composition_scale_7dc3_mass'} HassJobType.Callback <bound method TrackTemplateResultInfo._refresh of <TrackTemplateResultInfo {Template<template=({{ states.sensor.mi_body_composition_scale_7dc3_impedance.state if ((states.sensor.mi_body_composition_scale_7dc3_mass.state) | int) < 60 }}) renders=10>: <RenderInfo Template<template=({{ states.sensor.mi_body_composition_scale_7dc3_impedance.state if ((states.sensor.mi_body_composition_scale_7dc3_mass.state) | int) < 60 }}) renders=10> all_states=False all_states_lifecycle=False domains=frozenset() domains_lifecycle=frozenset() entities=frozenset({'sensor.mi_body_composition_scale_7dc3_mass'}) rate_limit=None has_time=False exception=None is_static=False>}>>>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 616, in state
numerical_value = int(value)
^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 619, in state
numerical_value = float(value)
^^^^^^^^^^^^
ValueError: could not convert string to float: ''
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 296, in _async_dispatch_entity_id_event
hass.async_run_hass_job(job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 671, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1215, in _refresh
self.hass.async_run_hass_job(self._job, event, updates)
File "/usr/src/homeassistant/homeassistant/core.py", line 671, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 429, in _handle_results
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 745, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 845, in _async_write_ha_state
state, attr = self._async_generate_attributes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 786, in _async_generate_attributes
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 751, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 623, in state
raise ValueError(
ValueError: Sensor sensor.filtered_weight_florentia has device class 'None', state class 'None' unit 'kg' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: '' (<class 'str'>)
I am trying to get the new sensor way of home assistant and not the legacy one.
template:
- trigger:
- platform: numeric_state
value_template: "{{ states('sensor.mi_body_composition_scale_7dc3_mass') | float(0) >= 60 }}"
sensor:
- unique_id: filtered_weight_gnf
name: "filtered_weight_gnf"
friendly_name: "Filtered weight GnF"
unit_of_measurement: "kg"
state: "{{ states('sensor.mi_body_composition_scale_7dc3_mass') }}"
- trigger:
- platform: numeric_state
value_template: "{{ states('sensor.mi_body_composition_scale_7dc3_mass') | float(0) >= 60 }}"
sensor:
- unique_id: filtered_impedance_gnf
name: "filtered_impedance_gnf"
friendly_name: "Filtered inpedance GnF"
unit_of_measurement: "Ω"
state: "{{ states('sensor.mi_body_composition_scale_7dc3_impedance') }}"
But i get this error.
Configuration warnings
Invalid config for 'sensor' at configuration.yaml, line 12: required key 'platform' not provided