dotKrad / hass-fpl

FPL Component for Home Assistant
MIT License
40 stars 20 forks source link

Minor logging issue - "Getting appliance usage data" is used twice #43

Open bcjmk opened 1 year ago

bcjmk commented 1 year ago

No information on why this ERROR is occurring, but further obscured by wrong detail in the logger. I'm wondering if the "lastBilledDate" is NULL when trying to strftime which is done outside of the try/except section.

async def __getDataFromBalance(self, account) -> dict: """get data from appliance usage""" _LOGGER.info("Getting appliance usage data")

async def __getDataFromApplianceUsage(self, account, lastBilledDate) -> dict: """get data from appliance usage""" _LOGGER.info("Getting appliance usage data")

Version of the custom_component

version 0.0.1

Configuration

Not affected by configuration

Debug log


2023-07-09 12:53:07.077 DEBUG (MainThread) [custom_components.fpl] Getting territory
2023-07-09 12:53:09.561 INFO (MainThread) [custom_components.fpl] Getting Programs
2023-07-09 12:53:09.561 INFO (MainThread) [custom_components.fpl] Getting energy service data
2023-07-09 12:53:14.565 ERROR (MainThread) [custom_components.fpl] 
2023-07-09 12:53:14.571 INFO (MainThread) [custom_components.fpl] Getting appliance usage data
2023-07-09 12:53:19.573 ERROR (MainThread) [custom_components.fpl] 
2023-07-09 12:53:19.577 INFO (MainThread) [custom_components.fpl] Getting appliance usage data
2023-07-09 12:53:19.915 INFO (MainThread) [custom_components.fpl] Logging out
2023-07-09 12:53:20.002 DEBUG (MainThread) [custom_components.fpl] Finished fetching fpl data in 12.925 seconds (success: True)
bcjmk commented 1 year ago

Forgot to mention, this is an intermittent issue. Although it seems to be a pattern. Ran twice successfully, failed both once. Ran once successfully, failed next 2 times. Ran once successfully, failed next 3 times. I'll let it run a few more hours to see if the pattern continues.

bcjmk commented 1 year ago

After running overnight, it looks to be timeout related. When the requests finished in <5 seconds, no errors. 8-10 seconds was a single failure, and >11 seconds was 2 failures. Which makes sense because the timeout is set to 5. Might need to add the timeout value to the session.post as referred to here for the try/except to catch the error and provide the value. https://stackoverflow.com/questions/54619868/http-requests-post-timeout