markgdev / home-assistant_OctopusAgile

Octopus Agile custom component for Home Assistant
Apache License 2.0
86 stars 33 forks source link

octopusagile.half_hour service fails #60

Open markcocker opened 3 years ago

markcocker commented 3 years ago

Describe the bug After restarting Home Assistant the octopusagile.rates sensor is not populated for several minutes. I tried to force an update by calling the octopusagile.half_hour service but this failed.

To Reproduce Steps to reproduce the behavior:

  1. Navigate to Developer Tools > Services
  2. Service: octopusagile.half_hour > CALL SERVICE
Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/OctopusAgile/__init__.py:174
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 15:30:42 (2 occurrences)
Last logged: 15:31:16
[548000602384] 'run_devices'

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 136, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1455, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1494, in _execute_service
    await self._hass.async_add_executor_job(handler.job.target, service_call)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/OctopusAgile/__init__.py", line 174, in handle_half_hour_timer
    devices = config["OctopusAgile"]["run_devices"]
KeyError: 'run_devices'

Expected behavior When calling the service octopusagile.rates sensor is updated. Alternatively the sensor is updated soon after HA is restarted so I don't need to call the service.

Desktop (please complete the following information):

Additional context

Version core-2021.2.3
Installation Type Home Assistant OS
Development false
Supervisor true
Docker true
Virtual Environment false
Python Version 3.8.7
Operating System Family Linux
Operating System Version 5.4.83-v8
CPU Architecture aarch64
Timezone Europe/London
Host Operating System Home Assistant OS 5.12
Update Channel stable
Supervisor Version supervisor-2021.02.11
Docker Version 19.03.13
Disk Total 233.9 GB
Disk Used 14.4 GB
Healthy true
Supported true
Board rpi4-64
Supervisor API ok
Version API ok
Installed Add-ons AppDaemon 4 (0.4.4), Check Home Assistant configuration (3.6.0), Duck DNS (1.12.5), Grafana (6.1.3), InfluxDB (4.0.3), Node-RED (8.1.2), Portainer (1.4.0), Samba share (9.3.1), Terminal & SSH (9.0.2), motionEye (0.11.0), Visual Studio Code (3.1.0), Home Assistant Google Drive Backup (0.103.1), AirCast (3.0.0)
mdeakin99 commented 3 years ago

I see this also. When running the service I see the following message (approx 15:49)

"Failed to call service octopusagile/half_hour. min() arg is an empty sequence"

5 minutes later this fixed itself (approx 15:59)