home-assistant_OctopusAgile icon indicating copy to clipboard operation
home-assistant_OctopusAgile copied to clipboard

No attribute issues post installation

Open JustGav opened this issue 3 years ago • 4 comments

Describe the bug Installed the plug in via HACS, configuration done in configuration YAML file. Component does not seem to start or retrieve data.

To Reproduce Steps to reproduce the behavior:

  1. Install OctopusAgile via HACS
  2. Edit configuration.yaml
octopusagile:
  region_code: "????"
  mpan: XXXXXX
  serial: XXXXXX
  auth: XXX
  startdate: "2022-10-24"
  gorate: 
  godayrate:
  gotimes:
  moneymakers:
  - switch.water_heater: null
  - climate.downstairs:
      params:
        temp: 25
sensor:
- platform: "octopusagile"
  1. See error Error setting up entry Name of the device for octopusagile Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 365, in async_setup result = await component.async_setup_entry(hass, self) AttributeError: module 'custom_components.octopusagile' has no attribute 'async_setup_entry'

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 515, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 710, in async_device_update raise exc 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/octopusagile/sensor.py", line 159, in update current_rate = self.hass.states.get("octopusagile.all_rates").attributes.get(rounded_time_str) AttributeError: 'NoneType' object has no attribute 'attributes'

Expected behavior Sensor data should be populated

Screenshots

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Version 106.0.5249.119

Additional context Home Assistant Version : 2022.10.5

JustGav avatar Oct 24 '22 10:10 JustGav

oa-2 oa-3

2022-10-24 11:21:04.769 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Name of the device for octopusagile Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 365, in async_setup result = await component.async_setup_entry(hass, self) AttributeError: module 'custom_components.octopusagile' has no attribute 'async_setup_entry' 2022-10-24 11:21:05.554 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.octopus_agile_previous_rate fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 515, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 710, in async_device_update raise exc 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/octopusagile/sensor.py", line 88, in update prev_rate = self.hass.states.get("octopusagile.all_rates").attributes.get(rounded_time_str) AttributeError: 'NoneType' object has no attribute 'attributes' 2022-10-24 11:21:05.635 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.octopus_agile_current_rate fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 515, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 710, in async_device_update raise exc 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/octopusagile/sensor.py", line 159, in update current_rate = self.hass.states.get("octopusagile.all_rates").attributes.get(rounded_time_str) AttributeError: 'NoneType' object has no attribute 'attributes' 2022-10-24 11:21:05.815 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.octopus_agile_next_rate fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 515, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 710, in async_device_update raise exc 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/octopusagile/sensor.py", line 227, in update next_rate = self.hass.states.get("octopusagile.all_rates").attributes.get(rounded_time_str) AttributeError: 'NoneType' object has no attribute 'attributes'

JustGav avatar Oct 24 '22 10:10 JustGav

I see the same issue.

Screenshot 2022-11-05 at 15 09 53

octopusagile:
  region_code: "N"
  mpan: !secret electric_mpan
  serial: !secret electric_serial
  auth: !secret octopus_api_key
  agilerate: "AGILE-22-08-31"
  startdate: "2022-11-05"
  run_devices:
    - energy_time: 1.5
      entity_id: dishwasher
      run_before: "08:00:00"
      run_time: 3.0

gsdevme avatar Nov 05 '22 15:11 gsdevme

My system was working and I've just updated to the latest HA ... I've just done a quick test by removing the octopusagile.json file and then restarting at which point I get a lot of these errors also. I believe the issue is to do with the fact that a lot of the info is read from this json file when the integration loads, meaning that until this file is generated you get loads of errors. You can either wait until all the schedules run or you can force the issue by calling some services from the developer tools menu. Call update_consumption, then update timers, then half_hour ... this doesn't fix the avg_rates sensors unless you run update timers after 23:00.

LucidityCrash avatar Feb 06 '23 11:02 LucidityCrash

https://github.com/markgdev/home-assistant_OctopusAgile/blob/cf7887eb0b7d5577a0d1dd5a070e787bc92f6005/custom_components/octopusagile/init.py#L71-L88 are the issue I think. It only populates the sensor data on startup if that file exists. I'm thinking if the file doesn't exist calling update_timers would be a better idea than jus not doing anything.

LucidityCrash avatar Feb 06 '23 11:02 LucidityCrash