Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Get your meter URL and add it to the below curl command. You can find this at https://octopus.energy/dashboard/developer/
- 2. Enter your API key from the dashboard into client ID at https://support.brightcove.com/base-64-encoding-tool and hit encode and replace ADD YOUR API KEY WITH THE encoded authentication string
- 3. Add to your Home Assistant YAML and restart
- # Smart Meter - Get JSON data from the meter for last 7 days
- - platform: command_line
- name: Electricity Raw Data - 7 days
- scan_interval: 7200
- value_template: '{{ value_json.count }}'
- json_attributes:
- - results
- command: >-
- curl -H '"'Authorization: Basic ADD YOUR API KEY'"' '"'https://api.octopus.energy/v1/electricity-meter-points/ADD YOUR OWN METER HERE/consumption/?period_from={{ (as_timestamp(now()) - (8*86400)) | timestamp_custom("%Y-%m-%d", True) }}T00:00:00&period_to={{ (as_timestamp(now()) - (2*86400)) | timestamp_custom("%Y-%m-%d", True) }}T23:30:00&page_size=336'"'
- # Add up all JSON data
- - platform: template
- sensors:
- electricity_7_days:
- friendly_name: Electricity Usage - Last 7 days
- icon_template: mdi:flash
- unit_of_measurement: 'kWh'
- value_template: '{{ (state_attr("sensor.electricity_raw_data_7_days", "results") | map(attribute="consumption") | sum ) | round(0)}}'
- # Smart Meter - Work out cost
- # Electricity - 14.50p per kwh & 20.15p per day
- electricity_7_days_cost:
- friendly_name: Electricity Cost - Last 7 days
- icon_template: mdi:currency-gbp
- value_template: '{{ "£%.2f"|format (float(states.sensor.electricity_7_days.state)*0.1450+1.4105)}}'
Add Comment
Please, Sign In to add comment