UK "smart" energy meters

nvm, got it working with that integration now. Thanks!

Yeah. it was not obvious to me.
seems like with SMETSv2 and DCC all data is available to all (so to speak).
you just need to know your unique ID’s to get it.

using the DCC data means you only have access to 30min updates, which i assume is because that’s the rate to local meters update the energy supplier. (assumption).

I have not tried to access my data from the GEO trio 2 directly, or from the the GEO Home API. I don’t yet know what is possible, but I assume you can then see more frequent data. Either way, the GEO trio 2 would need the wifi adaptor to connect cloud - and this would maybe make its DRO accessible locally too - or maybe not

You can pull the data from the geo home API with the following, currently it will just spit out the json responses from the API for live and periodic data.

Not a programmer myself so just ripped this from other projects and will look at working out to get this data into HA unless someone beats me to it.

#!/usr/bin/env python
from urllib.request import urlopen
import requests, json

BASE_URL='https://api.geotogether.com/'
LOGIN_URL='usersservice/v2/login'
DEVICEDETAILS_URL='api/userapi/v2/user/detail-systems?systemDetails=true'
LIVEDATA_URL = 'api/userapi/system/smets2-live-data/'
PERIODICDATA_URL = 'api/userapi/system/smets2-periodic-data/'
USERNAME= 'XXXXXXX'
PASSWORD = 'XXXXXXX'

# Request authToken
data = { 'identity' : USERNAME , 'password' : PASSWORD }
r=requests.post(BASE_URL+LOGIN_URL, data=json.dumps(data), verify=False)
authToken = json.loads(r.text)['accessToken']
headers = {"Authorization": "Bearer " + authToken}
#print(authToken)

# Get deviceId
r=requests.get(BASE_URL+DEVICEDETAILS_URL, headers=headers)
deviceId = json.loads(r.text)['systemRoles'][0]['systemId']
#print( 'Device Id: ' + deviceId)


# Get LIVEDATA
r=requests.get(BASE_URL+LIVEDATA_URL+'/'+deviceId, headers=headers)
#a=r.content
#h=' '.join(a)
h = json.loads(r.content)
print(h)


# Get PERIODICDATA
r=requests.get(BASE_URL+PERIODICDATA_URL+'/'+deviceId, headers=headers)
h = json.loads(r.content)
print(h)

This is a good find. Works for me as well! Did you manage to get the data into HA?

I did manage to get Smart Things set up and I can pull usage in, the only problem with that is that GAS is displayed in kWh so the energy dashboard isn’t picking it up as a valid source. A problem for another day, but glad it worked for you too!

First post so go easy on me…

After tinkering for a few days I finally have my Trio II device integrated with GeoTogether’s API and HA. To save anybody else some time please see below steps for getting it working.

PLEASE NOTE.
You will need a wifi enabled Trio. Mine wasn’t and I had to buy this geo WiFi Module - Green Energy Options : Green Energy Options to get it working.
Once installed you will also need to create an account with the Geo Home app to get a username and password. Google is your friend if you have issues setting this up.

For the integration a big thanks to Owain Lloyd @ https://github.com/owainlloyd/Geohome_Integration/blob/725e006225ac9bffe0a15d241db5a3ea22d92f9b/geohome.py for doing the heavy lifting with figuring out Geo’s API.

To get the integration working with HA:

STEP 1
For your integration to work you will need your Geo Device ID. Their API also uses an auth token which complicates things slightly as you need it for each call.

To get the auth token you will need to run this from a command prompt:

curl -X POST -H "Content-Type: application/json" -d '{"identity": "PUT_YOUR_GEO_USERNAME_HERE", "password": "PUT_YOUR_GEO_PASSWORD_HERE"}' https://api.geotogether.com/usersservice/v2/login

This will give you a temporary access token we then use that in the next call to get your device id. Please note only cut the accesstoken element from the returned json

curl -H "Authorization: Bearer PASTE_AUTH_TOKEN_FROM_PREVIOUS_CALL_HERE" 'https://api.geotogether.com/api/userapi/v2/user/detail-systems?systemDetails=true'

This will give you your systemId which won’t change so make a note of. You just need the systemId element of the returned json.

STEP 2

Copy and paste the below into your configuration.yaml file changing the “PUT_YOUR_XXX” values to your own. I am getting a weird ‘entity_unexpected_device_class’ warning on the Gas consumption still but the data is working. I think this is due to functionality of the underlying Energy dashboard rather than my settings and HA is pulling my data in consistently now so hopefully this will be resolved in a later release.

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

  - platform: command_line
    command: >
      curl 
      -H "Authorization: Bearer {{ state_attr('sensor.geo_accesstoken', 'accessToken') }}"
      -H "Accept: application/json" 
      -H "Content-Type: application/json"
      'https://api.geotogether.com/api/userapi/system/smets2-live-data/PUT_YOUR_SYSTEMID_HERE'
    name: geo_energy_usage_live
    scan_interval: 30
    value_template: "OK"
    json_attributes:
      - power

  - platform: command_line
    command: >
      curl 
      -H "Authorization: Bearer {{ state_attr('sensor.geo_accesstoken', 'accessToken') }}"
      -H "Accept: application/json" 
      -H "Content-Type: application/json"
      'https://api.geotogether.com/api/userapi/system/smets2-periodic-data/PUT_YOUR_SYSTEMID_HERE'
    name: geo_energy_usage_total
    scan_interval: 600
    value_template: "OK"
    json_attributes:
      - totalConsumptionList
      
  - platform: template
    sensors:
      geo_gas_usage_total:
        friendly_name: 'Total Gas Used'
        value_template: "{{ state_attr('sensor.geo_energy_usage_total','totalConsumptionList') | selectattr('commodityType', 'equalto', 'GAS_ENERGY') | map(attribute='totalConsumption') | first/1000 }}"
        unit_of_measurement: "m³"
        attribute_templates:
          last_reset: '1970-01-01T00:00:00+00:00'
          device_class: gas
          state_class: total_increasing
      geo_electricity_usage_total:
        friendly_name: 'Total Electricity Used'
        value_template: "{{ state_attr('sensor.geo_energy_usage_total','totalConsumptionList') | selectattr('commodityType', 'equalto', 'ELECTRICITY') | map(attribute='totalConsumption') | first }}"
        device_class: energy
        unit_of_measurement: "kWh"
      geo_gas_usage_live:
        friendly_name: 'Live Gas Usage'
        value_template: "{{ state_attr('sensor.geo_energy_usage_live','power') | selectattr('type', 'equalto', 'GAS_ENERGY') | map(attribute='watts') | first }}"
        device_class: energy
        unit_of_measurement: "Wh"
      geo_electricity_usage_live:
        friendly_name: 'Live Electricity Usage'
        value_template: "{{ state_attr('sensor.geo_energy_usage_live','power') | selectattr('type', 'equalto', 'ELECTRICITY') | map(attribute='watts') | first }}"
        device_class: energy
        unit_of_measurement: "Wh"
   

utility_meter:
  electricity:
    source: sensor.geo_electricity_usage_total
  gas:
    source: sensor.geo_gas_usage_total

You then need to select these sensor’s as statistics in the Energy Dashboard and Robert is your senior male relative.

Please feel free to suggest tweaks to the Jinja templates. I am new to Jinja and I am sure their are more polished ways of using the templates.

4 Likes

Jason, many thanks for this.

I am almost there I think. I get the correct responses from the command line and now have an access token stored within sensor but I cannot get the command line curl to work in Home Assistant. I’m pretty sure it’s a formatting error on my end. I have my sensor file broken out from main config with an !include.

- platform: command_line
  command: >
	curl
	-H "Authorization: Bearer {{ state_attr('sensor.geo_accesstoken', 'accessToken') }}"
	-H "Accept: application/json" 
	-H "Content-Type: application/json" 
	'https://api.geotogether.com/api/userapi/system/smets2-live-data/XXX_ID_XXX'
  name: geo_energy_usage_live
  scan_interval: 30
  value_template: "OK"
  json_attributes:
    - power

Thanks for this, I don’t see the new entities as options for tracking energy in the energy dashboard?

Thanks for this, it worked perfectly first time.

Hi there,

I have set up the Bright app and can see my usage on it no issues. I reach out to Bright support to enable the MQTT but they advised that i need to buy a glow as mine is being pulled out via the API. If i add in HA i get an error saying no CAD found.

Hey @blair.ogilvie1, it sounds like you are trying to use this integration. You’ll want to use my integration, as that’ll allow you to pull data directly via the DCC without needing Hildebrand’s CAD.

2 Likes

Perfect,

Thanks that is working perfectly now. Thanks for this and thanks for such a great Integration.

1 Like

Very very late to the party here…

If I am reading your post correctly, are you saying I don’t need the Glow CAD at all and this will work with my existing SMETS 2 meter?

1 Like

That’s correct you can use the Bright App and set up the custom integration @HandyHat has mentioned.

Android Apps by Hildebrand Technology Ltd on Google Play

3 Likes

Hey @MrJT

I followed this and it worked perfectly for a week or so, suddenly everything went crazy and all of the sensors disappeared apart from the sensor.electricity & sensor.gas, with my energy readings gone crazy as its assuming i’m using my total energy consumed not the live readings.

Any idea why it would have done this? (my config has not changed at all, device is connected, etc. & the Geo Home app is reporting the correct readings for the meter)

Wondering if maybe i’m not alone and its an api thing that has caused this?

Regards,
James

UPDATE:

After moving the Geotogether Sensor code to the bottom of my configuration.yaml, everything appears to be back to normal.

  • Definitely a syntax thing with other integrations, would highly recommend placing this energy integration at the bottom of your config or in a separate yaml to prevent this :slight_smile:
1 Like

I just received this from Bulb:

We’re updating your smart electricity meter

Hi Martha,

We’ve been taking automatic readings from your smart electricity meter for a while now, but we wanted to let you know we’re working on another upgrade behind the scenes. Soon it will be sending meter readings through the latest version of the smart network, called the DCC.

Your electricity meter is first generation, also called SMETS1. Originally, this type of meter could only be read by the supplier that installed it. We’ve been able to read your meter for a while now, which is great. But this last piece of work means that even if you switch supplier in the future, your meters will stay smart.

So I’m wondering what that means for me. I came here via a Google search as I’ve always wanted my energy consumption to be available in HA. I guess I’m being upgraded to SMENTS2? I’m guessing once the switch happens, I’ll be able to pull my data in with the Hildebrand Glow (DCC) Integration?

Indeed you will be able to do that once the data is flowing. Hopefully, the firmware will support the “dcc_other” user which is required by Hildebrand to pull the data to be displayed in their Bright app.

Jason,

I have tried your YAML code but so far without success.

When I look up the entities that have been set up I can see:

sensor.geo_accessToken - the STATE is showing as “OK” and the attributes for this entity are correctly showing the digits for an accessToken which has been provided by the API request so I presume I have managed to at least get past this part of the API request.

sensor.geo_energy_usage_total
sensor.geo_energy_usage_live
Both of the above are showing as entities with a STATE of “OK”. The Attributes are just showing the Friendly name:
friendly_name: geo_energy_usage_live
friendly_name: geo_energy_usage_total

sensor.geo_gas_usage_live
sensor.geo_gas_usage_total

sensor.geo_gas_usage_live - showing nothing under the STATE and attributes and seems properly populated with the friendly name, device class and unit of measurement

sensor.geo_gas_usage_total - showing as unavailable under the STATE and attributes are populated in accordance with the template (although not sure why the temp[late did not specify device_class like the others)

sensor.geo_electriciy_usage_live
sensor.geo_electricity_usage_total

sensor.geo_electriciy_usage_live - showing nothing under the STATE and attributes are properly populated with the friendly name, device class and unit of measurement

sensor.geo_electriciy_usage_total - showing nothing under the STATE and attributes are properly populated with the friendly name, device class and unit of measurement

I did try to set up in the Energy dashboard per your post but when I click on “add consumption” the sensors (entities) are not showing up

Any assistance would be appreciated.
Rgds
Gavin

Capture

I have a similar issue. I added a card to see what’s going on and i can only get live usage.
Thnx

Unfortunately none of mine are working yet. Did you implement the YAML script exactly as per Jason’s post or was there any additional changes to make?

I am still trying to figure out where the process is failing…because I can see the authorisation token I know it has at least got past that stage but I cant see any data so I presume the curl command to use the accessToken to get the live and total data is not working.