Skip to content
This repository has been archived by the owner on Nov 25, 2023. It is now read-only.

Commit

Permalink
updated parsing classes to reflect updated protobuf messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nmakel committed Mar 31, 2020
1 parent cec1431 commit bbff4bd
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 73 deletions.
20 changes: 10 additions & 10 deletions solaredge_setapp/information.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ def parse_protobuf(self, bytes):
parsed["dsp1"] = str(f"{proto.dsp1.major}.{proto.dsp1.minor}.{proto.dsp1.build}")
parsed["dsp2"] = str(f"{proto.dsp2.major}.{proto.dsp2.minor}.{proto.dsp2.build}")

for logger in proto.errors.loggerList:
for logger in proto.errors.loggers:
parsed["errors"] = [{
"controller_id": int(logger.controllerid),
"controller_id": int(logger.controllerID),
"subsystem_id": int(logger.subsystem),
"error_code": int(error.errorCode),
"error_code": int(error.error_code),
"timestamp": int(datetime.datetime.strptime(
"{year} {month} {day} {hour} {minutes} {seconds}".format(
year=int(error.startTime.year),
month=int(error.startTime.month),
day=int(error.startTime.day),
hour=int(error.startTime.hour),
minutes=int(error.startTime.minute),
seconds=int(error.startTime.second)
year=int(error.start_time.year),
month=int(error.start_time.month),
day=int(error.start_time.day),
hour=int(error.start_time.hour),
minutes=int(error.start_time.minute),
seconds=int(error.start_time.second)
), "%Y %m %d %H %M %S").timestamp()),
} for error in logger.errorsList]
} for error in logger.errors]
except AttributeError as e:
print(f"AttributeError: {e}")

Expand Down
31 changes: 16 additions & 15 deletions solaredge_setapp/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,48 @@ def parse_protobuf(self, bytes):
"serial": str(proto.header.id),
"timestamp": int(proto.header.timestamp),
"standby": bool(proto.standby.activated),
"utc_offset": int(proto.dateAndTime.gmtOffset),
"ntp_server": str(proto.dateAndTime.ntp),
"utc_offset": int(proto.date_and_time.gmt_offset),
"ntp_server": str(proto.date_and_time.ntp),
"afci": {
"enabled": bool(proto.afci.enable),
"manual_reconnect": bool(proto.afci.manualReconnect),
"manual_reconnect": bool(proto.afci.manual_reconnect),
"test_result": int(proto.afci.test.result)
},
}

parsed["inverters"] = []

for inverter in proto.diagnostics.inverters.primary, proto.diagnostics.inverters.left, proto.diagnostics.inverters.right:
if inverter.invSn:
if inverter.inv_sn:

if inverter.isolation.rIso.scaling:
inverter_isolation_r_iso = float(inverter.isolation.rIso.value / inverter.isolation.rIso.scaling)
if inverter.isolation.r_iso.scaling:
inverter_isolation_r_iso = float(inverter.isolation.r_iso.value / inverter.isolation.r_iso.scaling)
else:
inverter_isolation_r_iso = float(inverter.isolation.rIso.value)
inverter_isolation_r_iso = float(inverter.isolation.r_iso.value)

if inverter.isolation.alpha.scaling:
inverter_isolation_alpha = float(inverter.isolation.alpha.value / inverter.isolation.alpha.scaling)
else:
inverter_isolation_alpha = float(inverter.isolation.alpha.value)

parsed["inverters"].append({
"serial": str(inverter.invSn),
"serial": str(inverter.inv_sn),
"isolation": {
"fault_location": int(inverter.isolation.faultLocation),
"fault_location": int(inverter.isolation.fault_location),
"r_iso": inverter_isolation_r_iso,
"alpha": inverter_isolation_alpha
},
"optimizers_status": {
"total": int(inverter.optimizersStatus.enabled),
"online": int(inverter.optimizersStatus.connected)
"total": int(inverter.optimizers_status.enabled),
"online": int(inverter.optimizers_status.connected)
},
"optimizers": [{
"serial": str(po.sn),
"online": bool(po.reports),
"po_voltage": int(po.outputV),
"module_voltage": int(po.inputV),
"module_current": int(po.inputC),
"po_voltage": int(po.output_v),
"po_power": int(po.energy.value),
"module_voltage": int(po.input_v),
"module_current": int(po.input_c),
"temperature": int(po.temperature.value),
"timestamp": 0 if not bool(po.reports) else int(datetime.datetime.strptime(
"{year} {month} {day} {hour} {minutes} {seconds}".format(
Expand All @@ -73,7 +74,7 @@ def parse_protobuf(self, bytes):
minutes=po.date.minute,
seconds=po.date.second
), "%Y %m %d %H %M %S").timestamp())
} for po in inverter.optimizerList]
} for po in inverter.optimizer]
})
except AttributeError as e:
print(f"AttributeError: {e}")
Expand Down
96 changes: 48 additions & 48 deletions solaredge_setapp/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,76 +18,76 @@ def parse_protobuf(self, bytes):

parsed = {
"serial": str(proto.sn),
"power_ac": float(proto.powerWatt),
"power_ac": float(proto.power_watt),
"power_ac_limit": int(proto.limit),
"voltage_ac": float(proto.voltage),
"frequency": float(proto.frequencyHz),
"frequency": float(proto.frequency_hz),
"status": int(proto.status),
"switch": bool(proto.switchStatus),
"cosphi": float(proto.cosPhi),
"switch": bool(proto.switch_status),
"cosphi": float(proto.cos_Phi),
"country_id": int(proto.country),
"portia_subsystem_id": int(proto.portiaSubsystem),
"portia_subsystem_id": int(proto.portia_subsystem),
"afci": {
"enabled": bool(proto.afci.enable),
"manual_reconnect": bool(proto.afci.manualReconnect),
"manual_reconnect": bool(proto.afci.manual_reconnect),
"test_result": int(proto.afci.test.result)
},
"optimizers": {
"total": int(proto.optimizersStatus.enabled),
"online": int(proto.optimizersStatus.connected)
"total": int(proto.optimizers_status.enabled),
"online": int(proto.optimizers_status.connected)
},
"server_connection": bool(proto.sOk),
"server_connection": bool(proto.s_ok),
"server_communication": {
"physical": bool(proto.serverComm.lanTest.physicalConnection),
"ip": bool(proto.serverComm.lanTest.ipAddress),
"gateway": bool(proto.serverComm.lanTest.gatewayLink),
"internet": bool(proto.serverComm.lanTest.internetLink),
"monitoring": bool(proto.serverComm.lanTest.monitoringLink),
"server": bool(proto.serverComm.lanTest.sOk)
"physical": bool(proto.server_comm.lan_test.physical_connection),
"ip": bool(proto.server_comm.lan_test.ip_address),
"gateway": bool(proto.server_comm.lan_test.gateway_link),
"internet": bool(proto.server_comm.lan_test.internet_link),
"monitoring": bool(proto.server_comm.lan_test.monitoring_link),
"server": bool(proto.server_comm.lan_test.s_ok)
},
"server_channel": {
"lan": bool(proto.serverChannel.lan.value),
"cellular": bool(proto.serverChannel.cellular.value),
"rs485_1": bool(proto.serverChannel.rs4851SeSlave.value),
"rs485_2": bool(proto.serverChannel.rs4852SeSlave.value),
"wifi": bool(proto.serverChannel.wifi.value),
"zigbee": bool(proto.serverChannel.zigbee.value)
"lan": bool(proto.server_channel.lan.value),
"cellular": bool(proto.server_channel.cellular.value),
"rs485_1": bool(proto.server_channel.rs485_1_se_slave.value),
"rs485_2": bool(proto.server_channel.rs485_2_se_slave.value),
"wifi": bool(proto.server_channel.wifi.value),
"zigbee": bool(proto.server_channel.zigbee.value)
},
"energy": {
"day": float(proto.energy.today),
"month": float(proto.energy.thisMonth),
"year": float(proto.energy.thisYear),
"month": float(proto.energy.this_month),
"year": float(proto.energy.this_year),
"total": float(proto.energy.total)
},
"inverters": [],
"meters": [],
"batteries": [],
"communication": {
"lan": {
"mac": str(proto.communication.lanInfo.mac.value),
"dhcp": bool(proto.communication.lanInfo.dhcp.value),
"ip": str(proto.communication.lanInfo.ip.ipAddress.value),
"netmask": str(proto.communication.lanInfo.ip.subnetMask.value),
"gateway": str(proto.communication.lanInfo.ip.gateway.value),
"dns": str(proto.communication.lanInfo.ip.dns.value),
"connected": bool(proto.communication.lanInfo.cableConnected.value)
"mac": str(proto.communication.lan_info.mac.value),
"dhcp": bool(proto.communication.lan_info.dhcp.value),
"ip": str(proto.communication.lan_info.ip.ip_address.value),
"netmask": str(proto.communication.lan_info.ip.subnet_mask.value),
"gateway": str(proto.communication.lan_info.ip.gateway.value),
"dns": str(proto.communication.lan_info.ip.dns.value),
"connected": bool(proto.communication.lan_info.cable_connected.value)
},
"rs485_1": {
"protocol": {
"se_slave": bool(proto.communication.rs4851.protocol.seSlave),
"se_master": bool(proto.communication.rs4851.protocol.seMaster),
"modbus_multi_devices": bool(proto.communication.rs4851.protocol.modbusMultiDevices),
"sunspec": bool(proto.communication.rs4851.protocol.sunspec),
"none": bool(proto.communication.rs4851.protocol.none)
"se_slave": bool(proto.communication.rs485_1.protocol.se_slave),
"se_master": bool(proto.communication.rs485_1.protocol.se_master),
"modbus_multi_devices": bool(proto.communication.rs485_1.protocol.modbus_multi_devices),
"sunspec": bool(proto.communication.rs485_1.protocol.sunspec),
"none": bool(proto.communication.rs485_1.protocol.none)
}
},
"rs485_2": {
"protocol": {
"se_slave": bool(proto.communication.rs4852.protocol.seSlave),
"se_master": bool(proto.communication.rs4852.protocol.seMaster),
"modbus_multi_devices": bool(proto.communication.rs4852.protocol.modbusMultiDevices),
"sunspec": bool(proto.communication.rs4852.protocol.sunspec),
"none": bool(proto.communication.rs4852.protocol.none)
"se_slave": bool(proto.communication.rs485_2.protocol.se_slave),
"se_master": bool(proto.communication.rs485_2.protocol.se_master),
"modbus_multi_devices": bool(proto.communication.rs485_2.protocol.modbus_multi_devices),
"sunspec": bool(proto.communication.rs485_2.protocol.sunspec),
"none": bool(proto.communication.rs485_2.protocol.none)
}
}
}
Expand All @@ -104,31 +104,31 @@ def parse_protobuf(self, bytes):
parsed["country"] = solaredge_setapp.Countries(-1).name

for inverter in proto.inverters.primary, proto.inverters.left, proto.inverters.right:
if not inverter.dspSn:
if not inverter.dsp_sn:
continue

if inverter.power.scaling:
inverter_power_ac = float(inverter.power.value / inverter.power.scaling)
else:
inverter_power_ac = float(inverter.power.value)

if inverter.isolation.rIso.scaling:
inverter_isolation_r_iso = float(inverter.isolation.rIso.value / inverter.isolation.rIso.scaling)
if inverter.isolation.r_iso.scaling:
inverter_isolation_r_iso = float(inverter.isolation.r_iso.value / inverter.isolation.r_iso.scaling)
else:
inverter_isolation_r_iso = float(inverter.isolation.rIso.value)
inverter_isolation_r_iso = float(inverter.isolation.r_iso.value)

if inverter.isolation.alpha.scaling:
inverter_isolation_alpha = float(inverter.isolation.alpha.value / inverter.isolation.alpha.scaling)
else:
inverter_isolation_alpha = float(inverter.isolation.alpha.value)

parsed["inverters"].append({
"serial": str(inverter.dspSn),
"serial": str(inverter.dsp_sn),
"voltage_dc": float(inverter.voltage),
"power_ac": inverter_power_ac,
"optimizers": {
"total": int(inverter.optimizers.enabled),
"online": int(inverter.optimizers.connected)
"total": int(inverter.optimizers_status.enabled),
"online": int(inverter.optimizers_status.connected)
},
"temperature": {
"value": int(inverter.temperature.value),
Expand All @@ -138,7 +138,7 @@ def parse_protobuf(self, bytes):
}
},
"isolation": {
"fault_location": int(inverter.isolation.faultLocation),
"fault_location": int(inverter.isolation.fault_location),
"r_iso": inverter_isolation_r_iso,
"alpha": inverter_isolation_alpha
},
Expand Down

0 comments on commit bbff4bd

Please sign in to comment.