Skip to content

Commit

Permalink
feat: updated name of current rating sensor to include target region …
Browse files Browse the repository at this point in the history
…and removed all_rates attribute

BREAKING CHANGE:
all_rates attribute has been removed from target rating in favour of new event entities. The name of the current rating sensor now includes the region.
  • Loading branch information
BottlecapDave committed Oct 11, 2023
1 parent 400d147 commit 749e5e3
Show file tree
Hide file tree
Showing 12 changed files with 415 additions and 230 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules/
**/__pycache__/**
run_tests.sh
run_unit_tests.sh
216 changes: 8 additions & 208 deletions README.md

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions _docs/entities.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Entities

- [Entities](#entities)
- [Current Rating](#current-rating)

## Current Rating

`sensor.carbon_intensity_{{REGION}}_current_rating`

The forecasted intensity rating of the current 30 minute period.

| Attribute | Type | Description |
|-----------|------|-------------|
| `rate` | `string` | The rate for the current 30 minute period |
46 changes: 46 additions & 0 deletions _docs/events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Events

- [Events](#events)
- [Current Day Rates](#current-day-rates)
- [Next Day Rates](#next-day-rates)

The following events are raised by the integration. These events power various entities mentioned above. They can also be used to trigger automations. An example automation might look like the following

```yaml
- alias: CI rates change
trigger:
- platform: event
event_type: carbon_intensity_next_day_rates
condition: []
action:
- event: notify_channels
event_data_template:
mode: message
title: OE price changes
message: >
New rates available for {{ trigger.event.data.region }}. Starting value is {{ trigger.event.data.rates[0]["intensity_forecast"] }}
target: <@ULU7111GU>
length_hint: 00:00:04
```
## Current Day Rates
`carbon_intensity_current_day_rates`

This is fired when the current day rates are updated.

| Attribute | Type | Description |
|-----------|------|-------------|
| `rates` | `list` | The list of rates applicable for the current day |
| `region` | `string` | The region the rates are for |

## Next Day Rates

`carbon_intensity_next_day_rates`

This is fired when the next day rates are updated.

| Attribute | Type | Description |
|-----------|------|-------------|
| `rates` | `list` | The list of rates applicable for the next day |
| `region` | `string` | The region the rates are for |
10 changes: 10 additions & 0 deletions _docs/faq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# FAQ

- [FAQ](#faq)
- [How do I increase the logs for the integration?](#how-do-i-increase-the-logs-for-the-integration)

## How do I increase the logs for the integration?

If you are having issues, it would be helpful to include Home Assistant logs as part of any raised issue. This can be done by following the [instructions](https://www.home-assistant.io/docs/configuration/troubleshooting/#enabling-debug-logging) outlined by Home Assistant.

You should run these logs for about a day and then include the contents in the issue. Please be sure to remove any personal identifiable information from the logs before including them.
48 changes: 48 additions & 0 deletions _docs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Home Assistant Carbon Intensity Docs

- [Home Assistant Carbon Intensity Docs](#home-assistant-carbon-intensity-docs)
- [How to setup](#how-to-setup)
- [Entities](#entities)
- [Target Rate Sensors](#target-rate-sensors)
- [Events](#events)
- [Services](#services)
- [Energy Dashboard](#energy-dashboard)
- [Community Contributions](#community-contributions)
- [FAQ](#faq)


## How to setup

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.

## Entities

A full list of default entities can be found [here](./entities.md)

## Target Rate Sensors

These sensors calculate the lowest continuous or intermittent rates **within a 24 hour period** and turn on when these periods are active.

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.

Please follow the [setup guide](./setup_target_rate.md) to setup.

## Events

This integration raises several events, which can be used for various tasks like automations. For more information, please see the [events docs](./events.md).

## Services

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

## Energy Dashboard

The core sensors have been designed to work with the energy dashboard. Please see the [guide](./energy_dashboard.md) for instructions on how to set this up.

## Community Contributions

A collection of community contributions can be found [here](./community.md).

## FAQ

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-OctopusEnergy/discussions). If you have found a bug or have a feature request please [raise it](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/issues) using the appropriate report template.
70 changes: 70 additions & 0 deletions _docs/services.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Services

- [Services](#services)
- [Service carbon\_intensity.update\_target\_config](#service-carbon_intensityupdate_target_config)

There are a few services available within this integration, which are detailed here.

## Service carbon_intensity.update_target_config

Service for updating a given target rate's config. This allows you to change target rates sensors dynamically based on other outside criteria (e.g. you need to adjust the target hours to top up home batteries).

> Please note this is temporary and will not persist between restarts.
| Attribute | Optional | Description |
| ------------------ | -------- | ---------------------------------------------------------------------------------------------------------------|
| `target.entity_id` | `no` | The name of the target sensor whose configuration is to be updated |
| `data.hours` | `yes` | The optional number of hours the rate sensor should come on during a 24 hour period. Must be divisible by 0.5. |
| `data.start_time` | `yes` | The optional time the evaluation period should start. Must be in the format of `HH:MM`. |
| `data.end_time` | `yes` | The optional time the evaluation period should end. Must be in the format of `HH:MM`. |
| `data.offset` | `yes` | The optional offset to apply to the target rate when it starts. Must be in the format `(+/-)HH:MM:SS` |

This can be used via automations in the following way. Assuming we have the following inputs.

```yaml
input_number:
carbon_intensity_hours:
name: Carbon Intensity Target Hours
min: 0
max: 24

input_text:
# From/to would ideally use input_datetime, but we need the time in a different format
carbon_intensity_from:
name: Carbon Intensity Target From
initial: "00:00"
carbon_intensity_to:
name: Carbon Intensity Target To
initial: "00:00"
carbon_intensity_offset:
name: Carbon Intensity Target Offset
initial: "-00:00:00"
```
Then an automation might look like the following
```yaml
automations:
- alias: Update target rate config
trigger:
- platform: state
entity_id:
- input_number.carbon_intensity_hours
- input_text.carbon_intensity_from
- input_text.carbon_intensity_to
- input_text.carbon_intensity_offset
condition: []
action:
- service: carbon_intensity.update_target_config
data:
hours: >
"{{ states('input_number.carbon_intensity_hours') | string }}"
start_time: >
{{ states('input_text.carbon_intensity_from') }}
end_time: >
{{ states('input_text.carbon_intensity_to') }}
offset: >
{{ states('input_text.carbon_intensity_offset') }}
target:
entity_id: binary_sensor.carbon_intensity_target_example
```
10 changes: 10 additions & 0 deletions _docs/setup_account.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Setup Account

- [Setup Account](#setup-account)
- [Region](#region)

Setup is done entirely via the [integration UI](https://my.home-assistant.io/redirect/config_flow_start/?domain=carbon_intensity).

## Region

In order to provide accurate readings, you'll need to set the region you're tracking. This will be used to work out the carbon intensity in your area.
Loading

0 comments on commit 749e5e3

Please sign in to comment.