Rounding a value got from Shelly add-on

I have a Shelly ProEM measuring my air conditioning consumption. The Shelly add-on just create the device on HA and we don’t need to do anything else, that is just great.

Now, I have defined a utility meter to give me the information about how much I spent daily and monthly. My meter is defined as:

airconditioning_daily:
  source: sensor.shellyproem50_abcdef123456_em0_total_active_energy
  cycle: daily

While it is working ok, the values shows 4 decimal digits and I would like to have only 2 decimal digits. However, if it were a standard sensor I could just use “round(2)” on the “value_template” and get the problem solved. But how do I “round()” a sensor that is created by Shelly add-on? Do I have to create an specific template for this?

Thanks!

Sorry for this late response…

I went to the entities and changed the precision. It works when I click on the entity from within the entities screen. However, on the lovelace card it keeps 5 decimal places.

So the question is: Is it there a way to round it for showing on a lovelace card?

Hmm, when I click on an entity from lovelace and get the entity info (history, value, etc.), then click on the cog in the upper right corner and change the Display precision then click update, it does change the precision on the lovelace display.

So, I’m not sure why you are getting different results unless you have a custom card that is fixing the precision. What card are you using to display the entity?

The problem is that the entity comes from a Shelly. If you click on the cog, you get the following message:

If I have a standard access to the entity I could round it (i.e.: sensors from MQTT). In the same way, I have no clue how I could set an unique ID for something coming from the Shelly integration.

The only thing I think as a solution is creating a sensor template, what is quite annoying if you have several sensors with this problem. And yes, it may be a problem on the Shelly integration.

I have a number of Shelly devices (not a ShellyPro EM) and I was able to successfully change the display precision. I don’t think it is a problem with the Shelly integration.

Perhaps this community guide can help:

As said in the suggested community guide: “If it comes from an integration created using yaml, you may be able to give it a unique ID.”

The problem is that, as long as I know, there is no yaml file for Shelly sensors so you have no way to set an UID.

Are you using this Shelly Integration? If so, I don’t think the integration is created using yaml.

Yes… I am using Shelly integration. I have too many Shelly at home.
I guess I am now paying the price for being lazy :rofl: :rofl: :rofl:

I should have used MQTT. But only now I got this problem since the Pro EM was recently bought.

I found some discussions on GitHub about Shelly Pro EM 50 (Gen 2) issues. This might be related but the issue was closed. I’m assuming that “airconditioning_daily” is a friendly name for one of the actual entities?

Also, it seems some Shelly Pro EM 50s were shipped with a beta firmware. The current firmware is 1.2.2

Yes, I am measuring the air conditioning consumption. The data is ok, it shows what I need. The problem is the annoying 5 decimal places on the info. But the 5 decimals only shows on the lovelace card. The meter is defined as:

airconditioning_daily:
  source: sensor.shellyproem50_08f9e0123456_em0_total_active_energy
  cycle: daily

Since this is a value template, perhaps a unique_id can be inserted from GUID Generator.

airconditioning_daily:
  source: sensor.shellyproem50_08f9e0123456_em0_total_active_energy
  unique_id: {from the GUID generator}
  cycle: daily
1 Like

You are the guy MaxK! It works. Once I defined an UID and restarted the services I went to the card, click on entity and then on the cog. Now it allows for changing the resolution.

Problem solved!

I should have caught that on your first post but I, obviously, was not paying attention. Glad its working.