KoljaWindeler / energy_calc

A custom integration for Homeassistant that provides an overview about solar power usage
4 stars 2 forks source link

cannot import name 'States' from 'homeassistant.components.recorder.models #1

Open tkruger206 opened 2 years ago

tkruger206 commented 2 years ago

Hi K-W,

Thank you for making this great integration.

I am seeing the following error in logs when trying to load the integration. I have tried using the HACS/GUI install and setup method as well as the manual install and setup. I see the same error with both. I see you made some edits a few months ago for "States", not sure if HA has changed things again or the issue you had persisted. Appreciate any help here. Thanks.

Logger: homeassistant.setup Source: setup.py:298 First occurred: 1:52:30 PM (1 occurrences) Last logged: 1:52:30 PM

Unable to prepare setup for platform energy_calc.sensor: Platform not found (cannot import name 'States' from 'homeassistant.components.recorder.models' (/usr/src/homeassistant/homeassistant/components/recorder/models.py)).

Full logs 2022-07-09 13:52:30 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform energy_calc.sensor: Platform not found (cannot import name 'States' from 'homeassistant.components.recorder.models' (/usr/src/homeassistant/homeassistant/components/recorder/models.py)).

KoljaWindeler commented 2 years ago

Hi, short fyi: I'm on it. Fixed it some days ago but seeing issues. Have a running version that should also increase calculation accuracy.. testing tonight and tomorrow and will update if no more bugs appear

tkruger206 commented 2 years ago

Das ist dope. Prost Kumpel. Du bist eine Legende.

KoljaWindeler commented 2 years ago

:) also bei mir tut das jetzt wieder .. guck mal bitte nach ob es bei dir auch der Fall ist

Schorseg commented 2 years ago

works for me as well

tkruger206 commented 2 years ago

Works for me too.

Is there a way to take the attributes from the sensor and make them as energy meter entity?

I was looking to use the attribute output of this to feed into the energy dashboard for return to grid stats etc.

Thanks, Tim

On Jul 14, 2022, at 12:34, Schorseg @.***> wrote:

works for me as well

— Reply to this email directly, view it on GitHub https://github.com/KoljaWindeler/energy_calc/issues/1#issuecomment-1184822654, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHE7VTOYHA6XKOFYR4IZSZ3VUBTSVANCNFSM53D5XI6A. You are receiving this because you authored the thread.

Schorseg commented 2 years ago

Yes that does work. You can add it to the template: section and do it similar to this

template:

  • sensor:
    • name: "grid2homekwh" unit_of_measurement: "kWh" state: "{{state_attr('sensor.energy_calc', 'Grid_tohome[kWh]')}}" device_class: energy state_class: total
tkruger206 commented 2 years ago

Ah ja, vielen Dank.

On Jul 14, 2022, at 13:41, Schorseg @.***> wrote:

Yes that does work. You can add it to the template: section and do it similar to this

template:

sensor: