Guest User

Untitled

a guest
Dec 15th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. 1. Get your meter URL and add it to the below curl command. You can find this at https://octopus.energy/dashboard/developer/
  2. 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. 3. Add to your Home Assistant YAML and restart
  4.  
  5. # Smart Meter - Get JSON data from the meter for last 7 days
  6. - platform: command_line
  7. name: Electricity Raw Data - 7 days
  8. scan_interval: 7200
  9. value_template: '{{ value_json.count }}'
  10. json_attributes:
  11. - results
  12. command: >-
  13. 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'"'
  14.  
  15. # Add up all JSON data
  16. - platform: template
  17. sensors:
  18. electricity_7_days:
  19. friendly_name: Electricity Usage - Last 7 days
  20. icon_template: mdi:flash
  21. unit_of_measurement: 'kWh'
  22. value_template: '{{ (state_attr("sensor.electricity_raw_data_7_days", "results") | map(attribute="consumption") | sum ) | round(0)}}'
  23.  
  24. # Smart Meter - Work out cost
  25. # Electricity - 14.50p per kwh & 20.15p per day
  26. electricity_7_days_cost:
  27. friendly_name: Electricity Cost - Last 7 days
  28. icon_template: mdi:currency-gbp
  29. value_template: '{{ "£%.2f"|format (float(states.sensor.electricity_7_days.state)*0.1450+1.4105)}}'
Add Comment
Please, Sign In to add comment