Skip to content

Commit 28cb4b5

Browse files
committed
test: Fixed unit tests
1 parent 1e9ef65 commit 28cb4b5

18 files changed

+1287
-1254
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,6 @@ jobs:
5151
- name: Run unit tests
5252
run: |
5353
python -m pytest tests/unit
54-
integration_tests:
55-
# Tests are geared towards my account, so ignore for others
56-
if: ${{ github.repository_owner == 'BottlecapDave' }}
57-
name: Integration Tests
58-
runs-on: ubuntu-latest
59-
steps:
60-
- name: Checkout
61-
uses: actions/checkout@v4
62-
with:
63-
fetch-depth: 0
64-
- name: Setup
65-
uses: ./.github/actions/setup
66-
- name: Run integration tests
67-
run: |
68-
python -m pytest tests/integration
69-
env:
70-
API_KEY: ${{ secrets.target_timeframes_API_TOKEN }}
71-
GAS_MPRN: ${{ secrets.target_timeframes_GAS_MPRN }}
72-
GAS_SN: ${{ secrets.target_timeframes_GAS_SN }}
73-
ELECTRICITY_MPAN: ${{ secrets.target_timeframes_ELECTRICITY_MPAN }}
74-
ELECTRICITY_SN: ${{ secrets.target_timeframes_ELECTRICITY_SN }}
75-
ACCOUNT_ID: ${{ secrets.target_timeframes_ACCOUNT_ID }}
7654
release:
7755
name: Release
7856
if: ${{ github.repository_owner == 'BottlecapDave' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta') }}

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,52 @@
1-
# HomeAssistant-TargetTimeframes
1+
# Home Assistant Target Timeframes
2+
3+
Target timeframes was a feature that has been extracted out of the [Octopus Energy integration](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy). The idea is you can configure binary sensors that will find and turn on during the most optimal time periods based on external data sources, targeting either the lowest or highest values. What these values represent can be anything. In the original integration, the values represented cost of energy, and so the cheapest periods were discovered. But it could represent other things like
4+
5+
* Temperature to turn on sprinklers during the hottest times of the day
6+
* Carbon emissions to turn on devices when renewables on the grid are at their highest
7+
* Solar generation to turn on devices when the most energy is being generated.
8+
9+
How the sensors behave is configurable in a number of ways and explained further in the docs.
10+
11+
## How to install
12+
13+
There are multiple ways of installing the integration. Once you've installed the integration, you'll need to [setup your account](#how-to-setup) before you can use the integration.
14+
15+
### HACS
16+
17+
[![hacs_badge](https://img.shields.io/badge/HACS-Default-41BDF5.svg?style=for-the-badge)](https://github.com/hacs/integration)
18+
19+
This integration can be installed directly via HACS. To install:
20+
21+
* [Add the repository](https://my.home-assistant.io/redirect/hacs_repository/?owner=BottlecapDave&repository=homeassistant-targettimeframes&category=integration) to your HACS installation
22+
* Click `Download`
23+
24+
### Manual
25+
26+
You should take the latest [published release](https://github.com/BottlecapDave/homeassistant-targettimeframes/releases). The current state of `develop` will be in flux and therefore possibly subject to change.
27+
28+
To install, place the contents of `custom_components` into the `<config directory>/custom_components` folder of your Home Assistant installation. Once installed, don't forget to restart your home assistant instance for the integration to be picked up.
29+
30+
## How to setup
31+
32+
You will initially need to setup one or more [data sources](https://bottlecapdave.github.io/HomeAssistant-TargetTimeframes/setup/data_source.md). You'll then need to setup one or more [target timeframe](https://bottlecapdave.github.io/HomeAssistant-TargetTimeframes/setup/target_timeframe.md) or [rolling target timeframe](https://bottlecapdave.github.io/HomeAssistant-TargetTimeframes/setup/rolling_target_timeframe.md) sensors.
33+
34+
## Events
35+
36+
This integration raises several events, which can be used for various tasks like automations. For more information, please see the [events docs](https://bottlecapdave.github.io/HomeAssistant-TargetTimeframes/events.md).
37+
38+
## Services
39+
40+
This integration includes several services. Please review them in the [services doc](https://bottlecapdave.github.io/HomeAssistant-TargetTimeframes/services.md).
41+
42+
## Blueprints
43+
44+
A selection of [blueprints](https://bottlecapdave.github.io/HomeAssistant-TargetTimeframes/blueprints.md) are available to help get you up and running quickly with the integration.
45+
46+
## FAQ
47+
48+
Before raising anything, please read through the [faq](https://bottlecapdave.github.io/HomeAssistant-TargetTimeframes/faq.md). If you have questions, then you can raise a [discussion](https://github.com/BottlecapDave/homeassistant-targettimeframes/discussions). If you have found a bug or have a feature request please [raise it](https://github.com/BottlecapDave/homeassistant-targettimeframes/issues) using the appropriate report template.
49+
50+
## Sponsorship
51+
52+
Please see the [sponsorship](https://bottlecapdave.github.io/HomeAssistant-TargetTimeframes/sponsorship.md) page for more information.

_docs/blueprints/target_timeframes_octopus_energy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ action:
6565
{% for rate in all_rates %}
6666
{% set start = rate["start"] | as_timestamp | timestamp_utc %}
6767
{% set end = rate["end"] | as_timestamp | timestamp_utc %}
68-
{% set value = rate["value_inc_vat"] | float %}
68+
{% set value = rate["value"] | float %}
6969
{% set data.new_rates = data.new_rates + [{ 'start': start , 'end': end, 'value': value, 'metadata': { "is_capped": rate["is_capped"] } }] %}
7070
{% endfor %}
7171
{{ { 'data': data.new_rates } }}

_docs/index.md

Lines changed: 8 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
# Home Assistant Target Timeframes
22

3-
## Features
4-
5-
Below are the main features of the integration
6-
7-
* [Electricity](./entities/electricity.md) and [gas](./entities/gas.md) meter support including consumption data and rate information
8-
* [Custom sensor support to target cheapest rates](#target-rate-sensors)
9-
* [Custom sensor support for tracking costs of other entities](#cost-tracker-sensors)
10-
* [Custom sensor support for comparing to other tariffs](#tariff-comparison-sensors)
11-
* [Octopus Home mini support](#home-mini)
12-
* [Octopus Home Pro support (Experimental)](#home-pro)
13-
* [Intelligent tariff settings support](#intelligent)
14-
* [Saving sessions support](#octoplus)
15-
* [Wheel of fortune support](#wheel-of-fortune)
16-
* [Greener days support](#greenness-forecast)
17-
* [Heat Pump support](#heat-pumps)
3+
Target timeframes was a feature that has been extracted out of the [Octopus Energy integration](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy). The idea is you can configure binary sensors that will find and turn on during the most optimal time periods based on external data sources, targeting either the lowest or highest values. What these values represent can be anything. In the original integration, the values represented cost of energy, and so the cheapest periods were discovered. But it could represent other things like
4+
5+
* Temperature to turn on sprinklers during the hottest times of the day
6+
* Carbon emissions to turn on devices when renewables on the grid are at their highest
7+
* Solar generation to turn on devices when the most energy is being generated.
8+
9+
How the sensors behave is configurable in a number of ways and explained further in the docs.
1810

1911
## How to install
2012

@@ -37,87 +29,7 @@ To install, place the contents of `custom_components` into the `<config director
3729

3830
## How to setup
3931

40-
Please follow the [setup guide](./setup/account.md) to setup your initial account. This guide details the configuration, along with the entities that will be available to you.
41-
42-
## Entities
43-
44-
### Electricity Entities
45-
46-
[Full list of electricity entities](./entities/electricity.md).
47-
48-
### Gas Entities
49-
50-
[Full list of gas entities](./entities/gas.md).
51-
52-
### Home Mini
53-
54-
If you are lucky enough to own an [Octopus Home Mini](https://octopus.energy/blog/octopus-home-mini/), you can now receive this data within Home Assistant. When setting up (or editing) your account within Home Assistant, you will need to check the box next to `I have a Home Mini`. This will gain [electricity entities](./entities/electricity.md#home-minipro-entities) and [gas entities](./entities/gas.md#home-minipro-entities) which can be added to the [energy dashboard](https://www.home-assistant.io/blog/2021/08/04/home-energy-management/).
55-
56-
!!! info
57-
58-
You will only have the same data exposed in the integration that is available within the Octopus app. There has been reports of gas not appearing within the Octopus app (and integration) straight away, so you might have to wait a few days for this to appear. Once it's available within the Octopus app, if you reload the integration (or restart Home Assistant) then the entities should become available.
59-
60-
!!! warning
61-
62-
Export sensors are not provided as the data is not available.
63-
64-
### Home Pro
65-
66-
If you are lucky enough to own an Octopus Home Pro, you can now receive this data within Home Assistant. When setting up (or editing) your account within Home Assistant, you will need to configure your [Home Pro](./setup/account.md#home-pro). This will gain [electricity entities](./entities/electricity.md#home-minipro-entities) and [gas entities](./entities/gas.md#home-minipro-entities) which can be added to the [energy dashboard](https://www.home-assistant.io/blog/2021/08/04/home-energy-management/).
67-
68-
!!! info
69-
70-
You will only have the same data exposed in the integration that is available within the Octopus app. There has been reports of gas not appearing within the Octopus app (and integration) straight away, so you might have to wait a few days for this to appear. Once it's available within the Octopus app, if you reload the integration (or restart Home Assistant) then the entities should become available.
71-
72-
!!! warning
73-
74-
Export sensors are not provided as the data is not available.
75-
76-
### Intelligent
77-
78-
If you are on the [intelligent tariff](https://octopus.energy/smart/intelligent-octopus/), then you'll get a few additional entities when you install the integration.
79-
80-
[List of intelligent entities](./entities/intelligent.md).
81-
82-
!!! warning
83-
84-
If you switch to the intelligent tariff after you have installed the integration, you will need to reload the integration or restart your Home Assistant instance.
85-
86-
### Octoplus
87-
88-
To support Target Timeframes's [octoplus programme](https://octopus.energy/octoplus/). [Full list of octoplus entites](./entities/octoplus.md).
89-
90-
### Wheel of Fortune
91-
92-
To support the wheel of fortune that is awarded every month to customers. [Full list of wheel of fortune entites](./entities/wheel_of_fortune.md).
93-
94-
### Greenness Forecast
95-
96-
To support Target Timeframes's [greener days](https://octopus.energy/smart/greener-days/). [Full list of greenness forecast entities](./entities/greenness_forecast.md).
97-
98-
### Heat Pumps
99-
100-
To support heat pumps connected to Target Timeframes, like the [Cosy 6](https://octopus.energy/cosy-heat-pump/). [Full list of heat pump entities](./entities/heat_pump.md).
101-
102-
## Target Rate Sensors
103-
104-
These sensors calculate the lowest continuous or intermittent rates **within a 24 hour period** or on a rolling basis and turn on when these periods are active. If you are targeting an export meter, then the sensors will calculate the highest continuous or intermittent rates **within a 24 hour period** or on a rolling basis and turn on when these periods are active.
105-
106-
These sensors can then be used in automations to turn on/off devices that save you (and the planet) energy and money. You can go through this flow as many times as you need target rate sensors.
107-
108-
Please follow the setup guides for either [standard target rate](./setup/target_rate.md) or [rolling target rate](./setup/rolling_target_rate.md) sensors.
109-
110-
## Cost Tracker Sensors
111-
112-
These sensors track the consumption of other existing sensors and provide a daily cost of those sensors.
113-
114-
Please follow the [setup guide](./setup/cost_tracker.md).
115-
116-
## Tariff Comparison Sensors
117-
118-
These sensors compare the cost of the previous consumption to another tariff to see if you're on the best tariff.
119-
120-
Please follow the [setup guide](./setup/tariff_comparison.md).
32+
You will initially need to setup one or more [data sources](./setup/data_source.md). You'll then need to setup one or more [target timeframe](./setup/target_timeframe.md) or [rolling target timeframe](./setup/rolling_target_timeframe.md) sensors.
12133

12234
## Events
12335

@@ -127,18 +39,10 @@ This integration raises several events, which can be used for various tasks like
12739

12840
This integration includes several services. Please review them in the [services doc](./services.md).
12941

130-
## Energy Dashboard
131-
132-
The core sensors have been designed to work with the energy dashboard. Please see the [energy dashboard guide](./setup/energy_dashboard.md) for instructions on how to set this up.
133-
13442
## Blueprints
13543

13644
A selection of [blueprints](./blueprints.md) are available to help get you up and running quickly with the integration.
13745

138-
## Community Contributions
139-
140-
A collection of community contributions can be found on the [community contributions](./community.md) page.
141-
14246
## FAQ
14347

14448
Before raising anything, please read through the [faq](./faq.md). If you have questions, then you can raise a [discussion](https://github.com/BottlecapDave/homeassistant-targettimeframes/discussions). If you have found a bug or have a feature request please [raise it](https://github.com/BottlecapDave/homeassistant-targettimeframes/issues) using the appropriate report template.

0 commit comments

Comments
 (0)