Invalid decimal literal warning

I have this warning in my log, but I have no idea where to potentially find the problem because of how vague it is:

Logger: py.warnings
Source: helpers/template.py:333
First occurred: 10:00:33 AM (2 occurrences)
Last logged: 10:00:42 AM

<unknown>:1: SyntaxWarning: invalid decimal literal

One of your entity object_ids starts with a number.

# domain.object_id 

# e.g.

light.1234_lifx

# domain == "light"

# object_id == "1234_lifx"

And you or HA is trying to use that object_id without using square bracket notation. See: https://www.home-assistant.io/docs/configuration/templating/#entity_id-that-begins-with-a-number

So you may be trying to access the last_updated or last_changed property of an entity like this:

{{ states.light.1234_lifx.last_updated }}

When you (or HA) should be doing:

{{ states.light['1234_lifx'].last_updated }}

# or

{{ states.light['1234_lifx']['last_updated'] }}

Is there another error near the one you showed above that may reveal more info on where this is occurring?

1 Like

I don’t see any errors nearby that would be causing it. Is it possible to export my entities into a csv or something? I’m just trying to figure out where this might be referenced.

Try changing the logging level to debug. That may reveal more information. Don’t leave the level at debug for longer than necessary as it is very chatty and will create a huge log file.

# Example configuration.yaml entry
logger:
  default: debug

It isn’t happening consistently. I looked in the logbook and nothing happened during the time that it happened. I restarted my server yesterday morning and it happened today at 12:25:57PM and 12:26:01PM.

I don’t think I can realistically keep debugging on for 12+ hours hoping that something will happen.

I have been hunting one of these down for two days with no luck. I get exactly two every minute, pretty much at exactly the same time.

  • searched for any devices or entities that start with a numeral - nothing
  • Removed unnecessary and weird entities from mobile app and browser mod
  • Removed suspect integrations that don’t really need - nothing
  • Disabled/enabled integrations that were suspect - nothing
  • Cleaned up all of the stupid warnings re: defaults on all my templates (a bunch) that I have been too lazy to fix - nothing
  • Turned on debug and scanned through gobs of information looking for clues as to what is causing this - nothing

Running out of ideas. Have you found anything?

On the bright side, I have done a lot of house cleaning that I have been putting off for months now.
I suppose it isn’t hurting anything but it is annoying and filling up my logs.

Finally found my issue. I had two template sensors with string expressions starting with “in…” Apparently that is a no no. Must be a reserved word or something.

In one case, the template was adding unit of measure for air pressure, e.g. [… + ‘inHg’ + …]
The other was adding unit of measure for precipitation, e.g. [… + ‘in’ + …]

Couldn’t figure a way around it using ‘in’ in any way, so escaped a " e.g. [… + ‘\u0022’ + …]

Must be something else going on that I don’t understand, but at least my logs are quiet now.