This is a work in progress and may not be reflected in working code.
The purpose of the Dynamic2MQTT service is to publish information about a dynamic electricity tariff on to the MQTT bus.
The code runs in a docker container and is available here: https://gitlab.com/rescoopvpp/dynamic2mqtt
For development purposes, we are working with the Octopus Agile tariff. Octopus Agile is a dynamic tariff available in the United Kingdom that gives a different price for each half hour period each day.
Prices for the next day are published at approximately 4pm every day. They are available at an API endpoint.
The endpoint URL is dependant on the region of the customer, so must be configurable.
The Agile API is documented here: https://developer.octopus.energy/docs/api/
Agile tariffs are available at this endpoint: https://api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-N/standard-unit-rates/
{
"count": 74731,
"next": "https://api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-N/standard-unit-rates/?page=2",
"previous": null,
"results": [
{
"value_exc_vat": 9.24,
"value_inc_vat": 9.702,
"valid_from": "2021-04-06T21:30:00Z",
"valid_to": "2021-04-06T22:00:00Z"
},
{
"value_exc_vat": 12.12,
"value_inc_vat": 12.726,
"valid_from": "2021-04-06T21:00:00Z",
"valid_to": "2021-04-06T21:30:00Z"
},
{
"value_exc_vat": 12.5,
"value_inc_vat": 13.125,
"valid_from": "2021-04-06T20:30:00Z",
"valid_to": "2021-04-06T21:00:00Z"
},
...
{
"value_exc_vat": 8.34,
"value_inc_vat": 8.757,
"valid_from": "2021-04-04T20:30:00Z",
"valid_to": "2021-04-04T21:00:00Z"
},
{
"value_exc_vat": 11.47,
"value_inc_vat": 12.0435,
"valid_from": "2021-04-04T20:00:00Z",
"valid_to": "2021-04-04T20:30:00Z"
}
]
}
The Dynamic2MQTT service consumes the REST API and republishes the information on the MQTT bus.
It is a long running service that updates every half hour (this interval can be specified).
The services publishes MQTT messages on a number of topics with topic root data/sensor/dynamic_price/
.
data/sensor/dynamic_prices/current_price : 13.2
data/sensor/dynamic_prices/next_price : 11.2
data/sensor/dynamic_prices/previous_price : 12.2
data/sensor/dynamic_prices/upcoming_prices: {"2021-04-09T21:30:00Z": 12.411, "2021-04-09T21:00:00Z": 14.994, "2021-04-09T20:30:00Z": 14.994, "2021-04-09T20:00:00Z": 16.5375, "2021-04-09T19:30:00Z": 17.178, "2021-04-09T19:00:00Z": 18.6585, "2021-04-09T18:30:00Z": 17.9445, "2021-04-09T18:00:00Z": 19.047, "2021-04-09T17:30:00Z": 32.949, "2021-04-09T17:00:00Z": 32.949, "2021-04-09T16:30:00Z": 32.172, "2021-04-09T16:00:00Z": 30.1875, "2021-04-09T15:30:00Z": 30.1875, "2021-04-09T15:00:00Z": 26.523, "2021-04-09T14:30:00Z": 12.411, "2021-04-09T14:00:00Z": 11.907, "2021-04-09T13:30:00Z": 11.025, "2021-04-09T13:00:00Z": 12.348, "2021-04-09T12:30:00Z": 12.789, "2021-04-09T12:00:00Z": 15.435, "2021-04-09T11:30:00Z": 16.5375, "2021-04-09T11:00:00Z": 17.199, "2021-04-09T10:30:00Z": 17.199}
data/sensor/dynamic_prices/devices/washing_machine: {"state": "on", "on_at": "2021-04-09T16:30:00Z", "off_at": "2021-04-09T17:00:00Z"
For early development purposes, configuration is done using a dynamic2mqtt_configuration.yaml
file.
This file can be accessed by going to http://<IP address of CoFyBox>:3218
.
Full details at Dynamic2MQTT Configuration.
The service does not directly control assets (switches, etc), but rather provides an indication whether they should be on
or off
. This on
/off
value can be picked up from the MQTT bus and used in Home Assistant automations, etc.
data/sensor/dynamic_prices/devices/living_room_radiator: {"state": "on", "on_at": "2021-04-09T16:30:00Z", "off_at": "2021-04-09T17:00:00Z"
The dynamic2mqtt
service also provides Home Assistant compatible sensors that are available for auto discovery.
Home Assistant requires a topic such as homeassistant/sensor/dynamic_price/current_price/state
, with a configuration message to homeassistant/sensor/dynamic_price/current_price/config
.
The message topics match what is documented above.
The RescoopVPP Dynamic API has not yet been implemented and still needs to be specified.
The hope is that is can be implemented in a similar way to the Octopus Agile API.