Great news this will be on HACS
I found that there is another URL that you can pull to get more info about standing charge pricing etc which is “smets2-daily-data”.
I had a bit of a play with the original code posted here https://community.home-assistant.io/t/uk-smart-energy-meters/16545/205 around access tokens etc and set the units for a bunch of sensors as well as availability markers etc.
I have a geo_together_sensor.yaml that now looks like this:
#
# Renew Access Token
#
- platform: rest
name: "Geo API Access Token"
method: POST
payload: '{ "identity" : "[id]", "password": "[password]" }'
resource: https://api.geotogether.com/usersservice/v2/login
scan_interval: 3555
value_template: >
{% if value_json.accessToken is defined %}
{{ "on" }}
{% else %}
{{ "unavailable" }}
{% endif %}
json_attributes:
- accessToken
#
# Get System ID
#
- platform: command_line
command: >
curl
-H "Authorization: Bearer {{ state_attr('sensor.geo_api_access_token', 'accessToken') }}"
-H "Accept: application/json"
-H "Content-Type: application/json"
'https://api.geotogether.com/api/userapi/v2/user/detail-systems'
name: Geo API Details
unique_id: geo_api_details
scan_interval: 3555
value_template: >
{% if value_json.systemRoles is defined %}
{{ "on" }}
{% else %}
{{ "unavailable" }}
{% endif %}
json_attributes:
- systemRoles
#
# Pull Datasets
#
- platform: command_line
command: >
curl
-H "Authorization: Bearer {{ state_attr('sensor.geo_api_access_token', 'accessToken') }}"
-H "Accept: application/json"
-H "Content-Type: application/json"
'https://api.geotogether.com/api/userapi/system/smets2-live-data/{% if states.sensor.geo_system_id.state is defined %}{{ states.sensor.geo_system_id.state }}{% else %}{% endif %}'
name: Geo API Live Data
unique_id: geo_api_live
scan_interval: 60
value_template: >
{% if value_json.power is defined %}
{{ "on" }}
{% else %}
{{ "unavailable" }}
{% endif %}
json_attributes:
- latestUtc
- power
- systemStatus
- platform: command_line
command: >
curl
-H "Authorization: Bearer {{ state_attr('sensor.geo_api_access_token', 'accessToken') }}"
-H "Accept: application/json"
-H "Content-Type: application/json"
'https://api.geotogether.com/api/userapi/system/smets2-periodic-data/{% if states.sensor.geo_system_id.state is defined %}{{ states.sensor.geo_system_id.state }}{% else %}{% endif %}'
name: Geo API Periodic Data
unique_id: geo_api_periodic
scan_interval: 600
value_template: >
{% if value_json.totalConsumptionList is defined %}
{{ "on" }}
{% else %}
{{ "unavailable" }}
{% endif %}
json_attributes:
- latestUtc
- totalConsumptionList
- billToDateList
- activeTariffList
- currentCostsElec
- currentCostsGas
- platform: command_line
command: >
curl
-H "Authorization: Bearer {{ state_attr('sensor.geo_api_access_token', 'accessToken') }}"
-H "Accept: application/json"
-H "Content-Type: application/json"
'https://api.geotogether.com/api/userapi/system/smets2-daily-data/{% if states.sensor.geo_system_id.state is defined %}{{ states.sensor.geo_system_id.state }}{% else %}{% endif %}'
name: Geo API Daily Data
unique_id: geo_api_daily
scan_interval: 3555
value_template: >
{% if value_json.standingChargeList is defined %}
{{ "on" }}
{% else %}
{{ "unavailable" }}
{% endif %}
json_attributes:
- latestUtc
- standingChargeList
Then I have a geo_together_template.yaml file that looks like this:
- sensor:
#
# Detail Sensors - System ID
#
- unique_id: geo_system_id
name: 'Geo System ID'
state: >
{{
state_attr('sensor.geo_api_details','systemRoles') |
map(attribute='systemId') |
first
}}
availability: >
{{ states.sensor.geo_api_details.state }}
#
# Daily Sensors - Standing Charge
#
- unique_id: geo_electricity_standing_charge
name: 'Geo Electricity Standing Charge'
state: >
{{
(
state_attr('sensor.geo_api_daily_data','standingChargeList') |
selectattr('commodityType', 'equalto', 'ELECTRICITY') |
map(attribute='standingCharge') |
first /100
) |
round(5)
}}
availability: >
{{
states.sensor.geo_api_daily_data.state and
(
state_attr('sensor.geo_api_daily_data','standingChargeList') |
selectattr('commodityType', 'equalto', 'ELECTRICITY') |
map(attribute='valueAvailable') |
first
) == true
}}
device_class: monetary
unit_of_measurement: "GBP"
- unique_id: geo_gas_standing_charge
name: 'Geo Gas Standing Charge'
state: >
{{
(
state_attr('sensor.geo_api_daily_data','standingChargeList') |
selectattr('commodityType', 'equalto', 'GAS_ENERGY') |
map(attribute='standingCharge') |
first /100
) |
round(5)
}}
availability: >
{{
states.sensor.geo_api_daily_data.state and
(
state_attr('sensor.geo_api_daily_data','standingChargeList') |
selectattr('commodityType', 'equalto', 'GAS_ENERGY') |
map(attribute='valueAvailable') |
first
) == true
}}
device_class: monetary
unit_of_measurement: "GBP"
#
# Periodic Sensors - Total Usage
#
- unique_id: geo_gas_total_consumption_m3
name: 'Geo Gas Total Consumption m³'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','totalConsumptionList') |
selectattr('commodityType', 'equalto', 'GAS_ENERGY') |
map(attribute='totalConsumption') |
first/1000
) |
round(3)
}}
availability: >
{{
states.sensor.geo_api_periodic_data.state and
(
state_attr('sensor.geo_api_periodic_data','totalConsumptionList') |
selectattr('commodityType', 'equalto', 'GAS_ENERGY') |
map(attribute='valueAvailable') |
first
) == true
}}
unit_of_measurement: "m³"
device_class: gas
state_class: total_increasing
attributes:
last_reset: '1970-01-01T00:00:00+00:00'
- unique_id: geo_gas_total_consumption_kwh
name: 'Geo Gas Total Consumption kWh'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','totalConsumptionList') |
selectattr('commodityType', 'equalto', 'GAS_ENERGY') |
map(attribute='totalConsumption') |
first/1000*1.02264*39.2/3.6
) |
round(3)
}}
availability: >
{{
states.sensor.geo_api_periodic_data.state and
(
state_attr('sensor.geo_api_periodic_data','totalConsumptionList') |
selectattr('commodityType', 'equalto', 'GAS_ENERGY') |
map(attribute='valueAvailable') |
first
) == true
}}
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
attributes:
last_reset: '1970-01-01T00:00:00+00:00'
- unique_id: geo_electricity_total_consumption_kwh
name: 'Geo Electricity Total Consumption kWh'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','totalConsumptionList') |
selectattr('commodityType', 'equalto', 'ELECTRICITY') |
map(attribute='totalConsumption') |
first
) |
round(3)
}}
availability: >
{{
states.sensor.geo_api_periodic_data.state and
(
state_attr('sensor.geo_api_periodic_data','totalConsumptionList') |
selectattr('commodityType', 'equalto', 'ELECTRICITY') |
map(attribute='valueAvailable') |
first
) == true
}}
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
attributes:
last_reset: '1970-01-01T00:00:00+00:00'
#
# Periodic Sensors - Bill to Date
#
- unique_id: geo_electricity_bill_to_date
name: 'Geo Electricity Bill To Date'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','billToDateList') |
selectattr('commodityType', 'equalto', 'ELECTRICITY') |
map(attribute='billToDate') |
first /100
) |
round(2)
}}
availability: >
{{
states.sensor.geo_api_periodic_data.state and
(
state_attr('sensor.geo_api_periodic_data','billToDateList') |
selectattr('commodityType', 'equalto', 'ELECTRICITY') |
map(attribute='valueAvailable') |
first
) == true
}}
device_class: monetary
unit_of_measurement: "GBP"
- unique_id: geo_gas_bill_to_date
name: 'Geo Gas Bill To Date'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','billToDateList') |
selectattr('commodityType', 'equalto', 'GAS_ENERGY') |
map(attribute='billToDate') |
first /100
) |
round(2)
}}
availability: >
{{
states.sensor.geo_api_periodic_data.state and
(
state_attr('sensor.geo_api_periodic_data','billToDateList') |
selectattr('commodityType', 'equalto', 'GAS_ENERGY') |
map(attribute='valueAvailable') |
first
) == true
}}
device_class: monetary
unit_of_measurement: "GBP"
#
# Periodic Sensors - Tarrif
#
- unique_id: geo_electricity_current_unit_price
name: 'Geo Electricity Current Unit Price'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','activeTariffList') |
selectattr('commodityType', 'equalto', 'ELECTRICITY') |
map(attribute='activeTariffPrice') |
first /100
) |
round(5)
}}
availability: >
{{
states.sensor.geo_api_periodic_data.state and
(
state_attr('sensor.geo_api_periodic_data','activeTariffList') |
selectattr('commodityType', 'equalto', 'ELECTRICITY') |
map(attribute='valueAvailable') |
first
) == true
}}
device_class: monetary
unit_of_measurement: "GBP"
- unique_id: geo_gas_current_unit_price
name: 'Geo Gas Current Unit Price'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','activeTariffList') |
selectattr('commodityType', 'equalto', 'GAS_ENERGY') |
map(attribute='activeTariffPrice') |
first /100
) |
round(5)
}}
availability: >
{{
states.sensor.geo_api_periodic_data.state and
(
state_attr('sensor.geo_api_periodic_data','activeTariffList') |
selectattr('commodityType', 'equalto', 'GAS_ENERGY') |
map(attribute='valueAvailable') |
first
) == true
}}
device_class: monetary
unit_of_measurement: "GBP"
#
# Periodic Sensors - Electricity Cost History
#
- unique_id: geo_electricity_cost_today
name: 'Geo Electricity Cost Today'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','currentCostsElec') |
selectattr('duration', 'equalto', 'DAY') |
map(attribute='costAmount') |
first /100
) |
round(2)
}}
availability: >
{{ states.sensor.geo_api_periodic_data.state }}
device_class: monetary
unit_of_measurement: "GBP"
- unique_id: geo_electricity_cost_this_week
name: 'Geo Electricity Cost This Week'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','currentCostsElec') |
selectattr('duration', 'equalto', 'WEEK') |
map(attribute='costAmount') |
first /100
) |
round(2)
}}
availability: >
{{ states.sensor.geo_api_periodic_data.state }}
device_class: monetary
unit_of_measurement: "GBP"
- unique_id: geo_electricity_cost_this_month
name: 'Geo Electricity Cost This Month'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','currentCostsElec') |
selectattr('duration', 'equalto', 'MONTH') |
map(attribute='costAmount') |
first /100
) |
round(2)
}}
availability: >
{{ states.sensor.geo_api_periodic_data.state }}
device_class: monetary
unit_of_measurement: "GBP"
#
# Periodic Sensors - Electricity Consumption History
#
- unique_id: geo_electricity_kwh_today
name: 'Geo Electricity kWh Today'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','currentCostsElec') |
selectattr('duration', 'equalto', 'DAY') |
map(attribute='energyAmount') |
first
) |
round(3)
}}
availability: >
{{ states.sensor.geo_api_periodic_data.state }}
device_class: energy
unit_of_measurement: "kWh"
- unique_id: geo_electricity_kwh_this_week
name: 'Geo Electricity kWh This Week'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','currentCostsElec') |
selectattr('duration', 'equalto', 'WEEK') |
map(attribute='energyAmount') |
first
) |
round(3)
}}
availability: >
{{ states.sensor.geo_api_periodic_data.state }}
device_class: energy
unit_of_measurement: "kWh"
- unique_id: geo_electricity_kwh_this_month
name: 'Geo Electricity kWh This Month'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','currentCostsElec') |
selectattr('duration', 'equalto', 'MONTH') |
map(attribute='energyAmount') |
first
) |
round(3)
}}
availability: >
{{ states.sensor.geo_api_periodic_data.state }}
device_class: energy
unit_of_measurement: "kWh"
#
# Periodic Sensors - Gas Cost History
#
- unique_id: geo_gas_cost_today
name: 'Geo Gas Cost Today'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','currentCostsGas') |
selectattr('duration', 'equalto', 'DAY') |
map(attribute='costAmount') |
first /100
) |
round(2)
}}
availability: >
{{ states.sensor.geo_api_periodic_data.state }}
device_class: monetary
unit_of_measurement: "GBP"
- unique_id: geo_gas_cost_this_week
name: 'Geo Gas Cost This Week'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','currentCostsGas') |
selectattr('duration', 'equalto', 'WEEK') |
map(attribute='costAmount') |
first /100
) |
round(2)
}}
availability: >
{{ states.sensor.geo_api_periodic_data.state }}
device_class: monetary
unit_of_measurement: "GBP"
- unique_id: geo_gas_cost_this_month
name: 'Geo Gas Cost This Month'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','currentCostsGas') |
selectattr('duration', 'equalto', 'MONTH') |
map(attribute='costAmount') |
first /100
) |
round(2)
}}
availability: >
{{ states.sensor.geo_api_periodic_data.state }}
device_class: monetary
unit_of_measurement: "GBP"
#
# Periodic Sensors - Gas Consumption History
#
- unique_id: geo_gas_kwh_today
name: 'Geo Gas kWh Today'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','currentCostsGas') |
selectattr('duration', 'equalto', 'DAY') |
map(attribute='energyAmount') |
first
) |
round(3)
}}
availability: >
{{ states.sensor.geo_api_periodic_data.state }}
device_class: energy
unit_of_measurement: "kWh"
- unique_id: geo_gas_kwh_this_week
name: 'Geo Gas kWh This Week'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','currentCostsGas') |
selectattr('duration', 'equalto', 'WEEK') |
map(attribute='energyAmount') |
first
) |
round(3)
}}
availability: >
{{ states.sensor.geo_api_periodic_data.state }}
device_class: energy
unit_of_measurement: "kWh"
- unique_id: geo_gas_kwh_this_month
name: 'Geo Gas kWh This Month'
state: >
{{
(
state_attr('sensor.geo_api_periodic_data','currentCostsGas') |
selectattr('duration', 'equalto', 'MONTH') |
map(attribute='energyAmount') |
first
) |
round(3)
}}
availability: >
{{ states.sensor.geo_api_periodic_data.state }}
device_class: energy
unit_of_measurement: "kWh"
#
# Live Sensors - Current Usage
#
- unique_id: geo_electricity_current_usage
name: 'Geo Electricity Current Usage'
state: >
{{
(
state_attr('sensor.geo_api_live_data','power') |
selectattr('type', 'equalto', 'ELECTRICITY') |
map(attribute='watts') |
first
) |
round(0)
}}
availability: >
{{
states.sensor.geo_api_live_data.state and
(
state_attr('sensor.geo_api_live_data','power') |
selectattr('type', 'equalto', 'ELECTRICITY') |
map(attribute='valueAvailable') |
first
) == true
}}
device_class: energy
unit_of_measurement: "W"
- unique_id: geo_gas_current_usage
name: 'Geo Gas Current Usage'
state: >
{{
(
state_attr('sensor.geo_api_live_data','power') |
selectattr('type', 'equalto', 'GAS_ENERGY') |
map(attribute='watts') |
first /1000
) |
round(3)
}}
availability: >
{{
states.sensor.geo_api_live_data.state and
(
state_attr('sensor.geo_api_live_data','power') |
selectattr('type', 'equalto', 'GAS_ENERGY') |
map(attribute='valueAvailable') |
first
) == true
}}
device_class: gas
unit_of_measurement: "kW"
#
# Live Sensors - System Status
#
- unique_id: geo_system_status_display
name: 'Geo System Status Display'
state: >
{%
set display = (state_attr('sensor.geo_api_live_data','systemStatus') |
selectattr('component', 'equalto', 'DISPLAY') |
map(attribute='statusType') |
first)
%}
{%
set display_error_code = (state_attr('sensor.geo_api_live_data','systemStatus') |
selectattr('component', 'equalto', 'DISPLAY') |
map(attribute='systemErrorCode') |
first)
%}
{% if display is defined %}
{{ display }} - {{ display_error_code }}
{% else %}
{{ 'ASSUMED_OK' }}
{% endif %}
availability: >
{{ states.sensor.geo_api_live_data.state }}
- unique_id: geo_system_status_zigbee
name: 'Geo System Status Zigbee'
state: >
{%
set zigbee = (state_attr('sensor.geo_api_live_data','systemStatus') |
selectattr('component', 'equalto', 'ZIGBEE') |
map(attribute='statusType') |
first)
%}
{%
set zigbee_error_code = (state_attr('sensor.geo_api_live_data','systemStatus') |
selectattr('component', 'equalto', 'ZIGBEE') |
map(attribute='systemErrorCode') |
first)
%}
{% if zigbee is defined %}
{{ zigbee }} - {{ zigbee_error_code }}
{% else %}
{{ 'ASSUMED_OK' }}
{% endif %}
availability: >
{{ states.sensor.geo_api_live_data.state }}
- unique_id: geo_system_status_electricity
name: 'Geo System Status Electricity'
state: >
{%
set electricity = (state_attr('sensor.geo_api_live_data','systemStatus') |
selectattr('component', 'equalto', 'ELECTRICITY') |
map(attribute='statusType') |
first)
%}
{%
set electricity_error_code = (state_attr('sensor.geo_api_live_data','systemStatus') |
selectattr('component', 'equalto', 'ELECTRICITY') |
map(attribute='systemErrorCode') |
first)
%}
{% if electricity is defined %}
{{ electricity }} - {{ electricity_error_code }}
{% else %}
{{ 'ASSUMED_OK' }}
{% endif %}
availability: >
{{ states.sensor.geo_api_live_data.state }}
- unique_id: geo_system_status_gas
name: 'Geo System Status Gas'
state: >
{%
set gas = (state_attr('sensor.geo_api_live_data','systemStatus') |
selectattr('component', 'equalto', 'GAS') |
map(attribute='statusType') |
first)
%}
{%
set gas_error_code = (state_attr('sensor.geo_api_live_data','systemStatus') |
selectattr('component', 'equalto', 'GAS') |
map(attribute='systemErrorCode') |
first)
%}
{% if gas is defined %}
{{ gas }} - {{ gas_error_code }}
{% else %}
{{ 'ASSUMED_OK' }}
{% endif %}
availability: >
{{ states.sensor.geo_api_live_data.state }}
- unique_id: geo_system_status_wifi
name: 'Geo System Status WiFi'
state: >
{%
set wifi = (state_attr('sensor.geo_api_live_data','systemStatus') |
selectattr('component', 'equalto', 'WIFI') |
map(attribute='statusType') |
first)
%}
{%
set wifi_error_code = (state_attr('sensor.geo_api_live_data','systemStatus') |
selectattr('component', 'equalto', 'WIFI') |
map(attribute='systemErrorCode') |
first)
%}
{% if wifi is defined %}
{{ wifi }} - {{ wifi_error_code }}
{% else %}
{{ 'ASSUMED_OK' }}
{% endif %}
availability: >
{{ states.sensor.geo_api_live_data.state }}
The two files are placed in the respective configuration.sensor.enabled and configuration.template.enabled directories and are loaded with the following lines added to configuration.yaml:
sensor: !include_dir_merge_list configuration.sensor.enabled/
template: !include_dir_merge_list configuration.template.enabled/
@mmillmor could you add the sensors etc to your HACS integration?