mmillmor / geo_home

Geo Home smart meter integration for Home Assistant
Apache License 2.0
25 stars 4 forks source link

Integration does not support export reading #11

Open modulo- opened 1 year ago

modulo- commented 1 year ago

Hi, Could you please explore adding the export reading from the IHD to the integration? I'm not familiar with the data the IHD exposes, so if this is not feasible, fair enough.

mmillmor commented 1 year ago

I don't have export readings on my IHD, so don't know what to add to the code. However, if you do then I can use that. What we need is to know what the output looks like in such circumstances.

If you go in and edit /config/custom_components/geo_home/geohome.py and replace it with the attached version that contains some extra logging geohome.zip. After replacing the file , restart the system, and you will get something like this in the logs;

2023-01-16 12:22:17.048 WARNING (SyncWorker_8) [custom_components.geo_home.geohome] {'latestUtc': 1673871736, 'id': 'REDACTED', 'power': [{'type': 'ELECTRICITY', 'watts': X, 'valueAvailable': True}, {'type': 'GAS_ENERGY', 'watts': X, 'valueAvailable': True}], 'powerTimestamp': 1673871736, 'localTime': 1673871736, 'localTimeTimestamp': 1673871736, 'creditStatus': None, 'creditStatusTimestamp': 0, 'remainingCredit': None, 'remainingCreditTimestamp': 0, 'zigbeeStatus': {'electricityClusterStatus': 'CONNECTED', 'gasClusterStatus': 'CONNECTED', 'hanStatus': 'CONNECTED', 'networkRssi': -79}, 'zigbeeStatusTimestamp': 1673871736, 'emergencyCredit': None, 'emergencyCreditTimestamp': 0, 'systemStatus': [{'component': 'DISPLAY', 'statusType': 'STATUS_OK', 'systemErrorCode': 'ERROR_CODE_NONE', 'systemErrorNumber': 0}, {'component': 'ZIGBEE', 'statusType': 'STATUS_OK', 'systemErrorCode': 'ERROR_CODE_NONE', 'systemErrorNumber': 0}, {'component': 'ELECTRICITY', 'statusType': 'STATUS_OK', 'systemErrorCode': 'ERROR_CODE_NONE', 'systemErrorNumber': 0}, {'component': 'GAS', 'statusType': 'STATUS_OK', 'systemErrorCode': 'ERROR_CODE_NONE', 'systemErrorNumber': 0}], 'systemStatusTimestamp': 1673871736, 'temperature': 0.0, 'temperatureTimestamp': 0, 'ttl': 120}

2023-01-16 12:22:17.241 WARNING (SyncWorker_8) [custom_components.geo_home.geohome] {'ttl': 1800, 'latestUtc': 1673871622, 'id': 'REDACTED', 'totalConsumptionList': [{'commodityType': 'ELECTRICITY', 'readingTime': 1673871612, 'totalConsumption': X, 'valueAvailable': True}, {'commodityType': 'GAS_ENERGY', 'readingTime': 1673870400, 'totalConsumption': X, 'valueAvailable': True}], 'totalConsumptionTimestamp': 1673871622, 'supplyStatusList': [{'commodityType': 'ELECTRICITY', 'supplyStatus': 'SUPPLYON'}, {'commodityType': 'GAS_ENERGY', 'supplyStatus': 'SUPPLYON'}], 'supplyStatusTimestamp': 1673871622, 'billToDateList': [{'commodityType': 'ELECTRICITY', 'billToDate': X, 'validUTC': 1673871617, 'startUTC': 1673049600, 'duration': 2678400, 'valueAvailable': True}, {'commodityType': 'GAS_ENERGY', 'billToDate': X, 'validUTC': 946684800, 'startUTC': 1673067600, 'duration': 2678400, 'valueAvailable': True}], 'billToDateTimestamp': 1673871622, 'activeTariffList': [{'commodityType': 'ELECTRICITY', 'valueAvailable': True, 'nextTariffStartTime': 1673902800, 'activeTariffPrice': X, 'nextTariffPrice': X, 'nextPriceAvailable': True}, {'commodityType': 'GAS_ENERGY', 'valueAvailable': True, 'nextTariffStartTime': 0, 'activeTariffPrice': X, 'nextTariffPrice': 0.0, 'nextPriceAvailable': False}], 'activeTariffTimestamp': 1673871622, 'currentCostsElec': [{'commodityType': 'ELECTRICITY', 'duration': 'DAY', 'period': 0, 'costAmount': X, 'energyAmount': X}, {'commodityType': 'ELECTRICITY', 'duration': 'WEEK', 'period': 0, 'costAmount': X, 'energyAmount': X}, {'commodityType': 'ELECTRICITY', 'duration': 'MONTH', 'period': 0, 'costAmount': X, 'energyAmount': X}], 'currentCostsElecTimestamp': 1673871622, 'currentCostsGas': [{'commodityType': 'GAS_ENERGY', 'duration': 'DAY', 'period': 0, 'costAmount': X, 'energyAmount': X}, {'commodityType': 'GAS_ENERGY', 'duration': 'WEEK', 'period': 0, 'costAmount': X, 'energyAmount': X}, {'commodityType': 'GAS_ENERGY', 'duration': 'MONTH', 'period': 0, 'costAmount': X, 'energyAmount': X}], 'currentCostsGasTimestamp': 1673871622, 'prePayDebtList': None, 'prePayDebtTimestamp': 0, 'billingMode': [{'billingMode': 'CREDIT', 'commodityType': 'ELECTRICITY', 'valueAvailable': True}, {'billingMode': 'CREDIT', 'commodityType': 'GAS_ENERGY', 'valueAvailable': True}], 'billingModeTimestamp': 1673871622, 'budgetRagStatusDetails': [{'currDay': 'AMBER', 'yesterDay': 'GREEN', 'currWeek': 'AMBER', 'lastWeek': 'RED', 'currMth': 'AMBER', 'lastMth': 'RED', 'thisYear': 'GREEN', 'valueAvailable': True, 'commodityType': 'ELECTRICITY'}, {'currDay': 'AMBER', 'yesterDay': 'RED', 'currWeek': 'AMBER', 'lastWeek': 'RED', 'currMth': 'AMBER', 'lastMth': 'RED', 'thisYear': 'GREEN', 'valueAvailable': True, 'commodityType': 'GAS_ENERGY'}], 'budgetRagStatusDetailsTimestamp': 1673871622, 'budgetSettingDetails': [{'valueAvailable': True, 'energyAmount': X, 'costAmount': X, 'budgetToC': 1621460866, 'commodityType': 'ELECTRICITY'}, {'valueAvailable': True, 'energyAmount': X, 'costAmount': X, 'budgetToC': 1621460866, 'commodityType': 'GAS_ENERGY'}], 'budgetSettingDetailsTimestamp': 1673871622, 'setPoints': {'daySetPoint': {'temperatureSetPoint': X, 'timeOfChange': 0}, 'nightSetPoint': {'temperatureSetPoint': X, 'timeOfChange': 0}}, 'seasonalAdjustments': [{'valueAvailable': True, 'commodityType': 'ELECTRICITY', 'adjustment': True, 'timeOfChange': 1621460805}, {'valueAvailable': True, 'commodityType': 'GAS_ENERGY', 'adjustment': True, 'timeOfChange': 1621460805}]}

2023-01-16 12:22:17.419 WARNING (SyncWorker_8) [custom_components.geo_home.geohome] {'ttl': 0, 'latestUtc': 1673864421, 'id': 'REDACTED', 'standingChargeList': [{'commodityType': 'ELECTRICITY', 'standingCharge': X, 'valueAvailable': True}, {'commodityType': 'GAS_ENERGY', 'standingCharge': X, 'valueAvailable': True}], 'standingChargeTimestamp': 1673864421, 'tariffNameList': [{'commodityType': 'ELECTRICITY', 'tariffName': '', 'valueAvailable': True}, {'commodityType': 'GAS_ENERGY', 'tariffName': '', 'valueAvailable': True}], 'tariffNameTimestamp': 1673864421, 'debtRegisterList': None, 'debtRegisterTimestamp': 0, 'powerThresholdsElectricity': {'elementValidity': True, 'lowMediumThreshold': X, 'mediumHighThreshold': X, 'highThreshold': X}, 'powerThresholdsGas': {'elementValidity': True, 'lowMediumThreshold': X, 'mediumHighThreshold': X, 'highThreshold': X}, 'powerThresholdsTimestamp': 1673864421, 'customerIds': [{'commodityType': 'ELECTRICITY', 'valueAvailable': True, 'customerId': '____'}, {'commodityType': 'GAS_ENERGY', 'valueAvailable': True, 'customerId': '0000'}], 'customerIdsTimestamp': 1673864421}

Please send the logs. You should redact any IDs and costs, like I did above

modulo- commented 1 year ago

Hi, Sorry I've not been able to get the logs yet, but please see the API responses below. Seems like this information may not be accessible via the API. I've also emailed them just now to ask.

/api/userapi/v2/user/detail-systems?systemDetails=true

{"systemRoles":[{"name":"XXX","systemId":"XXX","roles":["READ","WRITE"]}],"systemDetails":[{"name":"XXX","devices":[{"deviceType":"TRIO_II_TB_GEO","sensorType":94,"nodeId":0,"versionNumber":{"major":5,"minor":9},"pairedTimestamp":0,"pairingCode":"XXX","upgradeRequired":false},{"deviceType":"WIFI_MODULE","sensorType":81,"nodeId":64,"versionNumber":{"major":2,"minor":6},"pairedTimestamp":0,"pairingCode":"XXX","upgradeRequired":false},{"deviceType":"JN5169_ZIGBEE","sensorType":96,"nodeId":65,"versionNumber":{"major":139,"minor":142},"pairedTimestamp":0,"pairingCode":"XXX","upgradeRequired":false}],"systemId":"XXX"}]}

/api/userapi/system/smets2-live-data/XXX

{ "latestUtc": 1673912981, "id": "XXX", "power": [ { "type": "ELECTRICITY", "watts": 221, "valueAvailable": true }, { "type": "GAS_ENERGY", "watts": 1920, "valueAvailable": true } ], "powerTimestamp": 1673912981, "localTime": 1673912981, "localTimeTimestamp": 1673912981, "creditStatus": null, "creditStatusTimestamp": 0, "remainingCredit": null, "remainingCreditTimestamp": 0, "zigbeeStatus": { "electricityClusterStatus": "CONNECTED", "gasClusterStatus": "CONNECTED", "hanStatus": "CONNECTED", "networkRssi": -81 }, "zigbeeStatusTimestamp": 1673912981, "emergencyCredit": null, "emergencyCreditTimestamp": 0, "systemStatus": [ { "component": "DISPLAY", "statusType": "STATUS_OK", "systemErrorCode": "ERROR_CODE_NONE", "systemErrorNumber": 0 }, { "component": "ZIGBEE", "statusType": "STATUS_OK", "systemErrorCode": "ERROR_CODE_NONE", "systemErrorNumber": 0 }, { "component": "ELECTRICITY", "statusType": "STATUS_OK", "systemErrorCode": "ERROR_CODE_NONE", "systemErrorNumber": 0 }, { "component": "GAS", "statusType": "STATUS_OK", "systemErrorCode": "ERROR_CODE_NONE", "systemErrorNumber": 0 } ], "systemStatusTimestamp": 1673912981, "temperature": 0, "temperatureTimestamp": 0, "ttl": 120 }

Periodic and daily endpoints are much the same that they show Gas and Electricity, but only the import reading/config

modulo- commented 1 year ago

Their support came back quickly!

Screenshot_20230119-101459~2

Ricky1790 commented 1 year ago

Following this also l, I have used your geohome.py and checked through the logs as as of yet there nothing relating to export in the logs I even did a search for my export reading to check it wasn't called something obscure hopefully it can be found once Geo update their app.

It's the missing feature from my energy map at the moment I can track import and generation currently so being able to get live export reading would be amazing.

On another note I have had to hard code my email and pass into the geohome.py file as I couldn't get it to accept through ha but once I've done this it's run fine ever since

m315426 commented 1 year ago

I have export readings and it appears as a negative number for the live data (e.g. -153W) I hope this can help add export readings to the energy dashboard?

mmillmor commented 1 year ago

I don't see export readings in the data for me (even though I have solar panels). Can you share more details about the data you see with me so that I can try to incorporate it?

MattHadfield113 commented 1 year ago

If you go into the settings on the Geo Trio, then to meters, it does have an export reading in there, so likely just needs exposing in the API.

Ricky1790 commented 1 year ago

I have exactly the same on the trio I can see export total reading but the data isn't in the Geo integration (although this isn't in the Geo home app also so Geo themselves may not be pulling the data)

m315426 commented 1 year ago

Ricky is right here, what I meant to say was that when I am exporting then there is a value in the Geo app with "exporting" next to it, it is only on the live data though so a total will have to be worked out in home assistant. When calling the live data endpoint and exporting I get a negative value like the following

{
    "latestUtc": ...,
    "id": ...,
    "power": [
        {
            "type": "ELECTRICITY",
            "watts": -153,
            "valueAvailable": true
        },
    ...
mmillmor commented 1 year ago

This doesn't actually tell you the real export amount though. The power is simply an instantaneous measurement, which only gets updated every 30 seconds or so. The snapshot may be good enough - you'd need to experiment. What you could do is create a template sensor for "export power" as follows;

{%- if states.sensor.electricity_power.state | int  < 0 -%}
  {{states.sensor.electricity_power.state | int * -1}}
{%- else -%}
  0
{%- endif -%}

Or if you use Powercalc, you could have the power as a template value of {{states.sensor.electricity_power.state | int * -1}} and a condition of states.sensor.electricity_power.state | int < 0 and that will give you energy for it

Ricky1790 commented 1 year ago

That is exactly what I was looking for thank you so much