hey there!
Is there any way to configure the unit_of_measurement of a template sensor with a template on it?
What I intend to do is something like:
- name: "Some Information"
unique_id: stock_info
device_class: monetary
unit_of_measurement: "{{ (state_attr('sensor.rest_pulldata_total', 'portfolio')['stocks'][0]| default({'currency': 'unknown'})).get('currency', 'unknown') }}"
state: "{{ (state_attr('sensor.rest_pulldata_total', 'portfolio')['stocks'][0] | default({'precio': 'unknown'})).get('precio', 'unknown') }}"
attributes:
currency: "{{ (state_attr('sensor.rest_pulldata_total', 'portfolio')['stocks'][0]| default({'currency': 'unknown'})).get('currency', 'unknown') }}"
name: "{{ (state_attr('sensor.rest_pulldata_total', 'portfolio')['stocks'][0]| default({'name': 'unknown'})).get('name', 'unknown') }}"
The state is being refreshed properly from the rest_pulldata_total sensor, and so are the attributes currency and name, but the unit_of_measurement seems to only take plain text…
Is there a way to fix this?
Thanks