jaredhobbs / rocky-mountain-power

A home assistant custom component for Rocky Mountain Power
MIT License
4 stars 0 forks source link

Rocky Mountain Power Entity failed to setup #1

Open Jsimpson75 opened 7 months ago

Jsimpson75 commented 7 months ago

I've installed everything per the readme, and the entity is failing to fetch my details from my account.

I am attaching the log file w/debug logging, and it is authenticating fine - but it seems to be having trouble parsing the response.

It's failing setup for each attempt, but there seems to be 2 distinct errors in the log file

2024-01-31 17:52:14.215 ERROR (MainThread) [custom_components.rocky_mountain_power.coordinator] Unexpected error fetching Rocky Mountain Power data: 'https://csapps.rockymountainpower.net/api/energy-usage/getMeterType' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 300, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/rocky_mountain_power/coordinator.py", line 76, in _async_update_data forecasts: list[Forecast] = await self.hass.async_add_executor_job(self.api.get_forecast) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/rocky_mountain_power/rocky_mountain_power.py", line 478, in get_forecast self.utility.get_forecast() File "/config/custom_components/rocky_mountain_power/rocky_mountain_power.py", line 188, in get_forecast details = json.loads(xhrs["https://csapps.rockymountainpower.net/api/energy-usage/getMeterType"])


KeyError: 'https://csapps.rockymountainpower.net/api/energy-usage/getMeterType'
2024-01-31 17:52:14.223 DEBUG (MainThread) [custom_components.rocky_mountain_power.coordinator] Finished fetching Rocky Mountain Power data in 37.327 seconds (success: False)

AND

2024-01-31 17:51:10.400 DEBUG (MainThread) [custom_components.rocky_mountain_power.coordinator] Updating sensor data with: [Forecast(account=Account(customer=Customer(uuid='8f2ed97e-e0a5-4155-af27-72a102220942'), uuid='16182717-001 0', utility_account_id='8f2ed97e-e0a5-4155-af27-72a102220942'), start_date=datetime.datetime(2024, 1, 9, 0, 0, tzinfo=tzfile('/usr/share/zoneinfo/America/Denver')), end_date=datetime.datetime(2024, 1, 30, 0, 0, tzinfo=tzfile('/usr/share/zoneinfo/America/Denver')), current_date=datetime.datetime(2024, 1, 31, 0, 0, tzinfo=tzfile('/usr/share/zoneinfo/America/Denver')), forecasted_cost=0.0, forecasted_cost_low=0.0, forecasted_cost_high=0.0)] 2024-01-31 17:51:10.402 DEBUG (MainThread) [custom_components.rocky_mountain_power.coordinator] Updating Statistics for rocky_mountain_power:elec_8f2ed97e_e0a5_4155_af27_72a102220942_energy_cost and rocky_mountain_power:elec_8f2ed97e_e0a5_4155_af27_72a102220942_energy_consumption 2024-01-31 17:51:10.416 DEBUG (MainThread) [custom_components.rocky_mountain_power.coordinator] Updating statistic for the first time 2024-01-31 17:51:16.602 ERROR (MainThread) [custom_components.rocky_mountain_power.coordinator] Unexpected error fetching Rocky Mountain Power data: 'elapsedDays' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 300, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/rocky_mountain_power/coordinator.py", line 80, in _async_update_data await self._insert_statistics() File "/config/custom_components/rocky_mountain_power/coordinator.py", line 107, in _insert_statistics cost_reads = await self._async_get_all_cost_reads() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/rocky_mountain_power/coordinator.py", line 189, in _async_get_all_cost_reads cost_reads.extend(await self.hass.async_add_executor_job(self.api.get_cost_reads, AggregateType.MONTH)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/rocky_mountain_power/rocky_mountain_power.py", line 517, in get_cost_reads reads = self._get_dated_data(aggregate_type, period=period) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/rocky_mountain_power/rocky_mountain_power.py", line 534, in _get_dated_data return self.utility.get_usage_by_month() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/rocky_mountain_power/rocky_mountain_power.py", line 238, in get_usage_by_month start_time = end_time - timedelta(days=int(d["elapsedDays"])) ~^^^^^^^^^^^^^^^ KeyError: 'elapsedDays' 2024-01-31 17:51:16.611 DEBUG (MainThread) [custom_components.rocky_mountain_power.coordinator] Finished fetching Rocky Mountain Power data in 42.755 seconds (success: False)

The following is observable in the UI when running setup:

image

Some details about my account

I have multiple meter entries for homes I previously lived in; they all have different meter IDs - but none of them have any data except the latest meter (item 5 in screenshot

Pasted_Image_1_31_24__6_01 PM

Pasted_Image_1_31_24__6_03 PM

Pasted_Image_1_31_24__6_05 PM

Version Info

Core 2024.1.6 Supervisor 2023.12.1 Operating System 11.4 Frontend 20240104.0 Hardware RaspberryPI 4 w/4gb ram

This is a brand new fresh install of HA from today using the latest.

Log file

home-assistant_rocky_mountain_power_2024-02-01T00-52-51.491Z.log

ragemachinest commented 7 months ago

I wish I could help here. Maybe it is the multiple meters causing the issue but I did just configure it to test it out and making sure the integration as a whole still worked. I only have one meter and it was able to successfully pull the data for me.

Directory setup just in case something is missing on your end: image

MFA is disabled on my RM account.

handyrandyrc commented 6 months ago

I set it up last night and ended up in the same boat as you, @Jsimpson75. However, I found the Selenium add on had to be started after I installed. I still had some difficulty getting it to pull data, so I rebooted the Home Assistant and walked away for the night. This morning, the Rocky Mountain Power module looks good/valid, and has entities attached. @jaredhobbs - may be an idea to instruct us to reboot after installation. I don't know if rebooting had anything to do with it, or if it just needed to automatically go re-try a bunch of times before it worked out.