Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 109599

How to change the unit of measurement used for display in this card?

$
0
0

I am trying to post a measurement of disk usage in bytes using the CURL command. I am using the Rest API to update the state of an entity. I have set up a template sensor in the configuration.yaml file, with an empty state (so that there is a sensor ready to receive the data). It looks like this:

template:
 - sensor:
    - name: "My Disk Sensor Bytes"
      unique_id: my_disk_sensor_bytes
      unit_of_measurement: B
      state_class: measurement
      device_class: data_size
      state: ''

Now I try to send some data using CURL form another machine:

curl \
  -H "Authorization: Bearer MYTOKEN" \
  -H "Content-Type: application/json" \
  -d '{"state": "16000000000", 
       "attributes": {
	       "unit_of_measurement": "B", 
		   "state_class": "measurement", 
		   "device_class": "data", 
		   "friendly_name": "My Disk Sensor Bytes"
		   }
	  }'  \
  http://localhost:8123/api/states/sensor.my_disk_sensor_bytes

The data seems to correctly appear in Developer Tools, with the correct attributes:

When I display the entity in a standard entity card, it shows correctly the data in bytes as expected:

image

I would like to display the data here in GiB instead, since that makes the most sense at the moment for this reading. However, I want to keep the underlying data in bytes (so that values can be compared long term, is consistent, and the history graphs work properly, etc). I only want to change the display value in this card.

I tried to click on the entity and edit the unit to GiB using this menu, but it didn’t affect the reading at all:

Is there a simple way to do this?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 109599

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>