HomeAssistant-OctopusEnergy icon indicating copy to clipboard operation
HomeAssistant-OctopusEnergy copied to clipboard

Odd Target Rates behaviour

Open no1knows opened this issue 1 year ago • 19 comments

I'm now on v4.5.0. I've set up two intermittent Target Rates, one for three hours and the other for six hours. No offset and a 00:00 - 23:59 min/max. Here are the results:

image image

Couple of things seem odd:

  1. The three hours are not a sub-set of the six hours, e.g. the three hour sensor came on at 4pm for 90 mins (during a period that definitely wasn't in the top 3 cheapest hours of the day!).
  2. There is much more than 3/6 hours where each sensor is activated in a 24hr period.

Today's pricing is as follows (incl. a nice plunge in the early morning!):

00:00 - 00:30 | 22.36
00:30 - 01:00 | 6.05
01:00 - 01:30 | 1.05
01:30 - 02:00 | -0.27
02:00 - 02:30 | 0.00
02:30 - 03:00 | -1.64
03:00 - 03:30 | -3.19
03:30 - 04:00 | -8.40
04:00 - 04:30 | -4.20
04:30 - 05:00 | -8.40
05:00 - 05:30 | -7.14
05:30 - 06:00 | 2.10
06:00 - 06:30 | 6.51
06:30 - 07:00 | 23.73
07:00 - 07:30 | 18.06
07:30 - 08:00 | 31.50
08:00 - 08:30 | 35.80
08:30 - 09:00 | 35.80
09:00 - 09:30 | 33.10
09:30 - 10:00 | 30.74
10:00 - 10:30 | 27.89
10:30 - 11:00 | 23.10
11:00 - 11:30 | 20.50
11:30 - 12:00 | 17.26
12:00 - 12:30 | 17.43
12:30 - 13:00 | 14.49
13:00 - 13:30 | 15.58
13:30 - 14:00 | 6.89
14:00 - 14:30 | 13.44
14:30 - 15:00 | 12.01
15:00 - 15:30 | 12.10
15:30 - 16:00 | 16.80
16:00 - 16:30 | 29.40
16:30 - 17:00 | 35.80
17:00 - 17:30 | 35.80
17:30 - 18:00 | 36.75
18:00 - 18:30 | 35.80
18:30 - 19:00 | 38.79
19:00 - 19:30 | 35.80
19:30 - 20:00 | 35.80
20:00 - 20:30 | 35.80
20:30 - 21:00 | 30.60
21:00 - 21:30 | 35.80
21:30 - 22:00 | 29.82
22:00 - 22:30 | 35.80
22:30 - 23:00 | 25.62
23:00 - 23:30 | 35.80
23:30 - 00:00 | 31.08

Finally, I'm still getting the following error when I try to create a new Target Rates sensor without entering min/max times (may also be caused by blank offset?):

Logger: aiohttp.server
Source: custom_components/octopus_energy/config_flow.py:215
Integration: Octopus Energy ([documentation](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/), [issues](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/issues))
First occurred: 18:12:16 (3 occurrences)
Last logged: 18:12:54

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 222, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 82, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 216, in post
    return await super().post(request)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 71, in post
    result = await self._flow_mgr.async_init(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 225, in async_init
    flow, result = await task
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data, init_done)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/octopus_energy/config_flow.py", line 246, in async_step_init
    return await self.__async_setup_target_rate_schema(config, {})
  File "/config/custom_components/octopus_energy/config_flow.py", line 215, in __async_setup_target_rate_schema
    vol.Optional(CONFIG_TARGET_START_TIME, default=config[CONFIG_TARGET_START_TIME]): str,
KeyError: 'Start time'

Appreciate any pointers!

no1knows avatar Oct 01 '22 17:10 no1knows

Hi @no1knows.

This seemed to be an issue with the labels, where the logic was the wrong way around. If you update to the latest version (v4.5.1) and re-configure your sensor you should get the desired behaviour. I also believe I've fixed the error you specified.

BottlecapDave avatar Oct 02 '22 09:10 BottlecapDave

Thank you! The error is gone and I've re-added the sensors. Will report back if I see any more unexpected behaviour.

no1knows avatar Oct 02 '22 11:10 no1knows

I'm on Octopus Go, so a simple situation where I already know that 00:30 to 04:30 is 7.5p/kWh and the rest of the time, it's 42.3p/kWh.

I've set up a target rate for a continuous 4 hours. The sensor finds 00:30 to 04:30, but also finds multiple other 4 hour slots during the day.

Is this due to a rounding error, or something along those lines?

FalconUK avatar Oct 02 '22 19:10 FalconUK

Sorry for the late response - @FalconUK Do you still see this behaviour with the latest version of the integration? If so, have you reconfigured your target rate sensor as per the instructions

BottlecapDave avatar Oct 09 '22 05:10 BottlecapDave

Hi Dave, no worries. Yes, for example, the sensor was on for 0030 - 0430 as expected, but also 0500 - 0900, and then came on again at 0930.

I currently have "Re-evaluate multiple times a day" set to true. Is this the issue? Even so, evaluation shouldn't turn the sensor on, as there's no cheap rate during the day.

FalconUK avatar Oct 09 '22 10:10 FalconUK

I believe the "Re-evaluate multiple times a day" setting is probably the issue. With that set to true, it's basically a moving target for the current day (and specified period).

This setting turned on is best for people on variable rates (something that most people aren't probably on atm) or where the sensor is powering an automation that can't be missed but is only a part of the reason why the automation might run. For example in my house, I have the ability to set my washing machine to remote start. I want the sensor to find the best time for the day from the moment I turn on remote start. If I didn't have this setting then the washing machine might not turn on until the next day because the best time was in the past.

It was a bug in the previous release where "Re-evaluate multiple times a day" was the default setting, which has since been fixed.

Please do let me know if unsetting this doesn't fix your issue though.

BottlecapDave avatar Oct 09 '22 16:10 BottlecapDave

Hi Dave, I'll try it without, but something is a little off. With my flat rate during the day, there's no 'best' four hour period, but the sensor is on and off regularly throughout the day.

FalconUK avatar Oct 09 '22 16:10 FalconUK

Because you're on a flat rate, you probably don't want "Re-evaluate multiple times a day" switched on. As previously mentioned, it's a setting that is best for rates where they fluctuate during the day (e.g. Octopus Agile) or the sensor is being used in conjunction with something else that powers something that "must" not be missed (e.g. my washing machine automation has an additional flag I check to know if the washing machine should be turned on). I'll try to update the readme with more examples.

BottlecapDave avatar Oct 09 '22 16:10 BottlecapDave

With "Re-evaluate multiple times a day" turned off, the behaviour of the sensor is more stable, but it's true from 0030 to 0500 every morning. Octopus Go cheap rate is from 0030 to 0430.

FalconUK avatar Oct 14 '22 14:10 FalconUK

@FalconUK Very odd that you're seeing this behaviour as in my testing I'm not seeing this behaviour. Are you receiving any errors in your Home Assistant logs relating to this integration? In addition, could you post the attributes associated with your target rate sensor to see if it holds any clues?

BottlecapDave avatar Oct 15 '22 08:10 BottlecapDave

@BottlecapDave, I've just enabled debug-level logging and will keep an eye on the logs.

Target rate sensor is configured as follows: Target rate sensor

Today: Octopus Go sensor

Attributes attached. interestingly, this show the low rate starting from 00:00, and the high rate starting from 03:30, so I guess they're in GMT/UTC and 23:30-00:00 belongs to yesterday? - but the attribute data for the low rate ending at 03:30 would be correct, even though the switch changed state incorrectly at 05:00.

OctopusGo.txt

FalconUK avatar Oct 15 '22 10:10 FalconUK

@BottlecapDave I've enabled debug-level logging. Is there any useful info you'd like?

FalconUK avatar Oct 20 '22 16:10 FalconUK

Sorry, I've released a new version (v4.6.0) which will hopefully fix your issue. Do you mind giving it a try?

BottlecapDave avatar Oct 20 '22 17:10 BottlecapDave

@BottlecapDave I'm running v4.6.0 and still seeing the sensor switch on at 00:30 and off at 05:00, not 04:30. The attribute data confirms that the lower tariff finishes at 03:30 UTC.

FalconUK avatar Oct 20 '22 17:10 FalconUK

I might have found the issue. Just testing now. However, I don't think it will be an issue by next week when the clocks go back :(

BottlecapDave avatar Oct 20 '22 18:10 BottlecapDave

Ahhh, the joys of BST.

If you're able to release an updated version, I'm happy to test before and after the clocks go back.

FalconUK avatar Oct 20 '22 18:10 FalconUK

🤞 that https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/releases/tag/v4.6.1 will fix your issue before the clocks go back

BottlecapDave avatar Oct 22 '22 17:10 BottlecapDave

@BottlecapDave, have installed v4.6.1 and will let you know how it goes over the next week.

FalconUK avatar Oct 22 '22 21:10 FalconUK

@BottlecapDave, looking good this morning. I'll keep and eye on it and update after the clocks go back.

Target rate sensor v4_6_1

FalconUK avatar Oct 23 '22 08:10 FalconUK

All looks okay, following the change back to GMT/UTC. 👍

FalconUK avatar Oct 31 '22 11:10 FalconUK