UK "smart" energy meters

I’ve been using a rest sensor :

# Geotogether Sensor
- platform: rest
  name: geo_accesstoken
  method: POST
  payload: '{ "identity" : "USERNAME", "password": "PASSWORD" }'
  resource: https://api.geotogether.com/usersservice/v2/login
  scan_interval: 3000
  value_template: "{{ value_json.username }}"
  json_attributes:
    - accessToken

- platform: rest
  name: geo_energy_usage_live
  resource: https://api.geotogether.com/api/userapi/system/smets2-live-data/SYSTEMID
  headers:
    Authorization: >
      Bearer {{ state_attr('sensor.geo_accesstoken', 'accessToken') }}
  scan_interval: 30
  value_template: "{{ value_json.id | default('unknown') }}"
  json_attributes:
    - power

- platform: rest
  name: geo_energy_usage_total
  resource: https://api.geotogether.com/api/userapi/system/smets2-periodic-data/SYSTEMID
  headers:
    Authorization: >
      Bearer {{ state_attr('sensor.geo_accesstoken', 'accessToken') }}
  scan_interval: 300
  value_template: "{{ value_json.id | default('unknown') }}"
  json_attributes:
    - totalConsumptionList
    - activeTariffList

and some template sensors:

- sensor:
  - name: "Total Gas Used"
    unique_id: geo_total_gas_used
    state: "{{ state_attr('sensor.geo_energy_usage_total','totalConsumptionList') | selectattr('commodityType', 'equalto', 'GAS_ENERGY') | map(attribute='totalConsumption') | first/1000*11.1868 | round(2) if is_state('sensor.geo_energy_usage_total','SYSTEMID') else 'unknown' }}"
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
  - name: "Total Electricity Used"
    unique_id: geo_total_electricity_used
    state: "{{ state_attr('sensor.geo_energy_usage_total','totalConsumptionList') | selectattr('commodityType', 'equalto', 'ELECTRICITY') | map(attribute='totalConsumption') | first | round(2) if is_state('sensor.geo_energy_usage_total','SYSTEMID') else 'unknown' }}"
    device_class: energy
    state_class: total_increasing
    unit_of_measurement: "kWh"
  - name: "Live Gas Usage"
    unique_id: "geo_live_gas_usage"
    state: "{{ state_attr('sensor.geo_energy_usage_live','power') | selectattr('type', 'equalto', 'GAS_ENERGY') | map(attribute='watts') | first if is_state('sensor.geo_energy_usage_live','SYSTEMID') else 'unknown' }}"
    device_class: power
    state_class: measurement
    unit_of_measurement: "W"
  - name: "Live Electricity Usage"
    unique_id: "geo_live_electricity_usage"
    state: "{{ state_attr('sensor.geo_energy_usage_live','power') | selectattr('type', 'equalto', 'ELECTRICITY') | map(attribute='watts') | first if is_state('sensor.geo_energy_usage_live','SYSTEMID') else 'unknown' }}"
    device_class: power
    state_class: measurement
    unit_of_measurement: "W"
  - name: "Gas Active Tariff"
    unique_id: geo_gas_active_tariff
    state: "{{ state_attr('sensor.geo_energy_usage_total','activeTariffList') | selectattr('commodityType', 'equalto', 'GAS_ENERGY') | map(attribute='activeTariffPrice') | first/100 if is_state('sensor.geo_energy_usage_total','SYSTEMID') else 'unknown' }}"
    unit_of_measurement: "GBP/kWh"
  - name: "Electricity Active Tariff"
    unique_id: geo_electricity_active_tariff
    state: "{{ state_attr('sensor.geo_energy_usage_total','activeTariffList') | selectattr('commodityType', 'equalto', 'ELECTRICITY') | map(attribute='activeTariffPrice') | first/100 if is_state('sensor.geo_energy_usage_total','SYSTEMID') else 'unknown' }}"
    unit_of_measurement: "GBP/kWh"

Replace USERNAME, PASSWORD, and SYSTEMID with your details. (I can’t remember how I got SYSTEMID … its in one of the responses to the api)

2 Likes