home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.65k stars 30.41k forks source link

Missing entity in cards #94056

Closed accountgit closed 1 year ago

accountgit commented 1 year ago

The problem

I have some tasmota devices, all added without problem in HA and created a couple of utility_meter entities related to it:

sensor:
  - platform: template
    sensors:
      site1_energy_bill_hourly:
        friendly_name: bill energy hour site1
        value_template: '{{ states("sensor.site1_energy_hourly") | float * states("sensor.pvpc") | float }}'
        unit_of_measurement: '€'
        icon_template: hass:currency-eur
  - platform: template
    sensors:
      site2_energy_bill_hourly:
        friendly_name: bill energy hour site2
        #value_template: '{{ states("sensor.site2_energy_hourly") | float * states("sensor.pvpc") | float }}'
        value_template: '{{ "%.8f" | format((states("sensor.site2_energy_hourly") | float * states("sensor.pvpc") | float)) }}'
        unit_of_measurement: '€'
        icon_template: hass:currency-eur

utility_meter:
  site1_energy_hourly:
    source: sensor.site1_energy_today
    cycle: hourly
    offset:
      minutes: 59
  site1_energy_bill_daily:
    source: sensor.site1_energy_bill_hourly
    cycle: daily
  site1_energy_monthly:
    source: sensor.site1_energy_today
    cycle: monthly
    offset:
      days: 14
  site1_energy_bill_monthly:
    source: sensor.site1_energy_bill_hourly
    cycle: monthly
    offset:
      days: 14
  site2_energy_hourly:
    source: sensor.site2_energy_today
    cycle: hourly
    offset:
      minutes: 59
  site2_energy_bill_daily:
    source: sensor.site2_energy_bill_hourly
    cycle: daily
  site2_energy_monthly:
    source: sensor.site2_energy_today
    cycle: monthly
    offset:
      days: 14
  site2_energy_bill_monthly:
    source: sensor.site2_energy_bill_hourly
    cycle: monthly
    offset:
      days: 14

The pvpc sensor came from Spain electricity hourly pricing (PVPC) integration.

When the value of any of the bill float values (XXXX_energy_bill_hourly or XXXXXX_energy_bill_monthly) it's under 1 (0.XXXXXXXXX) the entites are displayed correctly in the lovelace cards related to it , but I think that at the moment that any of the values goes over 1 in browser console log appears the message

Uncaught (in promise) RangeError: invalid digits value: 21
    a format_number.ts:74
    v compute_state_display.ts:112
    y compute_state_display.ts:54
    value hui-sensor-entity-row.ts:83
    update lit-element.ts:160
    performUpdate reactive-element.ts:1331
    scheduleUpdate reactive-element.ts:1263
    _$Ej reactive-element.ts:1235
    requestUpdate reactive-element.ts:1210
    set reactive-element.ts:726
    value hui-entities-card.ts:75
    value hui-entities-card.ts:74
    value hui-view.ts:151
    value hui-view.ts:149
    performUpdate reactive-element.ts:1331
    scheduleUpdate reactive-element.ts:1263
    _$Ej reactive-element.ts:1235
    requestUpdate reactive-element.ts:1210
    set reactive-element.ts:726
    value hui-root.ts:593
    _$AE reactive-element.ts:1380
    performUpdate reactive-element.ts:1345
    scheduleUpdate reactive-element.ts:1263
    _$Ej reactive-element.ts:1235
    requestUpdate reactive-element.ts:1210
    set reactive-element.ts:726
    j lit-html.ts:1868
    _$AI lit-html.ts:1810
    v lit-html.ts:1180
    g lit-html.ts:1525
    _$AI lit-html.ts:1372
    $ lit-html.ts:2168
    update lit-element.ts:165
    performUpdate reactive-element.ts:1331
    scheduleUpdate reactive-element.ts:1263
    _$Ej reactive-element.ts:1235
    requestUpdate reactive-element.ts:1210
    set reactive-element.ts:726
    value partial-panel-resolver.ts:112
    value hass-router-page.ts:91
    performUpdate reactive-element.ts:1331
    scheduleUpdate reactive-element.ts:1263
    _$Ej reactive-element.ts:1235
    requestUpdate reactive-element.ts:1210
    set reactive-element.ts:726
    j lit-html.ts:1868
    _$AI lit-html.ts:1810
    v lit-html.ts:1180
    g lit-html.ts:1525
    _$AI lit-html.ts:1372
    $ lit-html.ts:2168
    update lit-element.ts:165
[format_number.ts:74:13](https://raw.githubusercontent.com/home-assistant/frontend/20230503.3/src/common/number/format_number.ts)
    _$Ej reactive-element.ts:1233
    AsyncFunctionThrow self-hosted:814
    (Async: async)
    requestUpdate reactive-element.ts:1210
    set reactive-element.ts:726
    value hui-entities-card.ts:75
    forEach self-hosted:203
    value hui-entities-card.ts:74
    value hui-view.ts:151
    forEach self-hosted:203
    value hui-view.ts:149
    performUpdate reactive-element.ts:1331
    scheduleUpdate reactive-element.ts:1263
    _$Ej reactive-element.ts:1235
    AsyncFunctionNext self-hosted:810
    (Async: async)
    requestUpdate reactive-element.ts:1210
    set reactive-element.ts:726
    value hui-root.ts:593
    _$AE reactive-element.ts:1380
    performUpdate reactive-element.ts:1345
    scheduleUpdate reactive-element.ts:1263
    _$Ej reactive-element.ts:1235
    AsyncFunctionNext self-hosted:810
    (Async: async)
    requestUpdate reactive-element.ts:1210
    set reactive-element.ts:726
    j lit-html.ts:1868
    _$AI lit-html.ts:1810
    v lit-html.ts:1180
    g lit-html.ts:1525
    _$AI lit-html.ts:1372
    $ lit-html.ts:2168
    update lit-element.ts:165
    performUpdate reactive-element.ts:1331
    scheduleUpdate reactive-element.ts:1263
    _$Ej reactive-element.ts:1235
    AsyncFunctionNext self-hosted:810
    (Async: async)
    requestUpdate reactive-element.ts:1210
    set reactive-element.ts:726
    value partial-panel-resolver.ts:112
    value hass-router-page.ts:91
    performUpdate reactive-element.ts:1331
    scheduleUpdate reactive-element.ts:1263
    _$Ej reactive-element.ts:1235
    AsyncFunctionNext self-hosted:810
    (Async: async)
    requestUpdate reactive-element.ts:1210
    set reactive-element.ts:726
    j lit-html.ts:1868
    _$AI lit-html.ts:1810
    v lit-html.ts:1180
    g lit-html.ts:1525
    _$AI lit-html.ts:1372
    $ lit-html.ts:2168
    update lit-element.ts:165

and that specific variable doesn't appear in the card.

The values are saved in HA because I can see them in history of the values from "History" option and I can see them being received from the websocket in the network tab of the browser, but it's failing to parse them on the frontend. I tried changing the value of the template to use the format using "%.8f" but continues happening the same.

I'm using: Home Assistant 2023.5.4 Supervisor 2023.04.1 Operating System 10.2 Frontend 20230503.3 - latest

A value that is appearing is: "s":"0.02427397" and one that it's missing in the card is: "s":"1.117355880000000000000"

What version of Home Assistant Core has the issue?

core-2023.5.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

accountgit commented 1 year ago

I managed to make it work assigning a uuid in the sensor like:

    sensors:
      site1_energy_bill_hourly:
        unique_id : 87dba62e-51b4-435e-b294-f58332d73ace
        friendly_name: bill energy hour site1
        value_template: '{{ states("sensor.site1_energy_hourly") | float * states("sensor.pvpc") | float }}'
        unit_of_measurement: '€'
        icon_template: hass:currency-eur

and in developer tools -> statistics -> search for the sensor -> settings and change the display resolution to something different (like 0,0000).