Strange things happen when I tried to duplicate an entity

Got an entity which gives me the photovoltaics power from the Fronius integration.
solarnet_power_photovoltaics

Since I do have this in various sections of YAML and lovelace and want to play with something not utilising this entity I though, well, simply create a second entity which is a duplicate of that entity.
First attempt was like this:

template:
  - sensor:
    - unique_id: abcdef
      name: abcdef
      unit_of_measurement: W
      device_class: power
      state_class: measurement
      state: >
        {{ states('sensor.solarnet_power_photovoltaics') |float(default=0) }}

and it looked as if it would work, until I realised that I see at most 24hrs and nothing back (even after having it up and running like this for a week or so.
Then I tried the next way which springs to mind, which is also somewhat shorter in YAML.

sensor:
  - platform: group
    type: last
    unique_id: abcdef
    name: abcdef
    entities:
      - sensor.solarnet_power_photovoltaics

which suffers the same problem, trying to see data from yesterday is impossble since not being there.
developer tools>states>selecting the entity, then pressing show more, also shows 1 day whichever timespan I do select. adding the original entity besides does show values from the past.

And I have no idea about what’s wrong with it, or if there’s a differnt way to get this solved.
Someone got a clue on that?

There’s nothing wrong with either of them that I can see. Their history should extend back until either their creation date or your recorder purge date (10 days by default).

Any relevant errors in Settings → System → Logs ?

Not sure what you mean by “nothing back”. Are you saying the entity doesn’t exist after 24 hours? Keep in mind, if you just added the template sensor, you have to restart. A reload will not initialize this entity unless you have other template sensors in your system. Secondly, if you have other template entities in your system, this one needs to go inside that template section. Otherwise, if you have 2 template sections, the second will overwrite the first before the entities are loaded in. But that should cause errors in your logs.

Anything you create will only contain a history from when you created it and onward. Entities based on other entities do not retroactively fill your database with past data.

@petro
yes I’m aware I can’t auto create older data, but this was running since a week or more.
@tom_I
oh dear … it might have been the temperatures or too much from the wrong bottle.
But when I read the word “recorder” something did spring to mind and I found the misery.
The problem sits in front of the keyboard as most time.

As said in my earlier post I duplicated an entity just because I wanted

  • to play with it trying out some things
  • wanted to be sure to get rid of all that waste generated by my trials

so I implemented a short automation which goes like this:

trigger:
  - platform: time
    at: "00:00:01"
action:
  - service: recorder.purge_entities
    data:
      keep_days: 0

containg the duplicated entity I tried various things with.

And yes the logbook does show the automation was fired as 00:00:01 … as I told HA to do so and since I rarely have a look around midnight the data from the day before was gone in the morning.
Computers … they simply do what you tell them to do, no matter if that makes sense or now.

Thanks a lot … without that hint about the “recorder” I would have likely spent another 2hrs or days trying to find out why such a simple template does fail.

1 Like