FHEM Forum

FHEM => Anfängerfragen => Thema gestartet von: petitpunch am 07 Juli 2022, 12:58:44

Titel: HTTPMOD - JSON - ENPHASE
Beitrag von: petitpunch am 07 Juli 2022, 12:58:44
Hello,
i'm using Fhem since a while to control my house equipment (ZWAVE+KNX+HUE+ALEXA).

Today, i would like to parse data of my enphase solar panels. I can access to a json page with this data:


   {
   "production":[
      {
         "type":"inverters",
         "activeCount":7,
         "readingTime":1657190710,
         "wNow":544,
         "whLifetime":600913
      },
      {
         "type":"eim",
         "activeCount":0,
"measurementType":"production",
         "readingTime":1657190870,
         "wNow":-247.697,
         "whLifetime":0.0,
         "varhLeadLifetime":0.0,
         "varhLagLifetime":0.0,
         "vahLifetime":0.0,
         "rmsCurrent":1.993,
         "rmsVoltage":233.433,
         "reactPwr":237.304,
         "apprntPwr":382.255,
         "pwrFactor":-0.64,
         "whToday":0.0,
         "whLastSevenDays":0.0,
         "vahToday":0.0,
         "varhLeadToday":0.0,
         "varhLagToday":0.0,
         "lines":[
            {
               "wNow":-248.028,
               "whLifetime":0.0,
               "varhLeadLifetime":0.0,
               "varhLagLifetime":0.0,
               "vahLifetime":0.0,
               "rmsCurrent":1.647,
               "rmsVoltage":232.066,
               "reactPwr":237.304,
               "apprntPwr":381.782,
      ../..


(wNow is more than one time in this json but only the first is usefull)

I have used this code to retrieve the value of "wNow"   (production in realtime).


define ENPHASE HTTPMOD http://192.168.1.161/production.json?details=1 60\

setuuid ENPHASE 62c570b4-f33f-266d-54cd-8d2c41346a820026
attr ENPHASE userattr get01JSON get01Regex getData requestHeader stateFormat
attr ENPHASE enableCookies 1
attr ENPHASE icon measure_photovoltaic_inst
attr ENPHASE reading01JSON production
attr ENPHASE requestHeader1 Content-Type: application/json
attr ENPHASE requestHeader2 Accept: */*
attr ENPHASE room ENERGIE
attr ENPHASE stateFormat production-4 Watts/h



it is working but not clean at all.

this code read too much data :


production-1
production-10
production-11
production-12
production-13
production-14
../..
production-4
production-41
produ ../..


I could not log this to do a graph, this too heavy to storage and useless.

Could you help me to select only  production-4 ?  (wNow).

Other question...   could you help me to calculate and display in stateFormat the wNow in Kwh ?  (the value is displayed in watts).

Thank you

Titel: Antw:HTTPMOD - JSON - ENPHASE
Beitrag von: yersinia am 07 Juli 2022, 13:35:55
This is not a reply with a HTTPMOD solution - you might want to consider using JsonMod (https://fhem.de/commandref.html#JsonMod) instead as the source is json format.

Below a raw proposal
defmod enphaseJM JsonMod http://192.168.1.161/production.json?details=1
attr enphaseJM interval 0 */2 * * *
attr enphaseJM readingList single(jsonPath('$.production.[3].wNow'), 'wNow', '-?-');;
attr enphaseJM stateFormat { my $ret ="";;\
  $ret .= sprintf("%.3f", (ReadingsNum($name,"wNow",0) / 1000));;\
  $ret .= " kWh";;\
  return $ret;;\
}
attr enphaseJM webCmd reread
attr enphaseJM room ENERGIE

It should generate one reading wNow of the fourth production array element (counting starts at 0).

Interval is every second minute (https://crontab.guru/#*/2_*_*_*_*):
attr enphaseJM interval */2 * * * *

stateFormat devides wNow by 1000 and shortens to two decimal places:
  $ret .= sprintf("%.3f", (ReadingsNum($name,"wNow",0) / 1000));;\

JsonMod does not have that many features as HTTPMOD so it can be not the proper solution for your case. But imho it is worth a try.

And, btw, next time please use code tags when pasting code - the #-button above the text input field.
Titel: Antw:HTTPMOD - JSON - ENPHASE
Beitrag von: petitpunch am 07 Juli 2022, 23:20:52
Hello Yersinia,

thank you for your solution.
i have tried it but there is a problem with it.

here is the msg:


API_LAST_MSG
invalid server response
API_LAST_RES
1657228705.22904
DEF
http://192.168.1.161/production.json?details=1
FUUID
62c74d3b-f33f-266d-7bb4-747177de0c76f979
NAME
enphaseJM
NEXT
2022-07-08 02:00:00
NR
917
SOURCE
http://192.168.1.161/production.json?details=1 (400)
STATE
???
SVN
24783 2021-07-21 22:37:12 UTC
TYPE
JsonMod
Titel: Antw:HTTPMOD - JSON - ENPHASE
Beitrag von: yersinia am 08 Juli 2022, 08:03:22
It seems that the request is not yet correct, returned status code is 400 (https://en.wikipedia.org/wiki/Http_return_codes#4xx_client_errors):
http://192.168.1.161/production.json?details=1 (400)
You may need to add httpheaders:
attr enphaseJM httpHeader Content-Type: application/json

defmod enphaseJM JsonMod http://192.168.1.161/production.json?details=1
attr enphaseJM interval 0 */2 * * *
attr enphaseJM readingList single(jsonPath('$.production.[3].wNow'), 'wNow', '-?-');;
attr enphaseJM stateFormat { my $ret ="";;\
  $ret .= sprintf("%.3f", (ReadingsNum($name,"wNow",0) / 1000));;\
  $ret .= " kWh";;\
  return $ret;;\
}
attr enphaseJM webCmd reread
attr enphaseJM httpHeader Content-Type: application/json
attr enphaseJM room ENERGIE


Do you need to provide credentials?
Can you reach the Json source from a browser as well?
Titel: Antw:HTTPMOD - JSON - ENPHASE
Beitrag von: petitpunch am 08 Juli 2022, 13:09:41


Hi,  better but the value of wNow is incorrect.
I think this is the result of readingTime perhaps: 

readingTime":1657278359,"wNow":1665,"


here is the result displayed:


API_LAST_MSG 200
API_LAST_RES 1657278336.83895
DEF http://192.168.1.161/production.json?details=1
FUUID 62c80f53-f33f-266d-d9ed-470ec85b9eae22fc
NAME enphaseJM
NEXT 2022-07-08 14:00:00
NR 919
SOURCE http://192.168.1.161/production.json?details=1 (200)
STATE 0.000 kWh
SVN 24783 2021-07-21 22:37:12 UTC
TYPE JsonMod
eventCount 23


i give you the full json page :


{"production":[{"type":"inverters","activeCount":7,"readingTime":1657278359,"wNow":1665,"whLifetime":615125},{"type":"eim","activeCount":0,"measurementType":"production","readingTime":1657278454,"wNow":-889.221,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":7.348,"rmsVoltage":232.416,"reactPwr":1354.887,"apprntPwr":1618.507,"pwrFactor":-0.55,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0,"lines":[{"wNow":-889.584,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":7.001,"rmsVoltage":231.049,"reactPwr":1354.887,"apprntPwr":1618.033,"pwrFactor":-0.55,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0},{"wNow":0.363,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.347,"rmsVoltage":1.367,"reactPwr":0.0,"apprntPwr":0.474,"pwrFactor":0.0,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0}]}],"consumption":[{"type":"eim","activeCount":0,"measurementType":"total-consumption","readingTime":1657278454,"wNow":-2654.253,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":-3.621,"rmsVoltage":238.501,"reactPwr":-3088.573,"apprntPwr":-863.504,"pwrFactor":-1.0,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0,"lines":[{"wNow":-2653.611,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":-3.809,"rmsVoltage":231.157,"reactPwr":-3088.573,"apprntPwr":-880.564,"pwrFactor":-1.0,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0},{"wNow":0.363,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.347,"rmsVoltage":3.682,"reactPwr":-0.0,"apprntPwr":1.277,"pwrFactor":0.28,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0},{"wNow":-1.004,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":-0.158,"rmsVoltage":9.344,"reactPwr":0.0,"apprntPwr":-1.477,"pwrFactor":-1.0,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0}]},{"type":"eim","activeCount":0,"measurementType":"net-consumption","readingTime":1657278454,"wNow":-1765.032,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":10.968,"rmsVoltage":244.586,"reactPwr":-1733.686,"apprntPwr":2496.852,"pwrFactor":-0.7,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0,"lines":[{"wNow":-1764.028,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":10.81,"rmsVoltage":231.265,"reactPwr":-1733.686,"apprntPwr":2495.701,"pwrFactor":-0.7,"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.0,"rmsVoltage":5.997,"reactPwr":0.0,"apprntPwr":0.0,"pwrFactor":-1.0,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0},{"wNow":-1.004,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.158,"rmsVoltage":7.324,"reactPwr":0.0,"apprntPwr":1.151,"pwrFactor":-1.0,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0}]}],"storage":[{"type":"acb","activeCount":0,"readingTime":0,"wNow":0,"whNow":0,"state":"idle"}]}


thank you for your help.
Titel: Antw:HTTPMOD - JSON - ENPHASE
Beitrag von: yersinia am 08 Juli 2022, 13:23:57
When you try to set readingsList with complete(); it will show everything - this helps at the beginning:
attr enphaseJM readingList complete();;
Then you are able to narrow it down to the values you are interested in; here list of found readings based on Json data you provided:
READINGS:
     2022-07-08 13:13:51   consumption.0.activeCount 0
     2022-07-08 13:13:51   consumption.0.apprntPwr -863.504
     2022-07-08 13:13:51   consumption.0.lines.0.apprntPwr -880.564
     2022-07-08 13:13:51   consumption.0.lines.0.pwrFactor -1
     2022-07-08 13:13:51   consumption.0.lines.0.reactPwr -3088.573
     2022-07-08 13:13:51   consumption.0.lines.0.rmsCurrent -3.809
     2022-07-08 13:13:51   consumption.0.lines.0.rmsVoltage 231.157
     2022-07-08 13:13:51   consumption.0.lines.0.vahLifetime 0
     2022-07-08 13:13:51   consumption.0.lines.0.vahToday 0
     2022-07-08 13:13:51   consumption.0.lines.0.varhLagLifetime 0
     2022-07-08 13:13:51   consumption.0.lines.0.varhLagToday 0
     2022-07-08 13:13:51   consumption.0.lines.0.varhLeadLifetime 0
     2022-07-08 13:13:51   consumption.0.lines.0.varhLeadToday 0
     2022-07-08 13:13:51   consumption.0.lines.0.wNow -2653.611
     2022-07-08 13:13:51   consumption.0.lines.0.whLastSevenDays 0
     2022-07-08 13:13:51   consumption.0.lines.0.whLifetime 0
     2022-07-08 13:13:51   consumption.0.lines.0.whToday 0
     2022-07-08 13:13:51   consumption.0.lines.1.apprntPwr 1.277
     2022-07-08 13:13:51   consumption.0.lines.1.pwrFactor 0.28
     2022-07-08 13:13:51   consumption.0.lines.1.reactPwr 0
     2022-07-08 13:13:51   consumption.0.lines.1.rmsCurrent 0.347
     2022-07-08 13:13:51   consumption.0.lines.1.rmsVoltage 3.682
     2022-07-08 13:13:51   consumption.0.lines.1.vahLifetime 0
     2022-07-08 13:13:51   consumption.0.lines.1.vahToday 0
     2022-07-08 13:13:51   consumption.0.lines.1.varhLagLifetime 0
     2022-07-08 13:13:51   consumption.0.lines.1.varhLagToday 0
     2022-07-08 13:13:51   consumption.0.lines.1.varhLeadLifetime 0
     2022-07-08 13:13:51   consumption.0.lines.1.varhLeadToday 0
     2022-07-08 13:13:51   consumption.0.lines.1.wNow 0.363
     2022-07-08 13:13:51   consumption.0.lines.1.whLastSevenDays 0
     2022-07-08 13:13:51   consumption.0.lines.1.whLifetime 0
     2022-07-08 13:13:51   consumption.0.lines.1.whToday 0
     2022-07-08 13:13:51   consumption.0.lines.2.apprntPwr -1.477
     2022-07-08 13:13:51   consumption.0.lines.2.pwrFactor -1
     2022-07-08 13:13:51   consumption.0.lines.2.reactPwr 0
     2022-07-08 13:13:51   consumption.0.lines.2.rmsCurrent -0.158
     2022-07-08 13:13:51   consumption.0.lines.2.rmsVoltage 9.344
     2022-07-08 13:13:51   consumption.0.lines.2.vahLifetime 0
     2022-07-08 13:13:51   consumption.0.lines.2.vahToday 0
     2022-07-08 13:13:51   consumption.0.lines.2.varhLagLifetime 0
     2022-07-08 13:13:51   consumption.0.lines.2.varhLagToday 0
     2022-07-08 13:13:51   consumption.0.lines.2.varhLeadLifetime 0
     2022-07-08 13:13:51   consumption.0.lines.2.varhLeadToday 0
     2022-07-08 13:13:51   consumption.0.lines.2.wNow -1.004
     2022-07-08 13:13:51   consumption.0.lines.2.whLastSevenDays 0
     2022-07-08 13:13:51   consumption.0.lines.2.whLifetime 0
     2022-07-08 13:13:51   consumption.0.lines.2.whToday 0
     2022-07-08 13:13:51   consumption.0.measurementType total-consumption
     2022-07-08 13:13:51   consumption.0.pwrFactor -1
     2022-07-08 13:13:51   consumption.0.reactPwr -3088.573
     2022-07-08 13:13:51   consumption.0.readingTime 1657278454
     2022-07-08 13:13:51   consumption.0.rmsCurrent -3.621
     2022-07-08 13:13:51   consumption.0.rmsVoltage 238.501
     2022-07-08 13:13:51   consumption.0.type eim
     2022-07-08 13:13:51   consumption.0.vahLifetime 0
     2022-07-08 13:13:51   consumption.0.vahToday 0
     2022-07-08 13:13:51   consumption.0.varhLagLifetime 0
     2022-07-08 13:13:51   consumption.0.varhLagToday 0
     2022-07-08 13:13:51   consumption.0.varhLeadLifetime 0
     2022-07-08 13:13:51   consumption.0.varhLeadToday 0
     2022-07-08 13:13:51   consumption.0.wNow -2654.253
     2022-07-08 13:13:51   consumption.0.whLastSevenDays 0
     2022-07-08 13:13:51   consumption.0.whLifetime 0
     2022-07-08 13:13:51   consumption.0.whToday 0
     2022-07-08 13:13:51   consumption.1.activeCount 0
     2022-07-08 13:13:51   consumption.1.apprntPwr 2496.852
     2022-07-08 13:13:51   consumption.1.lines.0.apprntPwr 2495.701
     2022-07-08 13:13:51   consumption.1.lines.0.pwrFactor -0.7
     2022-07-08 13:13:51   consumption.1.lines.0.reactPwr -1733.686
     2022-07-08 13:13:51   consumption.1.lines.0.rmsCurrent 10.81
     2022-07-08 13:13:51   consumption.1.lines.0.rmsVoltage 231.265
     2022-07-08 13:13:51   consumption.1.lines.0.vahLifetime 0
     2022-07-08 13:13:51   consumption.1.lines.0.vahToday 0
     2022-07-08 13:13:51   consumption.1.lines.0.varhLagLifetime 0
     2022-07-08 13:13:51   consumption.1.lines.0.varhLagToday 0
     2022-07-08 13:13:51   consumption.1.lines.0.varhLeadLifetime 0
     2022-07-08 13:13:51   consumption.1.lines.0.varhLeadToday 0
     2022-07-08 13:13:51   consumption.1.lines.0.wNow -1764.028
     2022-07-08 13:13:51   consumption.1.lines.0.whLastSevenDays 0
     2022-07-08 13:13:51   consumption.1.lines.0.whLifetime 0
     2022-07-08 13:13:51   consumption.1.lines.0.whToday 0
     2022-07-08 13:13:51   consumption.1.lines.1.apprntPwr 0
     2022-07-08 13:13:51   consumption.1.lines.1.pwrFactor -1
     2022-07-08 13:13:51   consumption.1.lines.1.reactPwr 0
     2022-07-08 13:13:51   consumption.1.lines.1.rmsCurrent 0
     2022-07-08 13:13:51   consumption.1.lines.1.rmsVoltage 5.997
     2022-07-08 13:13:51   consumption.1.lines.1.vahLifetime 0
     2022-07-08 13:13:51   consumption.1.lines.1.vahToday 0
     2022-07-08 13:13:51   consumption.1.lines.1.varhLagLifetime 0
     2022-07-08 13:13:51   consumption.1.lines.1.varhLagToday 0
     2022-07-08 13:13:51   consumption.1.lines.1.varhLeadLifetime 0
     2022-07-08 13:13:51   consumption.1.lines.1.varhLeadToday 0
     2022-07-08 13:13:51   consumption.1.lines.1.wNow 0
     2022-07-08 13:13:51   consumption.1.lines.1.whLastSevenDays 0
     2022-07-08 13:13:51   consumption.1.lines.1.whLifetime 0
     2022-07-08 13:13:51   consumption.1.lines.1.whToday 0
     2022-07-08 13:13:51   consumption.1.lines.2.apprntPwr 1.151
     2022-07-08 13:13:51   consumption.1.lines.2.pwrFactor -1
     2022-07-08 13:13:51   consumption.1.lines.2.reactPwr 0
     2022-07-08 13:13:51   consumption.1.lines.2.rmsCurrent 0.158
     2022-07-08 13:13:51   consumption.1.lines.2.rmsVoltage 7.324
     2022-07-08 13:13:51   consumption.1.lines.2.vahLifetime 0
     2022-07-08 13:13:51   consumption.1.lines.2.vahToday 0
     2022-07-08 13:13:51   consumption.1.lines.2.varhLagLifetime 0
     2022-07-08 13:13:51   consumption.1.lines.2.varhLagToday 0
     2022-07-08 13:13:51   consumption.1.lines.2.varhLeadLifetime 0
     2022-07-08 13:13:51   consumption.1.lines.2.varhLeadToday 0
     2022-07-08 13:13:51   consumption.1.lines.2.wNow -1.004
     2022-07-08 13:13:51   consumption.1.lines.2.whLastSevenDays 0
     2022-07-08 13:13:51   consumption.1.lines.2.whLifetime 0
     2022-07-08 13:13:51   consumption.1.lines.2.whToday 0
     2022-07-08 13:13:51   consumption.1.measurementType net-consumption
     2022-07-08 13:13:51   consumption.1.pwrFactor -0.7
     2022-07-08 13:13:51   consumption.1.reactPwr -1733.686
     2022-07-08 13:13:51   consumption.1.readingTime 1657278454
     2022-07-08 13:13:51   consumption.1.rmsCurrent 10.968
     2022-07-08 13:13:51   consumption.1.rmsVoltage 244.586
     2022-07-08 13:13:51   consumption.1.type eim
     2022-07-08 13:13:51   consumption.1.vahLifetime 0
     2022-07-08 13:13:51   consumption.1.vahToday 0
     2022-07-08 13:13:51   consumption.1.varhLagLifetime 0
     2022-07-08 13:13:51   consumption.1.varhLagToday 0
     2022-07-08 13:13:51   consumption.1.varhLeadLifetime 0
     2022-07-08 13:13:51   consumption.1.varhLeadToday 0
     2022-07-08 13:13:51   consumption.1.wNow -1765.032
     2022-07-08 13:13:51   consumption.1.whLastSevenDays 0
     2022-07-08 13:13:51   consumption.1.whLifetime 0
     2022-07-08 13:13:51   consumption.1.whToday 0
     2022-07-08 13:13:51   production.0.activeCount 7
     2022-07-08 13:13:51   production.0.readingTime 1657278359
     2022-07-08 13:13:51   production.0.type inverters
     2022-07-08 13:13:51   production.0.wNow 1665
     2022-07-08 13:13:51   production.0.whLifetime 615125
     2022-07-08 13:13:51   production.1.activeCount 0
     2022-07-08 13:13:51   production.1.apprntPwr 1618.507
     2022-07-08 13:13:51   production.1.lines.0.apprntPwr 1618.033
     2022-07-08 13:13:51   production.1.lines.0.pwrFactor -0.55
     2022-07-08 13:13:51   production.1.lines.0.reactPwr 1354.887
     2022-07-08 13:13:51   production.1.lines.0.rmsCurrent 7.001
     2022-07-08 13:13:51   production.1.lines.0.rmsVoltage 231.049
     2022-07-08 13:13:51   production.1.lines.0.vahLifetime 0
     2022-07-08 13:13:51   production.1.lines.0.vahToday 0
     2022-07-08 13:13:51   production.1.lines.0.varhLagLifetime 0
     2022-07-08 13:13:51   production.1.lines.0.varhLagToday 0
     2022-07-08 13:13:51   production.1.lines.0.varhLeadLifetime 0
     2022-07-08 13:13:51   production.1.lines.0.varhLeadToday 0
     2022-07-08 13:13:51   production.1.lines.0.wNow -889.584
     2022-07-08 13:13:51   production.1.lines.0.whLastSevenDays 0
     2022-07-08 13:13:51   production.1.lines.0.whLifetime 0
     2022-07-08 13:13:51   production.1.lines.0.whToday 0
     2022-07-08 13:13:51   production.1.lines.1.apprntPwr 0.474
     2022-07-08 13:13:51   production.1.lines.1.pwrFactor 0
     2022-07-08 13:13:51   production.1.lines.1.reactPwr 0
     2022-07-08 13:13:51   production.1.lines.1.rmsCurrent 0.347
     2022-07-08 13:13:51   production.1.lines.1.rmsVoltage 1.367
     2022-07-08 13:13:51   production.1.lines.1.vahLifetime 0
     2022-07-08 13:13:51   production.1.lines.1.vahToday 0
     2022-07-08 13:13:51   production.1.lines.1.varhLagLifetime 0
     2022-07-08 13:13:51   production.1.lines.1.varhLagToday 0
     2022-07-08 13:13:51   production.1.lines.1.varhLeadLifetime 0
     2022-07-08 13:13:51   production.1.lines.1.varhLeadToday 0
     2022-07-08 13:13:51   production.1.lines.1.wNow 0.363
     2022-07-08 13:13:51   production.1.lines.1.whLastSevenDays 0
     2022-07-08 13:13:51   production.1.lines.1.whLifetime 0
     2022-07-08 13:13:51   production.1.lines.1.whToday 0
     2022-07-08 13:13:51   production.1.measurementType production
     2022-07-08 13:13:51   production.1.pwrFactor -0.55
     2022-07-08 13:13:51   production.1.reactPwr 1354.887
     2022-07-08 13:13:51   production.1.readingTime 1657278454
     2022-07-08 13:13:51   production.1.rmsCurrent 7.348
     2022-07-08 13:13:51   production.1.rmsVoltage 232.416
     2022-07-08 13:13:51   production.1.type eim
     2022-07-08 13:13:51   production.1.vahLifetime 0
     2022-07-08 13:13:51   production.1.vahToday 0
     2022-07-08 13:13:51   production.1.varhLagLifetime 0
     2022-07-08 13:13:51   production.1.varhLagToday 0
     2022-07-08 13:13:51   production.1.varhLeadLifetime 0
     2022-07-08 13:13:51   production.1.varhLeadToday 0
     2022-07-08 13:13:51   production.1.wNow -889.221
     2022-07-08 13:13:51   production.1.whLastSevenDays 0
     2022-07-08 13:13:51   production.1.whLifetime 0
     2022-07-08 13:13:51   production.1.whToday 0
     2022-07-08 13:13:51   storage.0.activeCount 0
     2022-07-08 13:13:51   storage.0.readingTime 0
     2022-07-08 13:13:51   storage.0.state idle
     2022-07-08 13:13:51   storage.0.type  acb
     2022-07-08 13:13:51   storage.0.wNow  0
     2022-07-08 13:13:51   storage.0.whNow 0


wNow appears four times under production:
2022-07-08 13:13:51   production.0.wNow 1665
2022-07-08 13:13:51   production.1.lines.0.wNow -889.584
2022-07-08 13:13:51   production.1.lines.1.wNow 0.363
2022-07-08 13:13:51   production.1.wNow -889.221

I guess you want the last one? Then you can use the JsonPath for it:
attr enphaseJM readingList single(jsonPath('$.production.[1].wNow'), 'wNow', '-?-');;

Complete Device raw:
defmod enphaseJM JsonMod http://192.168.1.161/production.json?details=1
attr enphaseJM interval 0 */2 * * *
attr enphaseJM readingList single(jsonPath('$.production.[1].wNow'), 'wNow', '-?-');;
attr enphaseJM stateFormat { my $ret ="";;\
  $ret .= sprintf("%.3f", (ReadingsNum($name,"wNow",0) / 1000));;\
  $ret .= " kWh";;\
  return $ret;;\
}
attr enphaseJM webCmd reread
attr enphaseJM httpHeader Content-Type: application/json
attr enphaseJM room ENERGIE
Titel: Antw:HTTPMOD - JSON - ENPHASE
Beitrag von: petitpunch am 08 Juli 2022, 13:35:44
it's working !
great !
many many thanks to you.

it's not easy to me to parse a json like that.

thank you !!
Titel: Antw:HTTPMOD - JSON - ENPHASE
Beitrag von: petitpunch am 10 Februar 2023, 00:07:13
Hello,

since the new firmware (7) of the envoy-s, i can't read the url anymore.
Enphase has added a login/password to an online url with a redirection to my local interface when the login/password is validated.
here is a project on github for home assistant  : https://github.com/jrutski/home_assistant_envoy_d7_fw

is it possible to convert that in fhem ?


Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Christian83 am 11 April 2023, 09:33:46
Hallo,

ich habe ein Perl Modul zum Auslesen des Enphase Gateways gebaut.
Bei Interessen kann ich es gerne zur Verfügung stellen.
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: s00rb am 21 April 2023, 19:13:23
Moin Christian,

ich wäre interessiert an dem Modul.
Aktuell gehe ich den Umweg über das Homekit Plugin "Enphase Envoy" um an die Daten meiner Anlage zu kommen und lasse mir die Daten per mqtt an FHEM schicken.
Leider steige ich durch die Datenflut und die API von enphase nicht wirklich durch.

Gruß Mario
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Christian83 am 24 April 2023, 08:52:37
Hi Mario,

anbei das Modul.
Edit: Altprogramm entfernt.

define <name> ENPHASE <IPAddr> <username>

username ist die mailadresse im Enlighten System.
Mit set <name> password <password> das Passwort für Enlighten hinterlegen.

get <name> LiveData - dann wird das Envoy ausgelesen.
Danach wird bei positiver Erzeugung aller 60 Sekunden sonst aller 300 Sekunden abgefragt. (Kann über Attribut updateinterval geändert werden).

Bei Fragen einfach melden.
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: s00rb am 24 April 2023, 18:52:40
Coole Sache!
Hab vielen Dank! Ich werde testen und berichten.
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Christian83 am 04 Mai 2023, 14:37:54
Bist du schon zum Testen gekommen?

Passt es? Fehlt was?
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: wolfganghabenicht am 23 Mai 2023, 13:05:20
Moin,

habe es eingerichet, aber bei mir toggelt es dauerhaft zwischen 'reading token', getting session id' und 'getting token' hin und her.

Ich habe eine Session-ID zurückbekommen, aber der state toggelt weiterhin
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Christian83 am 23 Mai 2023, 19:10:33
Zitat von: wolfganghabenicht am 23 Mai 2023, 13:05:20Moin,

habe es eingerichet, aber bei mir toggelt es dauerhaft zwischen 'reading token', getting session id' und 'getting token' hin und her.

Ich habe eine Session-ID zurückbekommen, aber der state toggelt weiterhin

Schalt mal verbose auf 5 und schreib das Log.
Dann sehe ich vielleicht was.
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: wolfganghabenicht am 30 Mai 2023, 16:22:27
Moin,

hier das LOG-File

2023.05.30 16:21:04 3: Enphase (GL.SOLAR): ==> url https://enlighten.enphaseenergy.com/entrez-auth-token?serial_num=##### returned: {"message":"{\"timestamp\":1685456463989,\"message\":\"MailAdress is not authorized to generate token for 122222033486\"}"}
2023.05.30 16:21:04 4: Enphase (GL.SOLAR): ==> HTTP/1.1 500 Internal Server Error
Date: Tue, 30 May 2023 14:21:04 GMT
Content-Type: application/json; charset=utf-8
Connection: close
Access-Control-Allow-Methods: POST, PUT, DELETE, GET, OPTIONS
Access-Control-Max-Age: 1728000
Cache-Control: no-cache, no-store
Expires: -1
Pragma: no-cache, no-store
Set-Cookie: locale=de; path=/; expires=Thu, 30 May 2024 14:21:03 GMT; secure; HttpOnly; SameSite=Lax
Status: 500 Internal Server Error
X-Powered-By: Phusion Passenger(R) 6.0.11
X-Request-Id: 4545775cdbc6b556f97d0c5350114fdf
X-Runtime: 0.081191
Strict-Transport-Security: max-age=15724800; includeSubDomains
2023.05.30 16:21:04 4: Enphase (GL.SOLAR): ==> Dumper HASH(0xda45980)
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Christian83 am 30 Mai 2023, 16:54:58
Anbei die Korrektur.
Edit: Updates weiter unten


Bitte im DEFINE hinter der Mailadresse noch die Seriennummer deines gateways schreiben. "define <name> ENPHASE <IPAddr> <username> <serialnum>"
(Findest du im enlighten in der Übersicht deiner Geräte).

Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Wernieman am 30 Mai 2023, 20:15:14
@wolfganghabenicht
in Deiner Logausgabe sind "interessante" Daten drin, wie z.B. eMail und Anlagennummer. Willst Du diese wirklich Veröffentlichen? Du kannst auch Deinen Beitrag editieren und es "anonymisieren" ....
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: wolfganghabenicht am 01 Juni 2023, 11:07:23
Hallo zusammen

vielen Dank für den Hinweis auf meine persönlichen Daten, ist entfernt

Ich habe die Seriennummer jetzt eingefügt, hat aber nicht viel bebracht.
Ich habe mir auf der Enphase-Plattform auch einen Account angelegt, und dort eine Application generiert, also Zugangsdaten sind vorhanden, und natürlich auch genau die Zugangsdaten, die ich angegeben habe.

Hier die Fehlermeldung von FHEM

2023.06.01 10:59:21 3: Enphase (GL.SOLAR): ==> url https://192.168.8.83/auth/check_jwt returned: <html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>Redirecting to <a id='link' href=''></a></center>
<script>
const redirect_url = window.location.protocol + '//' + window.location.host + '/home';
function redirect() { window.location.href = redirect_url; }
window.onload = function() {
    const link = document.getElementById('link');
    link.href = redirect_url;
    link.text = redirect_url;
    setTimeout(redirect, 500);
}
</script>
</body>
</html>
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: wolfganghabenicht am 01 Juni 2023, 11:08:37
Hallo zusammen

vielen Dank für den Hinweis auf meine persönlichen Daten, ist entfernt

Ich habe die Seriennummer jetzt eingefügt, hat aber nicht viel bebracht.
Ich habe mir auf der Enphase-Plattform auch einen Account angelegt, und dort eine Application generiert, also Zugangsdaten sind vorhanden, und natürlich auch genau die Zugangsdaten, die ich angegeben habe.

Hier die Fehlermeldung von FHEM

2023.06.01 10:59:21 3: Enphase (GL.SOLAR): ==> url https://192.168.8.83/auth/check_jwt returned: <html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>Redirecting to <a id='link' href=''></a></center>
<script>
const redirect_url = window.location.protocol + '//' + window.location.host + '/home';
function redirect() { window.location.href = redirect_url; }
window.onload = function() {
    const link = document.getElementById('link');
    link.href = redirect_url;
    link.text = redirect_url;
    setTimeout(redirect, 500);
}
</script>
</body>
</html>
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Christian83 am 01 Juni 2023, 11:14:46
Hi,

kannst du dich denn lokal auf deinem Gateway einloggen?

https://IP-Gateway/home.
Dort dann "Login mit Enphase".

Welche Firmware-Version hat dein Gateway?
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: wolfganghabenicht am 01 Juni 2023, 11:33:51
Moin

Anmeldung klappt, kommt allerdings eine Zertifikatswarnung.

Version ist D7.6.125

Gruß
Wolfgang
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Christian83 am 01 Juni 2023, 11:35:44
Alles klar. Dann diese Zugangsdaten auch im Modul hinterlegen. Dann sollte er zuerst eine Session-ID holen. Dann ein Token und dann eine sessionIDLocal.
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: wolfganghabenicht am 01 Juni 2023, 11:38:25
es kommt einmal kurz als Status 'Success', danach kommt wieder das toggeln zwischen 'reading token', 'getting token' und 'getting session ID local'
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Christian83 am 01 Juni 2023, 11:39:17
Zitat von: wolfganghabenicht am 01 Juni 2023, 11:38:25es kommt einmal kurz als Status 'Success', danach kommt wieder das toggeln zwischen 'reading token', 'getting token' und 'getting session ID local'

Kannst du mir mal den gesamten Log schicken (gerne als PM). Dann schau ich mal.
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: peterboeckmann am 10 November 2023, 13:29:53
Hallo Christian,

das Modul würde micha uch sehr interessieren. Kannst Du es hier nochmal hochladen oder mir sonst irgendwie zur Verfügung stellen?

Vielen Dank und viele Grüße,
Peter

Zitat von: Christian83 am 24 April 2023, 08:52:37Hi Mario,

anbei das Modul.
Edit: Altprogramm entfernt.

define <name> ENPHASE <IPAddr> <username>

username ist die mailadresse im Enlighten System.
Mit set <name> password <password> das Passwort für Enlighten hinterlegen.

get <name> LiveData - dann wird das Envoy ausgelesen.
Danach wird bei positiver Erzeugung aller 60 Sekunden sonst aller 300 Sekunden abgefragt. (Kann über Attribut updateinterval geändert werden).

Bei Fragen einfach melden.

Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: betateilchen am 10 November 2023, 13:34:29
Das Modul findest Du doch hier im Thread zum Download?

https://forum.fhem.de/index.php?msg=1277331
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: peterboeckmann am 10 November 2023, 13:56:31
Danke für den Tipp Betateilchen. Ich hatte eine Nachricht mit dem Text "anbei das Modul" gefunden, aber den Anhang nicht. ;-)
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: sebr am 12 November 2023, 20:27:52
Hi Christian,

coole Arbeit mit dem Modul, habe es auch am Laufen. Im Moment fragt das alle Sekunde den Live-Status ab und sagt dann "Daten zu alt". Das ist vermutlich normal oder, weil es Nacht ist und nichts produziert wird? Sobald erstmal Strom erzeugt wird fragt es im 60 bzw. 300 Sekunden Rhythmus, wenn ich das richtig gelesen habe.

Die Gesamtproduktion und den Gesamtverbrauch sehe ich aber schon Mal! Hast du eine kleine Doku (außerhalb des Code selbst ;) ) was für Parameter es noch gibt und wie man die einstellen kann?

Besten Dank für die Mühe,
Sebastian






Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Christian83 am 13 November 2023, 11:48:48
Zitat von: sebr am 12 November 2023, 20:27:52Hi Christian,

coole Arbeit mit dem Modul, habe es auch am Laufen. Im Moment fragt das alle Sekunde den Live-Status ab und sagt dann "Daten zu alt". Das ist vermutlich normal oder, weil es Nacht ist und nichts produziert wird? Sobald erstmal Strom erzeugt wird fragt es im 60 bzw. 300 Sekunden Rhythmus, wenn ich das richtig gelesen habe.

Die Gesamtproduktion und den Gesamtverbrauch sehe ich aber schon Mal! Hast du eine kleine Doku (außerhalb des Code selbst ;) ) was für Parameter es noch gibt und wie man die einstellen kann?

Besten Dank für die Mühe,
Sebastian



Hi Sebastian,

das Daten zu alt sorgt eigentlich nur dafür, dass die Datenaktualisierung im Gateway aktiviert wird, und dann sollte es (spätestens nach dem 2. Mal) auch wieder aktuelle Daten liefern. Da ich nicht mehr genau weiß, welcher Stand es war, habe ich nochmal das aktuelle Modul angehängt.

Attribute:

updateintervalconsWh - Ab welchem Verbrauch soll anderes Updateintervall benutzt werden
updateintervalconssec - Intervall ab Verbrauch laut updateintervalconsWh
updateintervalprodWh - Ab welcher Produktion soll anderes Updateintervall benutzt werden
updateintervalprodsec - Intervall ab Produktion laut updateintervalprodWh
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: sebr am 13 November 2023, 17:06:55
Klappt leider nicht.

Kriege in kurzer Abfolge:
getting Live Status timeout:10
reading Live Status
Daten zu alt

Hab ein Updateintervall nach 100WH Produktion von 20 Sek gesetzt, das scheint nicht zu ziehen.

Die Werte stimmen heute auch nicht mit der App überein.

Danke!


Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Christian83 am 13 November 2023, 17:38:50
Zitat von: sebr am 13 November 2023, 17:06:55Klappt leider nicht.

Kriege in kurzer Abfolge:
getting Live Status timeout:10
reading Live Status
Daten zu alt

Hab ein Updateintervall nach 100WH Produktion von 20 Sek gesetzt, das scheint nicht zu ziehen.

Die Werte stimmen heute auch nicht mit der App überein.

Danke!




Hallo,

schalte mal verbose auf 5 und poste das log. Achtung. Persönliche informationen entfernen.

Edit: Welche Version läuft auf dem Gateway?
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: sebr am 14 November 2023, 15:45:01
Gateway Firmware D7.6.168
Ich habe außerdem keine Batterie, falls das was zur Sache tut.

Hier das Log (sehe da jetzt keine persönlichen Daten):
023.11.14 15:35:35 4: Enphase (PV_SYS): ==> start livedaten
2023.11.14 15:35:36 5: Enphase (PV_SYS): ==> header: HTTP/1.1 200 OK
Server: openresty/1.17.8.1
Date: Tue, 14 Nov 2023 14:33:15 GMT
Content-Type: application/json
Connection: close
Pragma: no-cache
Expires: 1
Cache-Control: no-cache
Strict-Transport-Security: max-age=63072000; includeSubdomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
2023.11.14 15:35:36 5: Enphase (PV_SYS): ==> Error:
2023.11.14 15:35:36 5: Enphase (PV_SYS): ==> ReturnCode: 200
2023.11.14 15:35:36 5: Enphase (PV_SYS): ==> Readingtime: 1699972395
2023.11.14 15:35:36 5: Enphase (PV_SYS): ==> Readingtime: 14
2023.11.14 15:35:36 5: Enphase (PV_SYS): ==> Readingtime: 14
2023.11.14 15:35:36 5: Enphase (PV_SYS): ==> Readingtime: Tue Nov 14 15:33:15 2023
2023.11.14 15:35:37 4: Enphase (PV_SYS): ==> start newlive
2023.11.14 15:35:37 5: Enphase (PV_SYS): ==> header: HTTP/1.1 200 OK
Server: openresty/1.17.8.1
Date: Tue, 14 Nov 2023 14:33:16 GMT
Content-Length: 3441
Connection: close
Strict-Transport-Security: max-age=63072000; includeSubdomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
2023.11.14 15:35:37 5: {
    "connection": {
        "mqtt_state": "connected",
        "prov_state": "configured",
        "auth_state": "ok",
        "sc_stream": "enabled",
        "sc_debug": "disabled"
    },
    "meters": {
        "last_update": 1699972395,
        "soc": 0,
        "main_relay_state": 1,
        "gen_relay_state": 5,
        "backup_bat_mode": 1,
        "backup_soc": 0,
        "is_split_phase": 0,
        "phase_count": 3,
        "enc_agg_soc": 0,
        "enc_agg_energy": 0,
        "acb_agg_soc": 0,
        "acb_agg_energy": 0,
        "pv": {
            "agg_p_mw": 84446,
            "agg_s_mva": 313481,
            "agg_p_ph_a_mw": 36120,
            "agg_p_ph_b_mw": 29207,
            "agg_p_ph_c_mw": 19118,
            "agg_s_ph_a_mva": 108360,
            "agg_s_ph_b_mva": 109529,
            "agg_s_ph_c_mva": 95591
        },
        "storage": {
            "agg_p_mw": 0,
            "agg_s_mva": 0,
            "agg_p_ph_a_mw": 0,
            "agg_p_ph_b_mw": 0,
            "agg_p_ph_c_mw": 0,
            "agg_s_ph_a_mva": 0,
            "agg_s_ph_b_mva": 0,
            "agg_s_ph_c_mva": 0
        },
        "grid": {
            "agg_p_mw": 389700,
            "agg_s_mva": 687004,
            "agg_p_ph_a_mw": 14097,
            "agg_p_ph_b_mw": 14586,
            "agg_p_ph_c_mw": 361016,
            "agg_s_ph_a_mva": 91632,
            "agg_s_ph_b_mva": 138576,
            "agg_s_ph_c_mva": 456795
        },
        "load": {
            "agg_p_mw": 474146,
            "agg_s_mva": 1000485,
            "agg_p_ph_a_mw": 50217,
            "agg_p_ph_b_mw": 43793,
            "agg_p_ph_c_mw": 380134,
            "agg_s_ph_a_mva": 199992,
            "agg_s_ph_b_mva": 248105,
            "agg_s_ph_c_mva": 552386
        },
        "generator": {
            "agg_p_mw": 0,
            "agg_s_mva": 0,
            "agg_p_ph_a_mw": 0,
            "agg_p_ph_b_mw": 0,
            "agg_p_ph_c_mw": 0,
            "agg_s_ph_a_mva": 0,
            "agg_s_ph_b_mva": 0,
            "agg_s_ph_c_mva": 0
        }
    },
    "tasks": {
        "task_id": -1329390734,
        "timestamp": 1699916842
    },
    "counters": {
        "main_CfgLoad": 1,
        "main_CfgChanged": 1,
        "main_CfgNotFound": 230,
        "main_taskUpdate": 49,
        "MqttClient_publish": 220060,
        "MqttClient_respond": 1757,
        "MqttClient_msgarrvd": 879,
        "MqttClient_create": 7,
        "MqttClient_setCallbacks": 7,
        "MqttClient_connect": 7,
        "MqttClient_subscribe": 7,
        "SSL_Keys_Create": 7,
        "sc_hdlDataPub": 364533,
        "sc_SendStreamCtrl": 927,
        "sc_SendDemandRspCtrl": 1,
        "rest_Status": 77440
    },
    "dry_contacts": {
        "": {
            "dry_contact_id": "",
            "dry_contact_type": "",
            "dry_contact_load_name": "\u0006",
            "dry_contact_status": 3050996
        },
        "": {
            "dry_contact_id": "",
            "dry_contact_type": "",
            "dry_contact_load_name": "",
            "dry_contact_status": 3050996
        },
        "": {
            "dry_contact_id": "",
            "dry_contact_type": "",
            "dry_contact_load_name": "",
            "dry_contact_status": 3050996
        },
        "": {
            "dry_contact_id": "",
            "dry_contact_type": "",
            "dry_contact_load_name": "",
            "dry_contact_status": 3050996
        }
    }
}
2023.11.14 15:35:37 5: Enphase (PV_SYS): ==> Error:
2023.11.14 15:35:37 5: Enphase (PV_SYS): ==> ReturnCode: 200
2023.11.14 15:35:37 5: Enphase (PV_SYS): ==> Daten zu alt
2023.11.14 15:35:37 5: Enphase (PV_SYS): ==> Readingtime: 1699972395
2023.11.14 15:35:37 5: Enphase (PV_SYS): ==> Readingtime: 1699972537.61649
2023.11.14 15:35:37 5: Enphase (PV_SYS): ==> Readingtime: 14
2023.11.14 15:35:37 1: RMDIR: ./restoreDir/save/2023-11-02
2023.11.14 15:35:39 4: Enphase (PV_SYS): ==> start livedaten
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Wernieman am 14 November 2023, 16:05:09
Nur mal als Tipp am Rande:
Könntest Du bitte Config und Logausgaben in Code-Tags setzen? Im Menü des Web-Editors unter "Code" zu finden.
macht es viel einfacher zu lesen....
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Christian83 am 14 November 2023, 16:10:18
Zitat von: sebr am 14 November 2023, 15:45:012023.11.14 15:35:36 5: Enphase (PV_SYS): ==> Readingtime: Tue Nov 14 15:33:15 2023

Das zeigt, dass die Antwort vom Gateway von 15:33:15 ist. Dein FHEM aber schon 15:35:36 hat. Ich erlaube da einen Zeitversatz von 15 Sekunden (wegen Aktualität der Daten).
Die Frage ist jetzt, ob dein Gateway einfach die falsche Zeit hat.

(Bei mir ist aktuell ein Zeitversatz von 1 Sekunde)

Anbei die Anpassung.

Mit dem Attribut readingtimevariancesec kann man jetzt den Zeitversatz in Sekunden angeben. (Bei dir also 200...)

Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: sebr am 16 November 2023, 06:53:43
Guten Morgen Christian,

das war der Fehler. Mein envoy geht konstant 3 Minuten nach. Kontaktiere da jetzt mal den Support.
Zwei inhaltliche Fragen noch:
1. wNowProduction und wNowConsumption sind das, was ich im Moment unter Live-Daten bei Erzeugung/Verbrauch sehe richtig (Das würde passen)?
2. Der whTodayConsumption stimmt momentan. Der whTodayProduction sollte eigentlich bei 0 stehen, zeigt aber 3394 Wh an. Woran kann das liegen?

Danke für die Mühe, hast mir echt Zeit gespart! :)

Schönen Tag,
Sebastian
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Christian83 am 16 November 2023, 11:32:42
Zitat von: sebr am 16 November 2023, 06:53:43Zwei inhaltliche Fragen noch:
1. wNowProduction und wNowConsumption sind das, was ich im Moment unter Live-Daten bei Erzeugung/Verbrauch sehe richtig (Das würde passen)?
2. Der whTodayConsumption stimmt momentan. Der whTodayProduction sollte eigentlich bei 0 stehen, zeigt aber 3394 Wh an. Woran kann das liegen?

Hallo Sebastian,

1. Ja. Das sind die aktuellen Werte. (Wenn du in der App oder Web auf "Live-Status" gehst.
2. Da wurde mit einem Firmware-Update was verhunzt. Bei mir hat er sich dann irgendwann mitten am Tag auf 0 gesetzt. Momentan läuft der ohne Rücksetzung durch.

Gruß,

Christian
Titel: Aw: HTTPMOD - JSON - ENPHASE
Beitrag von: Christian83 am 17 November 2023, 12:52:53
Hab nen neues Thema dafür aufgemacht.
Dann gibt es einen gesammelten Ort.

https://forum.fhem.de/index.php?topic=135836.0