briancmpbll / home_assistant_custom_envoy

177 stars 77 forks source link

lifetime and daily production incorrect #134

Open kevincw01 opened 1 year ago

kevincw01 commented 1 year ago

enlighten website for lifetime shows 9.1mwh. ha integration shows 699kwh. envoy iq gateway (non meter). My other envoy legacy standard-s has the correct values. Also today's energy production on website = 0.7kwh and ha integration shows 0. 7 day production on website shows 106kwh, ha integration shows 0.

kevincw01 commented 1 year ago

debug data. auth token removed. First report is the legacy envoy which has correct status (192.168.0.233) and 2nd one (0.59) is the newer iq7 envoy that has incorrect data.

2023-08-12 10:58:49.246 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Using Model: P (HTTP, Metering enabled: False, Get Inverters: True)
2023-08-12 10:58:49.247 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] HTTP GET Attempt #1: http://192.168.0.233/api/v1/production: False: Header:None
2023-08-12 10:58:49.268 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Fetched from http://192.168.0.233/api/v1/production: <Response [200 OK]>: {
  "wattHoursToday": 5019,
  "wattHoursSevenDays": 242675,
  "wattHoursLifetime": 72142975,
  "wattsNow": 3127
}

2023-08-12 10:58:49.269 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] HTTP GET Attempt #1: http://192.168.0.233/api/v1/production/inverters: False: Header:None
2023-08-12 10:58:49.303 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Fetched from http://192.168.0.233/api/v1/production/inverters: <Response [200 OK]>: [
  {
    "serialNumber": "121552017442",
    "lastReportDate": 1691862593,
    "devType": 1,
    "lastReportWatts": 158,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121552011631",
    "lastReportDate": 1691862600,
    "devType": 1,
    "lastReportWatts": 157,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121552011632",
    "lastReportDate": 1691862591,
    "devType": 1,
    "lastReportWatts": 156,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121552015335",
    "lastReportDate": 1691862596,
    "devType": 1,
    "lastReportWatts": 162,
    "maxReportWatts": 251
  },
  {
    "serialNumber": "121552011616",
    "lastReportDate": 1691862600,
    "devType": 1,
    "lastReportWatts": 154,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121552011855",
    "lastReportDate": 1691862610,
    "devType": 1,
    "lastReportWatts": 159,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121552016747",
    "lastReportDate": 1691862607,
    "devType": 1,
    "lastReportWatts": 158,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121647026094",
    "lastReportDate": 1691862611,
    "devType": 1,
    "lastReportWatts": 148,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121647026201",
    "lastReportDate": 1691862614,
    "devType": 1,
    "lastReportWatts": 152,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121647027181",
    "lastReportDate": 1691862613,
    "devType": 1,
    "lastReportWatts": 146,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121647027018",
    "lastReportDate": 1691862610,
    "devType": 1,
    "lastReportWatts": 151,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121552016748",
    "lastReportDate": 1691862606,
    "devType": 1,
    "lastReportWatts": 154,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121552011857",
    "lastReportDate": 1691862591,
    "devType": 1,
    "lastReportWatts": 158,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121552018855",
    "lastReportDate": 1691862596,
    "devType": 1,
    "lastReportWatts": 159,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121552016755",
    "lastReportDate": 1691862602,
    "devType": 1,
    "lastReportWatts": 158,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121552015365",
    "lastReportDate": 1691862603,
    "devType": 1,
    "lastReportWatts": 160,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121552011646",
    "lastReportDate": 1691862609,
    "devType": 1,
    "lastReportWatts": 157,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121552019971",
    "lastReportDate": 1691862596,
    "devType": 1,
    "lastReportWatts": 158,
    "maxReportWatts": 250
  },
  {
    "serialNumber": "121552018867",
    "lastReportDate": 1691862599,
    "devType": 1,
    "lastReportWatts": 163,
    "maxReportWatts": 251
  },
  {
    "serialNumber": "121552015996",
    "lastReportDate": 1691862604,
    "devType": 1,
    "lastReportWatts": 159,
    "maxReportWatts": 251
  }
]

2023-08-12 10:58:49.306 DEBUG (MainThread) [custom_components.enphase_envoy] Retrieved data from API: {'production': 3127, 'daily_production': 5019, 'seven_days_production': 242675, 'lifetime_production': 72142975, 'consumption': 'Consumption data not available for your Envoy device.', 'daily_consumption': 'Consumption data not available for your Envoy device.', 'seven_days_consumption': 'Consumption data not available for your Envoy device.', 'lifetime_consumption': 'Consumption data not available for your Envoy device.', 'inverters_production': {'121552017442': [158, '2023-08-12 10:49:53'], '121552011631': [157, '2023-08-12 10:50:00'], '121552011632': [156, '2023-08-12 10:49:51'], '121552015335': [162, '2023-08-12 10:49:56'], '121552011616': [154, '2023-08-12 10:50:00'], '121552011855': [159, '2023-08-12 10:50:10'], '121552016747': [158, '2023-08-12 10:50:07'], '121647026094': [148, '2023-08-12 10:50:11'], '121647026201': [152, '2023-08-12 10:50:14'], '121647027181': [146, '2023-08-12 10:50:13'], '121647027018': [151, '2023-08-12 10:50:10'], '121552016748': [154, '2023-08-12 10:50:06'], '121552011857': [158, '2023-08-12 10:49:51'], '121552018855': [159, '2023-08-12 10:49:56'], '121552016755': [158, '2023-08-12 10:50:02'], '121552015365': [160, '2023-08-12 10:50:03'], '121552011646': [157, '2023-08-12 10:50:09'], '121552019971': [158, '2023-08-12 10:49:56'], '121552018867': [163, '2023-08-12 10:49:59'], '121552015996': [159, '2023-08-12 10:50:04']}, 'production_l1': None, 'daily_production_l1': None, 'lifetime_production_l1': None, 'production_l2': None, 'daily_production_l2': None, 'lifetime_production_l2': None, 'production_l3': None, 'daily_production_l3': None, 'lifetime_production_l3': None, 'consumption_l1': None, 'daily_consumption_l1': None, 'lifetime_consumption_l1': None, 'consumption_l2': None, 'daily_consumption_l2': None, 'lifetime_consumption_l2': None, 'consumption_l3': None, 'daily_consumption_l3': None, 'lifetime_consumption_l3': None, 'grid_status': None}
2023-08-12 10:58:49.306 DEBUG (MainThread) [custom_components.enphase_envoy] Finished fetching envoy Envoy 121612010809 data in 0.060 seconds (success: True)

newer iq7 envoy (black) that has incorrect data:

2023-08-12 10:59:12.181 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Checking Token value: <snip>
2023-08-12 10:59:12.181 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Token is populated: <snip>
2023-08-12 10:59:12.181 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Token expires at: 2024-08-11 08:36:10
2023-08-12 10:59:12.184 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Using Model: PC (HTTPs, Metering enabled: False, Get Inverters: True)
2023-08-12 10:59:12.184 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] HTTP GET Attempt #1: https://192.168.0.59/production.json?details=1: True: Header:{'Authorization': 'Bearer <snip>'}
2023-08-12 10:59:12.757 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Fetched from https://192.168.0.59/production.json?details=1: <Response [200 OK]>: {"production":[{"type":"inverters","activeCount":9,"readingTime":1691863201,"wNow":3123,"whLifetime":703588},{"type":"eim","activeCount":0,"measurementType":"production","readingTime":1691863217,"wNow":3794.892,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":31.203,"rmsVoltage":244.962,"reactPwr":241.865,"apprntPwr":3821.13,"pwrFactor":0.99,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0,"lines":[{"wNow":1886.225,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":15.597,"rmsVoltage":121.777,"reactPwr":116.832,"apprntPwr":1899.251,"pwrFactor":0.99,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0},{"wNow":1908.667,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":15.606,"rmsVoltage":123.185,"reactPwr":125.032,"apprntPwr":1921.879,"pwrFactor":0.99,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0}]}],"consumption":[{"type":"eim","activeCount":0,"measurementType":"total-consumption","readingTime":1691863217,"wNow":3794.892,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":31.472,"rmsVoltage":244.842,"reactPwr":-241.865,"apprntPwr":7705.678,"pwrFactor":0.49,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0,"lines":[{"wNow":1886.225,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":15.732,"rmsVoltage":121.732,"reactPwr":-116.832,"apprntPwr":1915.124,"pwrFactor":0.98,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0},{"wNow":1908.667,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":15.74,"rmsVoltage":123.11,"reactPwr":-125.032,"apprntPwr":1937.72,"pwrFactor":0.99,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0}]},{"type":"eim","activeCount":0,"measurementType":"net-consumption","readingTime":1691863217,"wNow":0.0,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.269,"rmsVoltage":244.722,"reactPwr":-0.0,"apprntPwr":32.943,"pwrFactor":0.0,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0,"lines":[{"wNow":0.0,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.135,"rmsVoltage":121.687,"reactPwr":-0.0,"apprntPwr":16.438,"pwrFactor":0.0,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0},{"wNow":0.0,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.134,"rmsVoltage":123.035,"reactPwr":0.0,"apprntPwr":16.505,"pwrFactor":0.0,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0}]}],"storage":[{"type":"acb","activeCount":0,"readingTime":0,"wNow":0,"whNow":0,"state":"idle"}]}
2023-08-12 10:59:12.759 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] HTTP GET Attempt #1: https://192.168.0.59/ivp/ensemble/inventory: True: Header:{'Authorization': 'Bearer <snip>'}
2023-08-12 10:59:13.011 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Fetched from https://192.168.0.59/ivp/ensemble/inventory: <Response [200 OK]>: []
2023-08-12 10:59:13.014 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] HTTP GET Attempt #1: https://192.168.0.59/home.json: True: Header:{'Authorization': 'Bearer <snip>'}
2023-08-12 10:59:16.220 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Fetched from https://192.168.0.59/home.json: <Response [200 OK]>: {"software_build_epoch":1687427017,"is_nonvoy":false,"db_size":2273280,"db_percent_full":"  0.60","timezone":"US/Pacific","current_date":"08/12/2023","current_time":"11:00","network":{"web_comm":true,"ever_reported_to_enlighten":true,"last_enlighten_report_time":1691862955,"primary_interface":"wlan0","interfaces":[{"type":"ethernet","interface":"eth0","mac":"00:1D:C0:B3:D6:6A","dhcp":true,"ip":"169.254.120.1","signal_strength":0,"signal_strength_max":1,"carrier":false},{"signal_strength":3,"signal_strength_max":5,"type":"wifi","interface":"wlan0","mac":"20:D7:78:C5:28:F6","dhcp":true,"ip":"192.168.0.59","carrier":true,"supported":true,"present":true,"configured":true,"status":"connected"}]},"tariff":"single_rate","comm":{"num":9,"level":5,"pcu":{"num":9,"level":5},"acb":{"num":0,"level":0},"nsrb":{"num":0,"level":0},"esub":{"num":0,"level":0},"encharge":[{"num":0,"level":0,"level_24g":0,"level_subg":0}]},"alerts":[{"msg_key":"lwui.home.warnings.cross_domain_traffic"}],"update_status":"satisfied","wireless_connection":[{"signal_strength":0,"signal_strength_max":0,"type":"zigbee","connected":false},{"signal_strength":0,"signal_strength_max":0,"type":"subghz","connected":false}],"enpower":{"connected":false,"grid_status":"closed"}}
2023-08-12 10:59:16.222 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] HTTP GET Attempt #1: https://192.168.0.59/api/v1/production: True: Header:{'Authorization': 'Bearer <snip>'}
2023-08-12 10:59:16.477 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Fetched from https://192.168.0.59/api/v1/production: <Response [200 OK]>: {
  "wattHoursToday": 0,
  "wattHoursSevenDays": 0,
  "wattHoursLifetime": 0,
  "wattsNow": 0
}

2023-08-12 10:59:16.480 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] HTTP GET Attempt #1: https://192.168.0.59/api/v1/production/inverters: True: Header:{'Authorization': 'Bearer <snip>'}
2023-08-12 10:59:16.782 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Fetched from https://192.168.0.59/api/v1/production/inverters: <Response [200 OK]>: [
  {
    "serialNumber": "202138028996",
    "lastReportDate": 1691863049,
    "devType": 1,
    "lastReportWatts": 342,
    "maxReportWatts": 367
  },
  {
    "serialNumber": "202138037045",
    "lastReportDate": 1691863170,
    "devType": 1,
    "lastReportWatts": 352,
    "maxReportWatts": 367
  },
  {
    "serialNumber": "202138037519",
    "lastReportDate": 1691863201,
    "devType": 1,
    "lastReportWatts": 345,
    "maxReportWatts": 367
  },
  {
    "serialNumber": "202138034606",
    "lastReportDate": 1691862388,
    "devType": 1,
    "lastReportWatts": 349,
    "maxReportWatts": 367
  },
  {
    "serialNumber": "202138037131",
    "lastReportDate": 1691862328,
    "devType": 1,
    "lastReportWatts": 344,
    "maxReportWatts": 367
  },
  {
    "serialNumber": "202138029315",
    "lastReportDate": 1691862419,
    "devType": 1,
    "lastReportWatts": 347,
    "maxReportWatts": 367
  },
  {
    "serialNumber": "202138037422",
    "lastReportDate": 1691862359,
    "devType": 1,
    "lastReportWatts": 340,
    "maxReportWatts": 367
  },
  {
    "serialNumber": "202138029630",
    "lastReportDate": 1691862539,
    "devType": 1,
    "lastReportWatts": 354,
    "maxReportWatts": 367
  },
  {
    "serialNumber": "202138033578",
    "lastReportDate": 1691862451,
    "devType": 1,
    "lastReportWatts": 350,
    "maxReportWatts": 367
  }
]

2023-08-12 10:59:16.793 DEBUG (MainThread) [custom_components.enphase_envoy] Retrieved data from API: {'production': 3123, 'daily_production': 0, 'seven_days_production': 0, 'lifetime_production': 703588, 'consumption': 3794, 'daily_consumption': 0, 'seven_days_consumption': 0, 'lifetime_consumption': 0, 'inverters_production': {'202138028996': [342, '2023-08-12 10:57:29'], '202138037045': [352, '2023-08-12 10:59:30'], '202138037519': [345, '2023-08-12 11:00:01'], '202138034606': [349, '2023-08-12 10:46:28'], '202138037131': [344, '2023-08-12 10:45:28'], '202138029315': [347, '2023-08-12 10:46:59'], '202138037422': [340, '2023-08-12 10:45:59'], '202138029630': [354, '2023-08-12 10:48:59'], '202138033578': [350, '2023-08-12 10:47:31']}, 'production_l1': None, 'daily_production_l1': None, 'lifetime_production_l1': None, 'production_l2': None, 'daily_production_l2': None, 'lifetime_production_l2': None, 'production_l3': None, 'daily_production_l3': None, 'lifetime_production_l3': None, 'consumption_l1': 1886, 'daily_consumption_l1': 0, 'lifetime_consumption_l1': 0, 'consumption_l2': 1908, 'daily_consumption_l2': 0, 'lifetime_consumption_l2': 0, 'consumption_l3': None, 'daily_consumption_l3': None, 'lifetime_consumption_l3': None, 'grid_status': 'closed'}
2023-08-12 10:59:16.793 DEBUG (MainThread) [custom_components.enphase_envoy] Finished fetching envoy Envoy 202202115804 data in 4.613 seconds (success: True)
kevincw01 commented 1 year ago
solar
catsmanac commented 1 year ago

Hi @kevincw01, looking at the debug log I see you have an Gateway/Envoy metered, but no meters installed/configured. (Which is something different as an Gateway/ENVOYS-S Standard that can not connect meters). The current firmware in this specific case reportedly resets lifetime production to zero when reaching ~1.2Mw. See this closed issue for that report. Furthermore this firmware only reports currentWatts (wNow) and Lifetime Wh (whLifetime), no day or last 7 days energy produced.

Can't make it any better, it's what the Gateway reports in this case and that reset is nasty. But I think the HA energy dashboard can deal with a resetting measurement. Or add a utility meter to HA based on this measurement and then in the entities window corrects it's value to what enphase web-site is reporting.

Below segment comes from your debug log with the numbers reported by the Gateway

Fetched from https://192.168.0.59/production.json?details=1: <Response [200 OK]>:
{
    "production": [
        {
            "type": "inverters",
            "activeCount": 9,
            "readingTime": 1691863201,
            "wNow": 3123,
            "whLifetime": 703588
        },