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

Provide device presets in separate files #17

Closed HoLo85 closed 3 years ago

HoLo85 commented 3 years ago

This PR moves the presets into separate files in the new sma-device-presets/ folder. The presets are read when the node starts and are provided as before, accessing the presets does not change.

The presets have to be placed in a file named like the options in the device selection, e.g. sb_tripower.json and provide the following data:

{
    "name": "SUNNY TRIPOWER 8.0/10.0",
    "config": {
        "id": "1",
        "values": {
            "6100_0046E500": {
                "name": "phase1_voltage",
                "divider": 100
            },
            "6100_0046E600": {
                "name": "phase2_voltage",
                "divider": 100
            },
            "6100_0046E700": {
                "name": "phase3_voltage",
                "divider": 100
            },
            "6100_40463600": {
                "name": "grid_feedin",
                "divider": 1
            },
            "6100_40463700": {
                "name": "grid_consumption",
                "divider": 1
            },
            "6100_40263F00": {
                "name": "power",
                "divider": 1
            }
        }
    }
}
HoLo85 commented 3 years ago

Thanks for your proposed changes! Nice improvement! One thing I noticed is that the node wasn't working after packaging. The package.json includes a files array, where you need to add the newly added directory. I'd suggest to add the whole directory with all files in it with sma-device-presets/* (See another comment about the name of that directory). You can test it by creating a package with npm pack.

Sorry forgot that, the folder and files are now included in the package.

HoLo85 commented 3 years ago

@rlindner did you have a look at the last changes and can we merge the PR?

rlindner commented 3 years ago

There's still a reference to devList which prevents to node from loading:

ReferenceError: devList is not defined (line:8)

Once that's resolved, I'm fine with merging it. 👍