Growatt Server

Hello,
Is there anyone who knew about the growatt server sensor, I really need help explaining some parts of the code. Such as:
`TOTAL_SENSOR_TYPES = {
“total_money_today”: (“Total money today”, “€”, “plantMoneyText”, None),
“total_money_total”: (“Money lifetime”, “€”, “totalMoneyText”, None),
“total_energy_today”: (“Energy Today”, “kWh”, “todayEnergy”, “power”),
“total_output_power”: (“Output Power”, “W”, “invTodayPpv”, “power”),
“total_energy_output”: (“Lifetime energy output”, “kWh”, “totalEnergy”, “power”),
“total_maximum_output”: (“Maximum power”, “W”, “nominalPower”, “power”),
}

INVERTER_SENSOR_TYPES = {
“inverter_energy_today”: (“Energy today”, “kWh”, “e_today”, “power”),
“inverter_energy_total”: (“Lifetime energy output”, “kWh”, “e_total”, “power”),
“inverter_voltage_input_1”: (“Input 1 voltage”, “V”, “vpv1”, None),
“inverter_amperage_input_1”: (“Input 1 Amperage”, “A”, “ipv1”, None),
“inverter_wattage_input_1”: (“Input 1 Wattage”, “W”, “ppv1”, “power”),
“inverter_voltage_input_2”: (“Input 2 voltage”, “V”, “vpv2”, None),
“inverter_amperage_input_2”: (“Input 2 Amperage”, “A”, “ipv2”, None),
“inverter_wattage_input_2”: (“Input 2 Wattage”, “W”, “ppv2”, “power”),
“inverter_voltage_input_3”: (“Input 3 voltage”, “V”, “vpv3”, None),
“inverter_amperage_input_3”: (“Input 3 Amperage”, “A”, “ipv3”, None),
“inverter_wattage_input_3”: (“Input 3 Wattage”, “W”, “ppv3”, “power”),
“inverter_internal_wattage”: (“Internal wattage”, “W”, “ppv”, “power”),
“inverter_reactive_voltage”: (“Reactive voltage”, “V”, “vacr”, None),
“inverter_inverter_reactive_amperage”: (“Reactive amperage”, “A”, “iacr”, None),
“inverter_frequency”: (“AC frequency”, “Hz”, “fac”, None),
“inverter_current_wattage”: (“Output power”, “W”, “pac”, “power”),
“inverter_current_reactive_wattage”: (“Reactive wattage”, “W”, “pacr”, “power”),`

and

def setup_platform(hass, config, add_entities, discovery_info=None):

I need explanations about: What lies in the variables, How it looks, and what is displayed to the user, what kind of sensors and why arguments are passed to them.

Hope someone can help me, I am on your disposition on Telegram (+48 53674520) or on discord (kret#7331)

I’d love to help you out! as the one who made these lists (which are slightly outdated already) i hope i’ll be able to help you understand.

TOTAL_SENSOR_TYPES = {
    "total_money_today": ("Total money today", "€", "plantMoneyText", {}),
    "total_money_total": ("Money lifetime", "€", "totalMoneyText", {}),
    "total_energy_today": ("Energy Today", ENERGY_KILO_WATT_HOUR, "todayEnergy", {},),
    "total_output_power": (
        "Output Power",
        POWER_WATT,
        "invTodayPpv",
        {"device_class": "power"},
    ),
    "total_energy_output": (
        "Lifetime energy output",
        ENERGY_KILO_WATT_HOUR,
        "totalEnergy",
        {},
    ),
    "total_maximum_output": (
        "Maximum power",
        POWER_WATT,
        "nominalPower",
        {"device_class": "power"},
    ),
}

I have seperated out the sensors by type.
Now it’s Total, Inverter and Storage
The keys of these lists such as inverter_energy_today are added to the s/n to create a unique device id (This is needed to manage the sensors via the front end, like disabling them.)
Then as the value i have a list going
Sensor name, Unit of measurement, api data name (the key in the response from Growatt), additional options.

setup_platform is the base of any integration, Home Assistant calls this with all those arguments allowing you to access the configuration values and to add entities.
So setup_platform recieves no sensors but it is the function that creates them.

I suggest reading through the devdocs a little bit: https://developers.home-assistant.io/docs/development_index/
And checking out the example sensor they have on there. It is the very basics of a sensor integration.