usda-hass-config/template_sensors/sheller_scale.yaml

26 lines
946 B
YAML

- name: Sheller Scale Stable
unique_id: sheller_scale_stable
unit_of_measurement: "lb"
state: >
{% set value = states("sensor.sheller_scale_serial") %}
{% if value | contains('S') %}
{% set temp_value = value | regex_findall_index('\d+\.\d+(?= lb)') | float %}
{% if value | contains('-') %}
{% set temp_value = temp_value * -1 %}
{% endif %}
{{ ((temp_value * 50 - (0.5 if temp_value > 0 else -0.5)) | int | float / 50) }}
{% else %}
{{ states("sensor.sheller_scale") }}
{% endif %}
- name: Sheller Scale
unique_id: sheller_scale
unit_of_measurement: "lb"
state: >
{% set value = states("sensor.sheller_scale_serial") %}
{% set temp_value = value | regex_findall_index('\d+\.\d+(?= lb)') | float %}
{% if value | contains('-') %}
{% set temp_value = temp_value * -1 %}
{% endif %}
{{ ((temp_value * 50 - (0.5 if temp_value > 0 else -0.5)) | int | float / 50) }}