Giter VIP home page Giter VIP logo

nimikko / octoblock Goto Github PK

View Code? Open in Web Editor NEW

This project forked from badguy99/octoblock

0.0 0.0 0.0 67 KB

Octoblock is an app which works under AppDaemon within Home Assistant which finds the cheapest “n” hour block for import or the most expensive “n” hour block for export, and works out the price of that block, for the Octopus Energy, Agile Octopus / Agile Outgoing Octopus tariffs.

License: MIT License

Python 100.00%

octoblock's Introduction

octoblock

Octoblock is an app which works under AppDaemon within Home Assistant which finds the cheapest “n” hour block for import or the most expensive “n” hour block for export, and works out the price of that block, for the Octopus Energy, Agile Octopus / Agile Outgoing Octopus tariffs. It creates and sets sensors for the cost and start time, for example, using the apps.yaml file below, the following entities are created and then updated:

sensor.octopus_1hour_time
sensor.octopus_1hour_price
sensor.octopus_1_5hour_time
sensor.octopus_1_5hour_price

Sensors for export will be created with naming such as:

sensor.octopus_export_1hour_time
sensor.octopus_export_1hour_price

With start_period set to now and hour set to 0 the current import or export price is returned, and the sensors are named:

sensor.octopus_current_price
sensor.octopus_export_current_price

hacs_badge

Installation

Use HACS or download the octoblock directory from inside the apps directory here to your local apps directory, then add the configuration to enable the octoblock module.

apps.yaml Configuration

octo_block_1hour:
  module: octoblock
  class: OctoBlock
  region: H
  hour: 1
  use_timezone: False

octo_block_90minutes:
  module: octoblock
  class: OctoBlock
  region: H
  hour: 1.5
  start_period: today
  use_timezone: True
  limits:
    start_time: '07:00'
    end_time: '16:00'

The module and class sections need to remain as above, other sections should be changed as required.

Field Changeable Example
Title Yes octo_block_1hour
module No octoblock
class No OctoBlock
region Yes H
hour Yes 1
start_period Yes today
use_timezone Yes True
import Yes True
export Yes False
limits:
start_time Yes '07:00'
end_time Yes '16:00'

You can have multiple blocks with different time periods (hour setting) or starting points (start_period setting) as needed. It will work with whole hour or half hour blocks in the hour setting.

region is the region letter from the end of E-1R-AGILE-18-02-21-H which can be found on the Octopus Energy developer dashboard webpage in the Unit Rates section for your account.

start_period is optional, it can be set to either now or today, and will default to now

now and today give subtly different results. now is re-evaluated every time the callback is run (once every 30 minutes), and today uses a start time of 00:00:00 with today's date.

This means that using today you will get the absolute cheapest block for today, even if that is in the past, and using now will get the cheapest block for the remainder of the day. today may be of more use with automated triggers, and now may be of use when you are wanting to display the cheapest time on a Lovelace UI card and use that information to turn on devices which cannot be automated, by hand.

This may be best illustrated with a couple of pictures:

State information with now start period

Using now start_period this has turned on and off a few times within the day as it is reevaluated as the day goes on

State information with today start period

Using today start_period this has only turned on once during the day

Setting start_period to now and hours to 0 will give the current import or export price.

When using today for the start_period it can be limited further usings limits > start_time and/or limits > end_time (please note the formating in the example yaml above) to restrict the period searched. This may be useful for example if you have something that you only want to run within certain times of the day, due to noise issues etc.

use_timezone can be set to True or False, and defaults to False, it allows you to specify if the date/time should be displayed in UTC (False), or using Europe/London (True) as the timezone. For example, 2020-03-29T02:00:00Z or 2020-03-29T03:00:00 BST respectively.

import and export should be set to True or False as required, import: True and export: False for the Agile Octopus tariff, and import: False and export: True for the Agile Outgoing Octopus tariff.

Home Assistant Automation

The created start time sensors can then be used to trigger automations within Home Assistant. This requires the Time Date integration to be configured as well. The triggers such as the following can be set up to trigger the automations.

trigger:
  platform: template
  value_template: >
  {% if (states("sensor.date_time_iso") + "Z") == (states("sensor.octopus_1hour_time")) %}
    true
  {% endif %}

Lovelace UI Cards

Once the sensors are created, they can be displayed as cards within the Lovelace UI. For example:

type: entities
title: Best 1hr Price
show_header_toggle: false
entities:
  - entity: sensor.octopus_1hour_price
    icon: 'mdi:flash'
    name: Price (p/kWh)
  - entity: sensor.octopus_1hour_time
    icon: 'mdi:clock-outline'
    name: Time
        
type: entities
title: Best 1.5hr Price
show_header_toggle: false
entities:
  - entity: sensor.octopus_1_5hour_price
    icon: 'mdi:flash'
    name: Price (p/kWh)
  - entity: sensor.octopus_1_5hour_time
    icon: 'mdi:clock-outline'
    name: Time

Lovelace UI best usage time example cards

octoblock's People

Contributors

badguy99 avatar markcocker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.