zeronounours / HA-custom-component-energy-meter

Provides extended features on top of utility-meter to track costs for each tariff as well as total costs
MIT License
19 stars 2 forks source link

Add possibility to only create a cost sensor onto an already existing LTS #54

Closed rrozema closed 10 months ago

rrozema commented 11 months ago

Is your feature request related to a problem? Please describe. I find that when using the energy-meter component I often already have a LTS entity -not created through a utility-meter- for which I want to add a cost or compensation sensor. As the energy-meter always creates both the cost sensor and the utility-meter I often find myself getting duplicate LTS sensors for the exact same value.

Describe the solution you'd like I'd like a way to define an energy-meter that only adds the costs/compensation sensor to an existing LTS entity.

Describe alternatives you've considered I can't think of any alternative to create only a cost sensor without adding a duplicate LTS entity.

Additional context N/A

zeronounours commented 11 months ago

Hello @rrozema To be sure to understand, let's take an example

energy_meter:
  daily_energy:
    source: sensor.energy
    name: Daily Energy
    cycle: daily
    price_entity: sensor.current_energy_price
    tariffs:
      - peak
      - offpeak

This config will create entities the following entities

Your issue is the existence of the energy costs sensor and you'd like only the utility meter for it ?

rrozema commented 10 months ago

Let me adapt your example situation to how I most of the times use your energy meter. I almost never need the tariff: nor the cycle: options. i.e. this what it currently looks like in most cases for me:

energy_meter:
  energy_dummy:
    source: sensor.energy
    name: Energy
    price_entity: sensor.current_energy_price

This config creates these entities:

However, that is not yet how I want it to be, as this still creates a copy of my existing sensor.energy which I don't need at all. The only sensor I would like to get created is

zeronounours commented 10 months ago

I've added ability to only create energy sensor through the create_utility_meter option. It will be included within the next release (coming soon)

rrozema commented 10 months ago

Apologies to bother you again after you've been so quick to add this, but I'm not sure I understand your last message correctly. You say the create_utility_meter option creates only the energy sensor. Isn't that the exact same functionality that the standard utility meter helper has? Or did you forget to type the word 'cost' in that message?

zeronounours commented 10 months ago

create_utility_meter control whether to create the utility meter part of the energy_meter.

Energy meter create 3 kind of entities:

In your situation, the reason you get a "copy" of your sensor.energy is because of the utility meter which follows it.

Setting create_utility_meter to false or no will prevent the creation of the utility meters, leaving the energy cost sensor (if a price is defined).

rrozema commented 10 months ago

Excellent! Now I get it. Thank you very much, both for the change and the explanation. Can't wait for this to become available :-)

zeronounours commented 10 months ago

I created the release, so you can already update the integration and update your config