Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No attribute issues post installation #99

Open
JustGav opened this issue Oct 24, 2022 · 4 comments
Open

No attribute issues post installation #99

JustGav opened this issue Oct 24, 2022 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@JustGav
Copy link

JustGav commented Oct 24, 2022

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
Copy link
Author

JustGav commented Oct 24, 2022

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'

@gsdevme
Copy link

gsdevme commented Nov 5, 2022

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

@markgdev markgdev added the help wanted Extra attention is needed label Nov 5, 2022
@LucidityCrash
Copy link
Contributor

LucidityCrash commented Feb 6, 2023

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
Copy link
Contributor

LucidityCrash commented Feb 6, 2023

try:
with open(datatorefile) as f:
data = json.load(f)
hass.states.set(f"octopusagile.timers", "", {"timers": data.get("timers")})
rates = data.get("rates")
if rates == None:
rates = myrates.get_new_rates()["date_rates"]
hass.states.set(f"octopusagile.rates", "", rates)
all_rates = data.get("all_rates")
if all_rates is None:
all_rates = myrates.get_new_rates()["date_rates"]
hass.states.set(f"octopusagile.all_rates", "", all_rates)
device_times = data.get("device_times", {})
for entity_id, vals in device_times.items():
hass.states.set(f"octopusagile.{entity_id}", vals["start_time"], vals["attribs"])
f.close()
except IOError:
print(f"{datatorefile} does not exist")

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants