Hi everybody,
I have this sensor grabbing data from grocy
via it’s API:
sensor:
# Wasser Nordquell Garage
- platform: rest
resource: http://home:9283/api/stock/products/1
headers:
GROCY-API-KEY: !secret grocy_api_key
name: "Vorrat Wasser Nordquell Garage"
value_template: "{{ value_json.stock_amount | int / 12 }}"
unit_of_measurement: "Kisten"
scan_interval: 300
json_attributes:
- last_purchased
- last_used
This will display it like this (entity on the very right)
I tried changing the value template to "{{ value_json.stock_amount | int / 12 | round(0) }}"
as well as "{{ value_json.stock_amount | int / 12 | string }}"
. This will both still display 5.0
.
The value can and will always be an integer without any decimal places (as it will always divide a number divisable by 12 with 12). So I would prefer to display it as an integer, not a float.
When I display the value in developer tools -> template
like this {{ states("sensor.vorrat_wasser_nordquell_garage") }}
, it will show 5
only, but lovelace still shows the comma. I thought of something like {{ (value_json.stock_amount | int / 12).split(",")[0] }}
, but that just feels wrong. Is there a cleaner way to do this?
Thank you for your input