knudsvik / EnergyScore

Custom Integration for Home Assistant to score how energy is utilized based on price point
MIT License
36 stars 4 forks source link

Cost and potential_savings without unique_id #108

Closed miguelpucela closed 1 year ago

miguelpucela commented 1 year ago

I have configured several energyscore sensors like these:

- platform: energyscore
  name: Eficiency 1
  price_entity: sensor.actual_price
  energy_entity: sensor.energy1
- platform: energyscore
  name: Eficiency 2
  price_entity: sensor.actual_price
  energy_entity: sensor.energy2
- platform: energyscore
  ...

The problem is that the integration only generates the new cost and potential_savings entities for the first sensor, but not for the rest.

I get an error in the log like this:

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:540
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 12:23:50 (2 occurrences)
Last logged: 12:23:50
Platform energyscore does not generate unique IDs. ID None_cost already exists - ignoring sensor.eficiency1_cost
Platform energyscore does not generate unique IDs. ID None_potential_savings already exists - ignoring sensor.eficiency1_potential_savings

If I set the optional unique_id for each sensor, it does create cost and potential_savings entities and there's no error in the logs.

knudsvik commented 1 year ago

Thanks for reporting! I see the problem here and need to think how to solve it. Generally I would recommend to setup EnergyScore in UI instead of yaml!

miguelpucela commented 1 year ago

I've set up by UI and evedrything is working OK.

Thank you!

jvuotila commented 1 year ago

Same problem. So it's not possible to use with multiple devices at the moment?

knudsvik commented 1 year ago

I have not provided the fix yet. If you provide unique id's it will work. It also works when setting up in the UI (recommended). I'll try to have a fix for this later today.

jvuotila commented 1 year ago

My use case is this: I have six different devices and property's total energy consumption which I want to monitor.

So I need seven different EnergyScore sensors. Seems that adding unique_id for each sensor doesn't fix the problem.

  - platform: energyscore
    unique_id: 8c966acb-b361-4e56-b2c1-19404e4e5143
    name: Kiinteistö energyscore (Property)
    energy_entity: sensor.energy_consumption_total_monthly
    price_entity: sensor.nordpool_in_euros

  - platform: energyscore
    unique_id: 866562e5-0eec-42c7-8bb1-e4613fb74a06
    name: Pyykkikone energyscore (Washing machine)
    energy_entity: sensor.pyykkikone_energy
    price_entity: sensor.nordpool_in_euros

  - platform: energyscore
    unique_id: 0399efc4-687f-4a2b-83c7-29fb1ed739a3
    name: Kuivausrumpu energyscore (Dryer)
    energy_entity: sensor.kuivausrumpu_energy
    price_entity: sensor.nordpool_in_euros

  - platform: energyscore
    unique_id: 959dcad3-7341-45e6-bf86-6c354707f290
    name: Tiskikone energyscore (Dish washer)
    energy_entity: sensor.tiskikone_energy
    price_entity: sensor.nordpool_in_euros

  - platform: energyscore
    unique_id: ffe5310d-8933-4587-a108-02c22e7d8749
    name: VILP energyscore (Water-to-air heat pump house)
    energy_entity: sensor.vilp_energy
    price_entity: sensor.nordpool_in_euros

  - platform: energyscore
    unique_id: 4ca3d7e4-72c9-463f-afc6-11a2269b6fed
    name: ILP Autotalli energyscore (Air pump garage)
    energy_entity: sensor.ilp_autotalli_energy
    price_entity: sensor.nordpool_in_euros

  - platform: energyscore
    unique_id: f56479a2-710f-44cb-b613-d7e005fb214e
    name: ILP ET energyscore (Air pump hallway)
    energy_entity: sensor.ilp_eteinen_energy
    price_entity: sensor.nordpool_in_euros

UI should look like this. First graph (Kiinteistö) is configured on integration UI.

image

knudsvik commented 1 year ago

@jvuotila As long as you provide unique_id´s you should not have the same issue as @miguelpucela as far as I can understand. Do you see any errors in the log regarding unique_id´s too?

jvuotila commented 1 year ago

Sorry, my bad. Just added those unique_id's and seems that after waiting 1-2 hours it seems to be working.