usda-hass-config/template_sensors/precision_scale.yaml

26 lines
878 B
YAML

- name: Precision Scale Stable
unique_id: precision_scale_stable
unit_of_measurement: "oz"
state: >-
{% set value = states("sensor.precision_scale_serial") %}
{% if not value | contains('M') %}
{% set temp_value = value | regex_findall_index('\d+\.\d+(?=oz)') | float %}
{% if value | contains('-') %}
{% set temp_value = temp_value * -1 %}
{% endif %}
{{ temp_value | round(4) }}
{% else %}
{{ states("sensor.precision_scale_stable") | round(4) }}
{% endif %}
- name: Precision Scale
unique_id: precision_scale
unit_of_measurement: "oz"
state: >-
{% set value = states("sensor.precision_scale_serial") %}
{% set temp_value = value | regex_findall_index('\d+\.\d+(?=oz)') | float %}
{% if value | contains('-') %}
{% set temp_value = temp_value * -1 %}
{% endif %}
{{ temp_value | round(4) }}