Add data to EmonPi V8,5 V.Low Write using HTTP calls

I want to configure EmonHub to accept data submitted from HTTP calls, but need help.

I have Micro inverters that output performance data via a gateway and a script that breaks out the individual data fields (Thanks Andi). The Http call  to  EmonPi with the data gets an ok response, but nothing appears in the node or feeds pages.  In the old input model, I suspect I would see the data in the input section and be able to configure for the feeds page.

I have played around with EmonHub Conf to attempt recognition with no success. I had to guess as I could not find any reference.

[interfacers]     ...

[[Inverters]]   # inverters data feed
    Type = EmonHubSocketInterfacer
    [[[init_settings]]]
        port_nb = 5040
    [[[runtimesettings]]] 

[Nodes]

[[25]]
    nodename=Inverter05
    firmware=Inverter_gen1
    hardware=Inverter_gen1
    [[[rx]]]
        names=AC_Output, DC_Input, Net_Frequency, Net_Voltage, Inverter_temp, Lifetime_Output, DC_current, DC_Volt, Accumulated_Wh, Accumulated_kWh
        datacodes= Could use H and L, but data currently in Data name and Data value pairs
        scales=1,1,1,1,1,1,1,1,1,1
        units=W,W,H,V,C,kW,A,V,W,kW

HTTP call:

 "http://$host/input/post.json?node=$IDDec&json={AC_Output:$ACpower,DC_Input:$HexDCPower,Net_Frequency:$HexACFreq,Net_Voltage:$HexACVolt,

Inverter_temp:$HexTemperature,Lifetime_Output:$LifekWh,DC_current:$HexDCCurrent,DC_Volt:$HexDCVolt,

Accumulated_Wh:$HexWh,Accumulated_kWh:$HexkWh}&apikey=$apikey"

$IDDec is a nine digit serial number, but I can translate to stay in the 30 maximum node restriction. (The Node section shows a translated inverter id.)

$host = 192.168.1.x

$apikey = Allocated key for the local EmonPi.

Help would be greatly appeciated.​

 

 

 

pb66's picture

Re: Add data to EmonPi V8,5 V.Low Write using HTTP calls

emonhub cannot recieve via http api yet, you can (and it looks like you have) open a socket to post data too but emonHub just listens to the port and you will need to send the data to the port in the right format, which is just a string of values with no labels or apikey etc.

The script you have that breaks out the values, how does that work? can we see it? I'm wondering if you can just ammend it to send to a port via a socket rather than use http and what form the incoming data is in before processing?

datacodes are used to translate "bytevalues" into real values and you are already using real values, either you need to pass data in bytes or configure emonhub to accept real values ie datacode=0.

either way the key value pairs will need to be just space separated values for emonhub to process

Paul

psg's picture

Re: Add data to EmonPi V8,5 V.Low Write using HTTP calls

Paul,

Thank you for the guidance, which will help me work on the code to feed in through Emonhub. The HTTP call was designed and works fine feeding into EmonCMS.org  Input service.  

pb66's picture

Re: Add data to EmonPi V8,5 V.Low Write using HTTP calls

You could amend the script to send to both emoncms's (or run 2 copies?) the changes should be minimised this way, but it's not ideal. IMO the data should be sent once to the hub, and emonhub should forward the data to (all) the emoncms server(s) .

Paul

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.