home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.59k stars 30.75k forks source link

Flick Electric integration reports energy price in cents but energy dashboard interprets it as dollars #85414

Closed 2fst4u closed 1 year ago

2fst4u commented 1 year ago

The problem

The Flick Electric integration reports energy price in cents but energy dashboard interprets it as dollars.

The Flick Electric integration gets the right current price, and can be used as a price variable for the energy dashboard, but the output is out by a factor of 100. Presumably because the dashboard is interpreting it as dollars.

What version of Home Assistant Core has the issue?

2033.1.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Flick Electric

Link to integration documentation on our website

https://www.home-assistant.io/integrations/flick_electric

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No errors.

Additional information

I only have one device reporting power usage so I can't try it with another one. To see if there is an issue there. That device is reporting the correct actual usage though, the issue is just the output of the price calculation.

home-assistant[bot] commented 1 year ago

Hey there @zephirenz, mind taking a look at this issue as it has been labeled with an integration (flick_electric) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `flick_electric` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign flick_electric` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


flick_electric documentation flick_electric source (message by IssueLinks)

ZephireNZ commented 1 year ago

I suspect there's some kind of issue between this and the energy integration.

A quick read through the code in energy and it appears to convert between energy measurements but not currency - instead defaulting to whatever currency type is set at the system level.

So the 100x difference will be because HA is assuming the sensor is in $/kWh when it's actually c/kWh.

https://github.com/home-assistant/core/blob/dev/homeassistant/components/energy/sensor.py#L450

2fst4u commented 1 year ago

I assume that's why too but I don't know how to get that fixed, it seems like a bigger issue than just an integration fix.

ZephireNZ commented 1 year ago

That was more meant as a comment to the next dev that looks at this, not asking you to do something 😅

I have mentioned in Discord to see whether I need to convert the sensor from cents to dollars, or if energy should be smarter about displaying the currency.

2fst4u commented 1 year ago

I wouldn't be able to do anything anyway!

Sounds great.

Minor question only tangentially related, does Flick present actual usage with their API? That would be awesome to be able to use.

Of all the power companies in the world imagine my surprise when I saw mine in the list of integrations haha.

ZephireNZ commented 1 year ago

Unfortunately not without relying on web scraping - which HA does not allow. And even then, the usage data is not realtime, it's about 1-2 days delayed.

The thought has been rattling in the back of my head if I want to write a 3rd party custom component to web scrape and ingest that data using the non-realtime power usage stats which HA supports.

2fst4u commented 1 year ago

Yea that would be awesome however it can work.

In any case, if we can get the energy page sorted that would be great. A real-time energy usage meter would be a cool investment anyway.

ZephireNZ commented 1 year ago

FYI - in the short term, you can create a template sensor which takes the value from flick electric and divides by 100 get to get $/kWh. Then replace that as the sensor in the energy dashboard config.

ZephireNZ commented 1 year ago

Architecture discussion thread: https://github.com/home-assistant/architecture/discussions/857

hacshacdgacs commented 1 year ago

Hey there, any chance you could drop the template in here. I'm struggling to get it to work myself

2fst4u commented 1 year ago

Hey there, any chance you could drop the template in here. I'm struggling to get it to work myself

Do you mean for the template to adjust the value? If so I used this and it works great:

template:
  - sensor:
      - name: "Flick Electric price $"
        unit_of_measurement: "$/kWh"
        state: "{{ states('sensor.flick_power_price')|float / 100 }}"

Then just use this new sensor as your price value in the energy page.

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.