BottlecapDave / HomeAssistant-OctopusEnergy

Unofficial Home Assistant integration for interacting with Octopus Energy
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/
MIT License
564 stars 56 forks source link

no smart meter sensors #259

Closed robotfishe closed 1 year ago

robotfishe commented 1 year ago

I installed the integration this morning and it's only giving me the basic sensors, none of the accumulative data I should be getting from my smart meter. The smart meter is definitely working as I can see the data in my Octopus account.

I found this in the device diagnostics:

            "serial_number": "**REDACTED**",
            "is_export": false,
            "is_smart_meter": false,
            "device_id": null,
            "manufacturer": "UTILITA GROUP LIMITED LIBERTY 100",
            "model": null,
            "firmware": null

The weird thing is the model is actually a Liberty 100, but it's definitely a smart meter. Is there any way I can force the integration to recognise this?

BottlecapDave commented 1 year ago

Hi and sorry you're having issues. I've had a few reports of this not reporting back correctly. I'll raise an issue in the Octopus Energy forums to see if I'm determining it correctly. I'll also try and get a release out where in this situation the sensors are available but in a disabled state.

robotfishe commented 1 year ago

Thanks. I've been able to set up some REST API sensors to get info, and I noticed that the API calls will only return data from the previous day and before. It seems like my meter might be saving up all its data for one transmission shortly after midnight, which might explain why it doesn't seem all that "smart" to your integration!

JohnPreston commented 1 year ago

Hello :) Adding to that issue: I have installed the integration, uninstalled it multiple times, no matter what I am doing, I actually don't get any sensor created for my smart meters either. I have followed the setup steps, which at some point asks to fill in a form for rates interval, which also doesn't seem to work (complains there are missing inputs ..)

Am I missing something obvious to setup the MPAN device or is this something the integration should be discovering on itself?

Thanks for your help!

EDIT: the only 2 entities created are:

When querying the API I can see multiple days worth of data.

BottlecapDave commented 1 year ago

I've been able to set up some REST API sensors to get info, and I noticed that the API calls will only return data from the previous day and before. It seems like my meter might be saving up all its data for one transmission shortly after midnight, which might explain why it doesn't seem all that "smart" to your integration!

@robotfishe This is how the smart meters work. They gather data locally, but the data isn't available to Octopus Energy until the following day. I've prepared a new release where the sensors are available in a disabled state in your scenarios so you can enable them to gain access. I've raised a question in the OE forums to get a better understanding of determining smart meters.

BottlecapDave commented 1 year ago

@JohnPreston Even if the integration thinks you don't have a smart meter, you should have more sensors than that. Could you follow these instructions and paste the results in here please?

robotfishe commented 1 year ago

Sure, here's what I've got:

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2023.6.1",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.11.3",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/London",
    "os_name": "Linux",
    "os_version": "6.1.29",
    "supervisor": "2023.06.1",
    "host_os": "Home Assistant OS 10.2",
    "docker_version": "23.0.6",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {
    "solcast_solar": {
      "version": "3.0.47",
      "requirements": [
        "aiohttp>=3.6.2",
        "datetime>=4.3",
        "isodate>=0.6.0"
      ]
    },
    "sun2": {
      "version": "2.2.2",
      "requirements": []
    },
    "multiscrape": {
      "version": "6.5.0",
      "requirements": [
        "lxml==4.9.1",
        "beautifulsoup4==4.11.1"
      ]
    },
    "alphaess": {
      "version": "0.0.13",
      "requirements": [
        "alphaess==0.0.17"
      ]
    },
    "octopus_energy": {
      "version": "7.4.2",
      "requirements": []
    },
    "hacs": {
      "version": "1.32.1",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    }
  },
  "integration_manifest": {
    "domain": "octopus_energy",
    "name": "Octopus Energy",
    "codeowners": [
      "@bottlecapdave"
    ],
    "config_flow": true,
    "dependencies": [
      "repairs",
      "recorder"
    ],
    "documentation": "https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/",
    "homekit": {},
    "iot_class": "cloud_polling",
    "issue_tracker": "https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/issues",
    "ssdp": [],
    "version": "7.4.2",
    "zeroconf": [],
    "is_built_in": false
  },
  "data": {
    "electricity_meter_points": [
      {
        "mpan": "**REDACTED**",
        "meters": [
          {
            "serial_number": "**REDACTED**",
            "is_export": false,
            "is_smart_meter": false,
            "device_id": null,
            "manufacturer": "UTILITA GROUP LIMITED LIBERTY 100",
            "model": null,
            "firmware": null
          }
        ],
        "agreements": [
          {
            "valid_from": "2022-09-12T23:00:00+00:00",
            "valid_to": "2023-09-12T23:00:00+00:00",
            "tariff_code": "E-1R-GO-22-07-05-N",
            "product_code": "GO-22-07-05"
          }
        ]
      }
    ],
    "gas_meter_points": [
      {
        "mprn": "**REDACTED**",
        "meters": [
          {
            "serial_number": "**REDACTED**",
            "consumption_units": "kWh",
            "is_smart_meter": false,
            "device_id": null,
            "manufacturer": "EG4V11",
            "model": null,
            "firmware": null
          }
        ],
        "agreements": [
          {
            "valid_from": "2023-03-31T23:00:00+00:00",
            "valid_to": null,
            "tariff_code": "G-1R-VAR-22-11-01-N",
            "product_code": "VAR-22-11-01"
          }
        ]
      }
    ]
  }
}
BottlecapDave commented 1 year ago

The detection of smart meters should now be improved in the latest release https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/releases/tag/v7.4.3.

@JohnPreston could you try downloading the latest release and then let me know which sensors specifically are missing (if any)

JohnPreston commented 1 year ago

Sorry for the late reply. As it turns out, the error was on the Octopus side where, as I moved house, they hadn't completed all the setup. Once that got done, it all worked perfectly to create all the entities.

BottlecapDave commented 1 year ago

Glad to know your issue is sorted @JohnPreston. I'll close this issue off as the detection has been improved and @robotfishe has been quiet :)

robotfishe commented 1 year ago

@BottlecapDave I was able to get things working by setting up my own rest sensor from scratch, but I've suddenly had some issues with that today so I tried updating your integration and it does seem to be picking up the smart meter. However, there's still no usage data. Another complication is that I now have an export meter set up with Octopus, and your integration is seeing it and correctly identifying the tariff as SEG, but it's not showing it as an export meter. Here's the diagnostic dump, any ideas?

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2023.7.2",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.11.4",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/London",
    "os_name": "Linux",
    "os_version": "6.1.34",
    "supervisor": "2023.07.1",
    "host_os": "Home Assistant OS 10.3",
    "docker_version": "23.0.6",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {
    "solcast_solar": {
      "version": "3.0.47",
      "requirements": [
        "aiohttp>=3.6.2",
        "datetime>=4.3",
        "isodate>=0.6.0"
      ]
    },
    "sun2": {
      "version": "2.3.0",
      "requirements": []
    },
    "alphaess": {
      "version": "0.0.13",
      "requirements": [
        "alphaess==0.0.17"
      ]
    },
    "octopus_energy": {
      "version": "7.5.1",
      "requirements": []
    },
    "hacs": {
      "version": "1.32.1",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    }
  },
  "integration_manifest": {
    "domain": "octopus_energy",
    "name": "Octopus Energy",
    "codeowners": [
      "@bottlecapdave"
    ],
    "config_flow": true,
    "dependencies": [
      "repairs",
      "recorder"
    ],
    "documentation": "https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/",
    "homekit": {},
    "iot_class": "cloud_polling",
    "issue_tracker": "https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/issues",
    "ssdp": [],
    "version": "7.5.1",
    "zeroconf": [],
    "is_built_in": false
  },
  "data": {
    "electricity_meter_points": [
      {
        "mpan": "**REDACTED**",
        "meters": [
          {
            "serial_number": "**REDACTED**",
            "is_export": false,
            "is_smart_meter": true,
            "device_id": null,
            "manufacturer": "UTILITA GROUP LIMITED LIBERTY 100",
            "model": null,
            "firmware": null
          }
        ],
        "agreements": [
          {
            "valid_from": "2023-07-05T23:00:00+00:00",
            "valid_to": "2024-07-05T23:00:00+00:00",
            "tariff_code": "E-1R-OUTGOING-SEG-FIX-12M-20-07-07-N",
            "product_code": "OUTGOING-SEG-FIX-12M-20-07-07"
          }
        ]
      },
      {
        "mpan": "**REDACTED**",
        "meters": [
          {
            "serial_number": "**REDACTED**",
            "is_export": false,
            "is_smart_meter": true,
            "device_id": null,
            "manufacturer": "UTILITA GROUP LIMITED LIBERTY 100",
            "model": null,
            "firmware": null
          }
        ],
        "agreements": [
          {
            "valid_from": "2022-09-12T23:00:00+00:00",
            "valid_to": "2023-09-12T23:00:00+00:00",
            "tariff_code": "E-1R-GO-22-07-05-N",
            "product_code": "GO-22-07-05"
          }
        ]
      }
    ],
    "gas_meter_points": [
      {
        "mprn": "**REDACTED**",
        "meters": [
          {
            "serial_number": "**REDACTED**",
            "consumption_units": "kWh",
            "is_smart_meter": true,
            "device_id": null,
            "manufacturer": "EG4V11",
            "model": null,
            "firmware": null
          }
        ],
        "agreements": [
          {
            "valid_from": "2023-03-31T23:00:00+00:00",
            "valid_to": null,
            "tariff_code": "G-1R-VAR-22-11-01-N",
            "product_code": "VAR-22-11-01"
          }
        ]
      }
    ]
  }
}
BottlecapDave commented 1 year ago

I was able to get things working by setting up my own rest sensor from scratch, but I've suddenly had some issues with that today so I tried updating your integration and it does seem to be picking up the smart meter. However, there's still no usage data

@robotfishe what endpoint were you calling and how far back were you requesting the data? Beyond the last 24 hour period that this integration provides? Can you give an example of the call (with period filters), response and when you called the endpoint

Another complication is that I now have an export meter set up with Octopus, and your integration is seeing it and correctly identifying the tariff as SEG, but it's not showing it as an export meter

I have been struggling to determine this consistently and OE have been very little help in their forums. I use the presence of smartExportMeter being present to determine if the meter is an export meter but this does not seem to be sufficient for some people. If you're able to make the following graphql queries it might help point me in the right direction

# Get token for next statement
mutation {
  obtainKrakenToken(input: { APIKey: "" }) {
    token
  }
}
# Get account information. Please paste the results in this ticket with identifiable information replaced in a way that I can still see related data
query {
  account(accountNumber: "") {
    electricityAgreements {
      meterPoint {
        mpan
        meters {
          id
          serialNumber
          meterType,
          smartExportElectricityMeter {
            id
          }
          exportMeters {
            edges {
              node {
                id
                serialNumber
                activeFrom
                activeTo
              }
            }
          }
        }
      }
    }
  }
}
robotfishe commented 1 year ago

@robotfishe what endpoint were you calling and how far back were you requesting the data? Beyond the last 24 hour period that this integration provides? Can you give an example of the call (with period filters), response and when you called the endpoint

@BottlecapDave I actually got my REST call working again by just increasing the timeout to 2 minutes - did this after trying a test call in Postman and noticing it took over a minute for data to come back. I call for the previous full day, so today it would be:

https://api.octopus.energy/v1/electricity-meter-points/****/meters/****/consumption?period_from=2023-07-20T00:00&period_to=2023-07-20T23:59

I tried to run the graphql query for you but couldn't get it to work - got some "invalid" responses and then an unauthorized. I'm not experienced with graphql at all so probably got a bracket out of place somewhere or something.

BottlecapDave commented 1 year ago

Taking over a minute to respond sounds way too long. Sounds like you might need to contact OE, but that is probably the culprit to why you can't get your data.

For the graphql queries. I find it easiest to use the interface at https://api.octopus.energy/v1/graphql/.

For your second request, you need to click in headers at the bottom and paste the following

{
  "Authorization": "MY-TOKEN-FROM-FIRST-REQUEST"
}