GithubHelp home page GithubHelp logo

firstof9 / ha-openei Goto Github PK

View Code? Open in Web Editor NEW
15.0 4.0 1.0 409 KB

OpenEI integration for Home Assistant

License: MIT License

Python 100.00%
home-assistant homeassistant integration energy rates api hacktoberfest

ha-openei's Introduction

HA-OpenEI

GitHub Release GitHub Activity License

hacs Project Maintenance BuyMeCoffee

Discord Community Forum

Component to integrate with OpenEI.org.

This component will set up the following platforms.

Platform Description
sensor Show info from OpenEI's API.

Installation

  1. Using the tool of choice open the directory (folder) for your HA configuration (where you find configuration.yaml).
  2. If you do not have a custom_components directory (folder) there, you need to create it.
  3. In the custom_components directory (folder) create a new folder called openei.
  4. Download all the files from the custom_components/openei/ directory (folder) in this repository.
  5. Place the files you downloaded in the new directory (folder) you created.
  6. Restart Home Assistant
  7. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "OpenEI Utility Rates"

Configuration is done in the UI

Step 1: Enter your API Key:

step1

Step 2: Select your utility company:

step2

Step 3.1: Select your rate plan:

step3.1 step3.2

Contributions are welcome!

If you want to contribute to this please read the Contribution guidelines


ha-openei's People

Contributors

firstof9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

woobins

ha-openei's Issues

Support data from mincharge key in API

Is your feature request related to a problem? Please describe.
A minimum fee for each month of service is charged by PG&E leading to the cost sensor being consistently offset from it's true value.

Describe the solution you'd like
I think it would be most convenient to detect which of the three possible units ($/day, month, year) are being used through the minchargeunits key and then add the value to the corresponding value sensor when the corresponding energy sensor resets.

Describe alternatives you've considered
The simplest version of this I can imagine would give a sensor with the value of mincharge and that has minchargeunits as an attribute. The compensation and detection of when the sensor resets would then be left as an exercise for the user.

Additional context
API reference

0.0.8 - Integration stuck at "Retrying setup: None"

I am running Home Assistant 2021.9.4 in Docker with HACS 1.15.2.

I have 0.0.8 installed via HACS, but I also tried other versions back to 0.0.4, and tried selecting other providers, but I keep getting "Retrying setup: None" in the Integrations page of Home Assistant.

image

The only error that appears in the logs for custom_components.openei is this repeating a few times

2021-09-07 23:39:24 ERROR (MainThread) [custom_components.openei] Error fetching openei data:

I verified my API key is working by manually requesting a rateplan with it and it successfully returned a .json with rateplan information. Since the correct utility wasn't showing in the list, I tried manually editing my Home Assistant core.config_entries to replace the utility and rateplan ID and that did not change the error or log behavior. I have also tried removing the integration, uninstalling OpenEI from HACS, restarting Home Assistant's entire Docker container, re-installing OpenEI, and then restarting the Docker container again.

Here are the logs from Home Assistant for a few minutes after startup:

2021-09-07 23:39:16 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration variable which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-09-07 23:39:16 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration weatheralerts which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-09-07 23:39:16 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-09-07 23:39:16 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration car_wash which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-09-07 23:39:16 WARNING (SyncWorker_4) [homeassistant.loader] We found a custom integration openei which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-09-07 23:39:16 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration monitor_docker which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-09-07 23:39:16 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration vivint which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-09-07 23:39:24 ERROR (MainThread) [custom_components.openei] Error fetching openei data:
2021-09-07 23:39:24 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Black Hills Power Inc' for openei integration not ready yet: None; Retrying in background
2021-09-07 23:39:33 WARNING (MainThread) [homeassistant.setup] Setup of zone is taking over 10 seconds.
2021-09-07 23:39:33 ERROR (MainThread) [hole] Can not load data from *hole: pihole.tuxrug.net:80
2021-09-07 23:39:33 WARNING (MainThread) [homeassistant.components.pi_hole] Failed to connect: Can not load data from *hole: pihole.tuxrug.net:80
2021-09-07 23:39:33 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Pi-Hole' for pi_hole integration not ready yet: Can not load data from *hole: pihole.tuxrug.net:80; Retrying in background
2021-09-07 23:39:33 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform weatheralerts is taking over 10 seconds.
2021-09-07 23:39:33 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Home' for accuweather integration not ready yet; Retrying in background
2021-09-07 23:39:44 ERROR (MainThread) [custom_components.openei] Error fetching openei data:
2021-09-07 23:40:00 ERROR (MainThread) [custom_components.openei] Error fetching openei data:
2021-09-07 23:40:20 ERROR (MainThread) [custom_components.openei] Error fetching openei data:
2021-09-07 23:41:01 ERROR (MainThread) [custom_components.openei] Error fetching openei data:

Below are my Home Assistant and HACS environment details. I just found this integration and already purged old Docker images, so I do not know if this could be a breaking change in a recent build of the Home Assistant docker image.

System Health

version core-2021.9.4
installation_type Home Assistant Container
dev false
hassio false
docker true
user root
virtualenv false
python_version 3.9.6
os_name Linux
os_version 3.10.0-1160.41.1.el7.x86_64
arch x86_64
timezone America/Denver
Home Assistant Community Store
GitHub API ok
Github API Calls Remaining 4202
Installed Version 1.15.2
Stage running
Available Repositories 945
Installed Repositories 17
AccuWeather
can_reach_server ok
remaining_requests 18
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Lovelace
dashboards 3
resources 7
views 10
mode storage

Generate entity names specific to provider or rate plan

Is your feature request related to a problem? Please describe.
First, thank you for releasing and supporting ha-openei! One minor comment: I think the sensors the integration generates should be named in a less generic fashion. binary_sensor.approval is ambiguous at best.

Describe the solution you'd like
I would suggest either naming the sensors with the electric providers name, such as binary_sensor.pacific_gas_electric_co_approval, or some other more appropriate HA convention.

Describe alternatives you've considered
I could change each entity name manually, but not sure that scales.

Additional context
none

[Feat] Filter out old records using the effective as of filter.

Version of ha-openei

latest

Describe the bug

I noticed for Wisconsin Public Service (https://openei.org/apps/USURDB/?utilRateFinder=Wisconsin+Public+Service+Corp&service_type=&effective_date=2021-09-23) I had tons and tons of plans showing with the same name as my plan (https://openei.org/apps/USURDB/rate/view/5c40c3b65457a3a70f1482c5). I had to guess what the sort was in the list. I noticed once I filtered out all the inactive it was much shorter:

image

Debug log

[BUG] Error doing job: Task exception was never retrieved

Home Assistant 2023.1.2
Supervisor 2022.12.1
Operating System 9.4
Frontend 20230104.0 - latest

I have been unable to get this integration to work. I've followed the instructions, and tried two different API keys. I've tried several different electrical plans to see if maybe I was using a deprecated one as well. Can't figure what I'm doing wrong.

As per our conversation, here are the logs including traceback. Please feel free to reach out if I can help troubleshoot.

Logger: homeassistant
Source: custom_components/openei/init.py:127
Integration: OpenEI Utility Rates (documentation, issues)
First occurred: January 8, 2023 at 9:00:00 PM (1893 occurrences)
Last logged: 10:00:03 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/openei/init.py", line 120, in _async_refresh_data
self._data = await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/openei/init.py", line 159, in get_sensors
value = getattr(rate, SENSOR_TYPES[sensor].key)
File "/usr/local/lib/python3.10/site-packages/openeihttp/init.py", line 251, in all_rates
adjs.append(rate[0]["adj"])
KeyError: 'adj'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/config/custom_components/openei/init.py", line 127, in _async_refresh_data
raise UpdateFailed() from exception
homeassistant.helpers.update_coordinator.UpdateFailed

[BUG] - Missing Adjustments $/kWh

Using Latest (Head)

This is part bug and part feature request.

With my utility they split the charges across two fields. The rate field and the adjustment field.
This library only provides the value of the rate field, which means that it's inaccurate as to the actual charges (rate + adjustment).

Other applications I've used provide the sum of these two numbers (the actual rate charged). This library ignores the adjustment portion.

[BUG] Old Home Assistant Commands causing errors.

It seems there are some older Home Assistant commands in use that are causing errors.

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/openei/init.py", line 70, in async_setup_entry
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
AttributeError: 'ConfigEntries' object has no attribute 'async_setup_platforms'

https://developers.home-assistant.io/blog/2022/07/08/config_entry_forwards/

[BUG] Reconfiguring integration doesn't update the selected plan.

Version of ha-openei

Latest beta

Describe the bug

If you reconfigure an existing instance via integrations and choose a new plan, that plan isn't persisted. It looks like it always saves the first selected plan and not an updated plan.

Also some feedback on that wizard. If we could have a link to the selected plan so we could inspect the rates that would be awesome!

Debug log

[BUG] Wizard to configure never starts

Version of ha-openei

Latest installed through HACS
HA-OpenEI 0.1.10
HA 2023.5.4

Describe the bug

A clear and concise description of what the bug is.

After installation I attempt to add the component. It opens a pop-up saying the wizard is starting. It never proceeds.

Screenshot_20230725_022955_Chrome

Debug log

There were no errors in the log. I can enable a different level if they will help. It's not clear to me how to set this up for just this component.

[BUG] Sensor implements device_state_attributes

Version of ha-openei

0.1.5

Describe the bug

As of Home Assistant version 2021.12.0, the usage of device_state_attributes is deprecated. It seems extra_state_attributes should be used from now on.
This is the only place I found that states the replacement home-assistant/core#47304 and I found docs about it here https://developers.home-assistant.io/docs/core/entity/#generic-properties
It looks like they just renamed it as a PR with this change can be found here https://github.com/home-assistant/core/pull/59672/files.

Debug log

[homeassistant.helpers.entity] Entity sensor.pacificorp_idaho_current_energy_rate (<class 'custom_components.openei.sensor.OpenEISensor'>) implements device_state_attributes. Please report it to the custom component author.
[homeassistant.helpers.entity] Entity sensor.pacificorp_idaho_distributed_generation (<class 'custom_components.openei.sensor.OpenEISensor'>) implements device_state_attributes. Please report it to the custom component author.
[homeassistant.helpers.entity] Entity sensor.pacificorp_idaho_plan_name (<class 'custom_components.openei.sensor.OpenEISensor'>) implements device_state_attributes. Please report it to the custom component author.
[homeassistant.helpers.entity] Entity sensor.pacificorp_idaho_all_listed_rates (<class 'custom_components.openei.sensor.OpenEISensor'>) implements device_state_attributes. Please report it to the custom component author.
[homeassistant.helpers.entity] Entity sensor.pacificorp_idaho_monthly_energy_rate (<class 'custom_components.openei.sensor.OpenEISensor'>) implements device_state_attributes. Please report it to the custom component author.
[homeassistant.helpers.entity] Entity sensor.pacificorp_idaho_minimum_charge (<class 'custom_components.openei.sensor.OpenEISensor'>) implements device_state_attributes. Please report it to the custom component author.

[BUG] ToU rates do not update

Version of ha-openei

0.1.1

Describe the bug

After installing and configuring against my plan, the initial load of utility rates is correct. However, when the change in time happens to a higher window (say 2:59pm to 3:00pm), the sensor (in my case sensor.pacific_gas_electric_co_current_energy_rate does not update to the new rate.

Expected behavior: value of sensor.pacific_gas_electric_co_current_energy_rate changes from 0.18 to 0.36
Actual behavior: value of sensor.pacific_gas_electric_co_current_energy_rate does not change after initial setup of the rate plan.

Debug log


2021-09-08 13:04:53 INFO (SyncWorker_1) [homeassistant.util.package] Attempting install of python-openei==0.1.9
2021-09-08 13:08:25 INFO (MainThread) [homeassistant.setup] Setting up openei
2021-09-08 13:08:25 INFO (MainThread) [homeassistant.setup] Setup of domain openei took 0.0 seconds
2021-09-08 13:08:25 INFO (MainThread) [custom_components.openei] 
-------------------------------------------------------------------
OpenEI
Version: 0.0.1
This is a custom integration!
If you have any issues with this you need to open an issue here:
https://github.com/firstof9/ha-openei/issues
-------------------------------------------------------------------

2021-09-08 13:08:25 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.openei
2021-09-08 13:08:25 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.openei
2021-09-08 13:08:25 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.openei entity: binary_sensor.pacific_gas_electric_co_approval
2021-09-08 13:08:25 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.openei entity: sensor.pacific_gas_electric_co_current_energy_rate
2021-09-08 13:08:25 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.openei entity: sensor.pacific_gas_electric_co_distributed_generation
2021-09-08 13:08:25 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.openei entity: sensor.pacific_gas_electric_co_plan_name
2021-09-08 13:08:25 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.openei entity: sensor.pacific_gas_electric_co_all_listed_rates

If I restart HA when OpenEI starts it does successfully pick up the new current correct rate, but I wouldn't expect to have to do that.

This is the relevant rate plan: https://openei.org/apps/USURDB/rate/view/60a50f795457a33a3856fb5c#3__Energy

[Issue] Tier rates reading incorrectly

I updated and now the rate is at the highest tier even though I'm just realizing I think it ought to be on tier 1 right now with the value of the 1 month energy sensor (6.8 kWh /day * 30 = 204) I'm at 113 kWh so I'm below the baseline right now so in 92 kWh it should switch to tier 2 then once it reaches 400% of that baseline value it should go to tier 3.

Originally posted by @coleya in #17 (comment)

[BUG] OpenEI API rate limit exceeded

Version of ha-openei

0.1.8

Describe the bug

My OpenEI integration keeps dropping back to a state of Error fetching openei data:.

The fact that there's no content or explanation after that dangling colon seems like a bug to me; it should have exception text or something.

When I looked at the logs before I restarted homeassistant, I saw that the API had replied with a message about having exceeded the rate limit.

Debug log


2022-10-27 17:07:36.596 INFO (MainThread) [custom_components.openei]
-------------------------------------------------------------------
OpenEI
Version: 0.1.8
This is a custom integration!
If you have any issues with this you need to open an issue here:
https://github.com/firstof9/ha-openei/issues
-------------------------------------------------------------------
2022-10-27 17:07:36.596 DEBUG (MainThread) [custom_components.openei] config_entry: {'api_key': <REDACTED>, 'location': <ZIP>, 'radius': 0, 'utility': 'Pacific Gas & Electric Co', 'rate_plan': '62d05f87d2612e35a469bb87', 'manual_plan': ''}
2022-10-27 17:07:36.596 DEBUG (MainThread) [custom_components.openei] updated_config: {'api_key': <REDACTED>, 'location': <ZIP>, 'radius': 0, 'utility': 'Pacific Gas & Electric Co', 'rate_plan': '62d05f87d2612e35a469bb87', 'manual_plan': ''}
2022-10-27 17:07:36.596 DEBUG (MainThread) [custom_components.openei] Data will be updated at the top of every hour.
2022-10-27 17:07:36.597 DEBUG (MainThread) [custom_components.openei] Next update in 3144 seconds.
2022-10-27 17:07:37.133 ERROR (MainThread) [custom_components.openei] Error fetching openei data:
2022-10-27 17:07:37.136 DEBUG (MainThread) [custom_components.openei] Finished fetching openei data in 0.539 seconds (success: False)
2022-10-27 17:07:37.136 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Pacific Gas & Electric Co' for openei integration not ready yet: None; Retrying in background
2022-10-27 17:07:40.863 DEBUG (MainThread) [custom_components.openei] config_entry: {'api_key': <REDACTED>, 'location': <ZIP>, 'radius': 0, 'utility': 'Pacific Gas & Electric Co', 'rate_plan': '62d05f87d2612e35a469bb87', 'manual_plan': ''}
2022-10-27 17:07:40.864 DEBUG (MainThread) [custom_components.openei] updated_config: {'api_key': <REDACTED>, 'location': <ZIP>, 'radius': 0, 'utility': 'Pacific Gas & Electric Co', 'rate_plan': '62d05f87d2612e35a469bb87', 'manual_plan': ''}
2022-10-27 17:07:40.864 DEBUG (MainThread) [custom_components.openei] Data will be updated at the top of every hour.
2022-10-27 17:07:40.864 DEBUG (MainThread) [custom_components.openei] Next update in 3140 seconds.
2022-10-27 17:07:41.398 ERROR (MainThread) [custom_components.openei] Error fetching openei data:
2022-10-27 17:07:41.399 DEBUG (MainThread) [custom_components.openei] Finished fetching openei data in 0.535 seconds (success: False)
2022-10-27 17:08:07.733 DEBUG (MainThread) [custom_components.openei] config_entry: {'api_key': <REDACTED>, 'location': <ZIP>, 'radius': 0, 'utility': 'Pacific Gas & Electric Co', 'rate_plan': '62d05f87d2612e35a469bb87', 'manual_plan': ''}
2022-10-27 17:08:07.733 DEBUG (MainThread) [custom_components.openei] updated_config: {'api_key': <REDACTED>, 'location': <ZIP>, 'radius': 0, 'utility': 'Pacific Gas & Electric Co', 'rate_plan': '62d05f87d2612e35a469bb87', 'manual_plan': ''}
2022-10-27 17:08:07.734 DEBUG (MainThread) [custom_components.openei] Data will be updated at the top of every hour.
2022-10-27 17:08:07.734 DEBUG (MainThread) [custom_components.openei] Next update in 3113 seconds.
2022-10-27 17:08:08.188 ERROR (MainThread) [custom_components.openei] Error fetching openei data:
2022-10-27 17:08:08.189 DEBUG (MainThread) [custom_components.openei] Finished fetching openei data in 0.455 seconds (success: False)
2022-10-27 17:08:08.189 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Pacific Gas & Electric Co' for openei integration not ready yet: None; Retrying in background

Next refresh in 3140 seconds? But then it retries in way less time than that.

At some point, all the retries also blow up the rate limit from the API. From before I restarted:

2022-10-27 12:58:03.570 ERROR (MainThread) [custom_components.openei] Error fetching openei data: 
2022-10-27 12:59:24.073 ERROR (SyncWorker_6) [openeihttp] Error: You have exceeded your rate limit. Try again later or contact us at https://api.openei.org:443/contact/ for assistance
2022-10-27 12:59:24.074 ERROR (MainThread) [custom_components.openei] Error fetching openei data: 
2022-10-27 13:00:00.425 ERROR (SyncWorker_0) [openeihttp] Error: You have exceeded your rate limit. Try again later or contact us at https://api.openei.org:443/contact/ for assistance
2022-10-27 13:00:00.427 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/openei/__init__.py", line 117, in _async_refresh_data
    self._data = await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/openei/__init__.py", line 148, in get_sensors
    rate.update()
  File "/usr/local/lib/python3.10/site-packages/openeihttp/__init__.py", line 113, in update
    self.update_data()
  File "/usr/local/lib/python3.10/site-packages/openeihttp/__init__.py", line 143, in update_data
    raise APIError
openeihttp.APIError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/openei/__init__.py", line 121, in _async_refresh_data
    raise UpdateFailed() from exception
homeassistant.helpers.update_coordinator.UpdateFailed
2022-10-27 13:00:00.509 ERROR (SyncWorker_5) [openeihttp] Error: You have exceeded your rate limit. Try again later or contact us at https://api.openei.org:443/contact/ for assistance
2022-10-27 13:00:00.511 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/openei/__init__.py", line 117, in _async_refresh_data
    self._data = await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/openei/__init__.py", line 148, in get_sensors
    rate.update()
  File "/usr/local/lib/python3.10/site-packages/openeihttp/__init__.py", line 113, in update
    self.update_data()
  File "/usr/local/lib/python3.10/site-packages/openeihttp/__init__.py", line 143, in update_data
    raise APIError
openeihttp.APIError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/openei/__init__.py", line 121, in _async_refresh_data
    raise UpdateFailed() from exception
homeassistant.helpers.update_coordinator.UpdateFailed
2022-10-27 13:00:00.522 ERROR (SyncWorker_4) [openeihttp] Error: You have exceeded your rate limit. Try again later or contact us at https://api.openei.org:443/contact/ for assistance
2022-10-27 13:00:00.524 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/openei/__init__.py", line 117, in _async_refresh_data
    self._data = await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/openei/__init__.py", line 148, in get_sensors
    rate.update()
  File "/usr/local/lib/python3.10/site-packages/openeihttp/__init__.py", line 113, in update
    self.update_data()
  File "/usr/local/lib/python3.10/site-packages/openeihttp/__init__.py", line 143, in update_data
    raise APIError
openeihttp.APIError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/openei/__init__.py", line 121, in _async_refresh_data
    raise UpdateFailed() from exception
homeassistant.helpers.update_coordinator.UpdateFailed
2022-10-27 13:00:00.533 ERROR (SyncWorker_6) [openeihttp] Error: You have exceeded your rate limit. Try again later or contact us at https://api.openei.org:443/contact/ for assistance

Now, is the rate limiting the cause of the error ("Error fetching openei data: "), or is the error the cause of the retries and thus the rate limiting? I'll have to try disabling the integration for a full day to see if it recovers.

[BUG] Adjustments not showing for Public Service Co of Colorado TOU rates

Version of ha-openei

0.1.12 on HA Core 2023.11.0

Describe the bug

Adjustments to the rate are not added as a sensor, at least for Public Service Co of CO, Residential TOU rate. Current Energy rate is correctly retrieved. It looks like this feature was added in 0.1.8, but perhaps there has been a field name change since then?

TOU rate link: https://apps.openei.org/USURDB/rate/view/62f12eaa7a464314265d3c76#3__Energy

Rates on OpenEI:
image

Sensors in HA:
image

Expected result is a sensor sensor.public_service_co_of_colorado_Current Adjustment rate, and if possible, a sum of the Current Energy and Current Adjustment rates (though that could be done in a template later if needed).

Logs

Two error logs show up, though they are somewhat cryptic:

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:507
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 11:34:31 PM (1 occurrences)
Last logged: 11:34:31 PM
Error adding entities for domain sensor with platform openei

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 677, in _async_add_entity
    unit_of_measurement=entity.unit_of_measurement,
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 485, in unit_of_measurement
    native_unit_of_measurement
TypeError: unhashable type: 'list'

and

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:367
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 11:34:31 PM (1 occurrences)
Last logged: 11:34:31 PM
Error while setting up openei platform for sensor

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 367, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 677, in _async_add_entity
    unit_of_measurement=entity.unit_of_measurement,
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 485, in unit_of_measurement
    native_unit_of_measurement
TypeError: unhashable type: 'list'

Accept manual input for rate plan ID (workaround for possible bug in API responses)

Is your feature request related to a problem? Please describe.

OpenEI is not returning the correct utility even when selecting a large radius. I located the rateplan ID from the OpenEI website at https://openei.org/apps/USURDB/ via zip code and retrieving the ID from the URL.

I suspect this may be a bug in the OpenEI API, see Additional Context.

Describe the solution you'd like

Allow for manual input for rateplan ID, bypassing location lookup, perhaps using a checkbox to indicate that the user already has this ID.

Describe alternatives you've considered

Gathering more information to confirm bug and report issue to OpenEI may also resolve this without modifications to this project's configuration/setup flow.

Additional context

I confirmed by manually crafting API calls and parsing the responses that the OpenEL API itself does not return the correct utility whether I pass my latitude and longitude, full street address, or just zip code by itself as the Address parameter - it gives the same response no matter what I try that matches the selections offered in this integration's setup flow.

Manually crafting a request URL with my API key and this rateplan ID I found by searching my zip code at https://openei.org/apps/USURDB/ confirms the plan is active and returns JSON data that matches my bill, so this appears to be a bug preventing the API from returning this utility in the response when querying utilites/plans for a location.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.