rlindner / node-red-contrib-sma-webconnect

Node-RED node to query the web interface of SMA inverters
MIT License
13 stars 9 forks source link

Add support to query ids returning arrays and objects #13

Closed HoLo85 closed 3 years ago

HoLo85 commented 3 years ago

Added capability to store message arrays in custom messages.

HoLo85 commented 3 years ago

hi, updated the PR. The returned array values look like this with the current implementation: {"dc_power":[2067,479],"dc_voltage":[58645,40779],"dc_current":[3527,1178],"available_sessions":2}

HoLo85 commented 3 years ago

Had to do an update to the code so messages with objects also get stored if requested. The output will stay as it was, but now extended by array and object messages.

Input:

"sma_config": {
    "id": "1",
    "values": {
        "6100_0046E500": {
            "name": "phase1_voltage",
            "divider": 1
        },
        "6380_40251E00": {
            "name": "dc_power",
            "divider": 1
        },
        "6380_40451F00": {
            "name": "dc_voltage",
            "divider": 1
        },
        "6380_40452100": {
            "name": "dc_current",
            "divider": 1
        },
        "6180_00522900": {
            "name": "unknown",
            "divider": 1
        },
        "6180_08652500": {
            "name": "unknown2",
            "divider": 1
        }
    }
}

Output:

"phase1_voltage":23543,
"dc_power":[156,404],
"dc_voltage":[56146,33022],
"dc_current":[279,1226],
"unknown":{
    "low":0,
    "high":0,
    "val":null
},
"unknown2":{
    "tag":303
},
"available_sessions":1