Skip to content

Commit

Permalink
Added TypedDef and protective code.
Browse files Browse the repository at this point in the history
Multiple Home Assistant checks passed.

black....................................................................Passed
codespell................................................................Passed
flake8...................................................................Passed
bandit...................................................................Passed
isort....................................................................Passed
Check JSON...............................................................Passed
yamllint.............................................(no files to check)Skipped
prettier.................................................................Passed
mypy.....................................................................Passed
pylint...................................................................Passed
gen_requirements_all.....................................................Passed
hassfest.................................................................Passed
hassfest-metadata....................................(no files to check)Skipped
hassfest-mypy-config.................................(no files to check)Skipped
  • Loading branch information
faanskit committed Dec 14, 2022
1 parent 5aef795 commit df1c6fd
Show file tree
Hide file tree
Showing 4 changed files with 875 additions and 524 deletions.
381 changes: 379 additions & 2 deletions custom_components/saj_esolar_air/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,388 @@
PLATFORMS: list[Platform] = [Platform.SENSOR]


class ESolarStoreFindRawdataPageList(TypedDict):
"""API response for findRawdataPageList."""

nowPrower: float
rOutPowerWattStr: str
batPower: float
rBackupPowerWatt: float
pV3StrCurr1Str: str
timeStart: str
pV4Curr: float
currSelfConsumePowerStr: str
rOutVolt: float
totalPVEnergy: float
tOutVolt: float
createTimeStr: str
deviceType: int
pV4StrCurr2Str: str
pv3SeriesCurrent: str
rGridFreqStr: str
totalBatDisEnergy: float
tOutFreqStr: str
sGridPowerWattStr: str
totalBatChgEnergy: float
isAdmin: str
pV1StrCurr4: float
pV1StrCurr3: float
pV1StrCurr2: float
pV1StrCurr1: float
pv2SeriesCurrent: str
POP: float
RST: int
pvInputMode: str
rGridFreq: float
sGridFreqStr: str
sGridVoltStr: str
tOutPowerVAStr: str
pV4VoltStr: str
batEnergyPercent: float
backupTotalLoadPowerWatt: float
tableStoreTimeEnd: str
tOutVoltStr: str
rGridVoltStr: str
batVoltStr: str
tGridCurrStr: str
rGridCurr: float
rOutFreqStr: str
userId: str
partitionName: str
sGridVolt: float
pV3PowerStr: str
tOnGridOutVolt: float
tGridPowerWattStr: str
pV2StrCurr4Str: str
ctPVPowerWattStr: str
pV4StrCurr3Str: str
tOutPowerWatt: float
pV3Power: float
pV1CurrStr: str
pV2CurrStr: str
pV4CurrStr: str
onLineStr: str
pV2Power: float
todayBatDisEnergy: float
pac: float
officeId: str
rOutPowerWatt: float
pacStr: str
powernow: float
ctPvCurr: float
tGridVoltStr: str
powerNower: str
pvChannelList: list[Any]
pv1SeriesCurrent: str
pV1Power: float
pV4Volt: float
pV3StrCurr2Str: str
deviceTempStr: str
rOutCurr: float
tOutCurr: float
todayFeedInEnergyStr: str
totalPVEnergyStr: str
pV3Curr: float
sOnGridOutPowerWatt: float
tGridFreqStr: str
todayBatChgEnergy: float
pV1StrCurr1Str: str
tGridFreq: float
totalFeedInEnergy: float
sOutPowerVAStr: str
gridDirection: int
batCurrStr: str
powerNow: float
rOutPowerVA: float
kitType: str
pV1VoltStr: str
todayLoadEnergy: float
sOutPowerWattStr: str
pV4StrCurr1: float
sGridPowerVA: float
pV4StrCurr2: float
pV4StrCurr3: float
pV4StrCurr4: float
sOutPowerVA: float
batType: str
pV3Volt: float
rGridPowerVAStr: str
tGridPowerVAStr: str
tGridCurr: float
rOnGridOutFreq: float
pV4StrCurr4Str: str
tOutFreq: float
todayPVEnergy: float
tGridPowerWatt: float
sGridPowerVAStr: str
tOutCurrStr: str
ctPvCurrStr: str
pV2Curr: float
totalLoadEnergy: float
pV2PowerStr: str
datetimeStr: str
powernower: str
PVP: float
rGridCurrStr: str
totalLoadPowerWattStr: str
pV1StrCurr2Str: str
nowProwerStr: str
totalLoadEnergyStr: str
sOutVolt: float
ctGridPowerWattStr: str
rGridPowerVA: float
index: int
tGridVolt: float
todayFeedInEnergy: float
totalBatChgEnergyStr: str
tOnGridOutPowerWatt: float
pV3VoltStr: str
batPowerStr: str
pV2Volt: float
deviceSn: str
todayPVEnergyStr: str
pV3StrCurr3Str: str
rGridPowerWattStr: str
batCapicity: str
sGridCurrStr: str
sOutCurrStr: str
pV2StrCurr2: float
timeEnd: str
pV2StrCurr1: float
pV2StrCurr3Str: str
tOutPowerWattStr: str
tOutPowerVA: float
pV2StrCurr4: float
pV2StrCurr3: float
rOutFreq: float
plantuid: str
endUser: str
totalSellEnergy: float
sGridPowerWatt: float
pV1StrCurr3Str: str
rOnGridOutVolt: float
totalSellEnergyStr: str
deviceModel: str
batVolt: float
todaySellEnergy: float
totalFeedInEnergyStr: str
sOutVoltStr: str
timeStr: str
pV3CurrStr: str
pV1Curr: float
sOutPowerWatt: float
pV3StrCurr1: float
pV3StrCurr2: float
rOnGridOutPowerWatt: float
pV3StrCurr3: float
pV3StrCurr4: float
pv4SeriesCurrent: str
kitSN: str
pV2StrCurr1Str: str
pV4Power: float
todaySellEnergyStr: str
sOutFreq: float
sGridCurr: float
typeStr: str
rGridVolt: float
rOutPowerVAStr: str
rOutCurrStr: str
pV4PowerStr: str
userUid: str
pV2StrCurr2Str: str
pV4StrCurr1Str: str
ctGridPowerWatt: float
deviceTemp: float
pV2VoltStr: str
sOutFreqStr: str
batCurr: float
totalBatDisEnergyStr: str
pV1PowerStr: str
batEnergyPercentStr: str
pV1StrCurr4Str: str
ctPVPowerWatt: float
totalLoadPowerWatt: float
todaySelfConsumpEnergy: float
rOutVoltStr: str
todayLoadEnergyStr: str
rGridPowerWatt: float
sOutCurr: float
pV3StrCurr4Str: str
sGridFreq: float
tGridPowerVA: float
meterAStatus: int
pV1Volt: float
sOnGridOutVolt: float
todaySelfConsumpEnergyStr: str
plantName: str


class ESolarStoreDevicePower(TypedDict):
"""API response for storeDevicePower."""

pvPower: float
gridPower: float
inputOutputPower: float
batteryPower: float
totalLoadPower: float
homeLoadPower: float
backupLoadPower: float
solarPower: float
batCurr: float
batEnergyPercent: float
runningState: int
isOnline: int
isAlarm: int
mark: int
batCapcity: float
batCapcityStr: str
hasMeter: bool
hasBattery: bool
pvDirection: int
gridDirection: int
batteryDirection: int
outPutDirection: int
dataTime: int
updateDate: int


class ESolarKitList(TypedDict):
"""API response for kitList."""

invType: str
kitType: str
monthSellEnergyStr: str
todaySellEnergy: float
kitSn: str
updateDateStr: str
ifShowAFCI: int
powernower: str
mastermcufw: str
type: int
devicetype: str
onLineStr: str
displayfw: str
devicepc: str
powernow: float
isShowBattery: int
owner: str
todaySellEnergyStr: str
index: int
monthSellEnergy: float
devicesn: str
userId: str
onLine: int
slavemcufw: str
isModuleExpire: int
totalSellEnergy: float
totalSellEnergyStr: str
isShowHighVoltBat: int
isHistory: int
mark: int
plantName: str
dataTimeStr: str
findRawdataPageList: ESolarStoreFindRawdataPageList
storeDevicePower: ESolarStoreDevicePower
status: str


class ESolarBeanList(TypedDict):
"""API response for beanList."""

pvElec: float
useElec: float
buyElec: float
sellElec: float
chargeElec: float
dischargeElec: float
buyRate: str
sellRate: str
selfConsumedRate1: str
selfConsumedRate2: str
selfConsumedEnergy1: float
selfConsumedEnergy2: float
plantTreeNum: float
reduceCo2: float
dataTime: None | int
devicesn: str


class ESolarPlantDetail(TypedDict):
"""API response for platDetail."""

type: int
runningState: int
nowPower: float
todayElectricity: float
monthElectricity: float
yearElectricity: float
totalElectricity: float
totalConsumpElec: None | float
totalBuyElec: None | float
totalSellElec: None | float
selfUseRate: None | str
income: None | float
todayGridIncome: None | float
devOnlineNum: int
devTotalNum: int
totalPlantTreeNum: float
totalReduceCo2: float
todayAlarmNum: None | int
lastUploadTime: str
userType: int
snList: list[str]
energyCompareYearList: list[str]


class ESolarPeakList(TypedDict):
"""API response for peakList."""

devicesn: str
peakPower: float


class ESolarPlantList(TypedDict):
"""API response for plantList."""

plantuid: str
plantname: str
systempower: float
currency: str
type: int
installername: str
countryCode: str
country: str
province: str
city: str
county: str
foreignRemark: str
address: str
latitude: float
longitude: float
createDateStr: str
isOnline: str
runningState: int
nowPower: float
todayElectricity: float
totalElectricity: float
enableEdit: str
enableDelete: str
enableVisitor: str
isFavorite: str
isRename: int
isMulBind: int
isTimeError: int
plantDetail: ESolarPlantDetail
status: str
peakList: None | list[ESolarPeakList]
kitList: None | list[ESolarKitList]
beanList: None | list[ESolarBeanList]


class ESolarResponse(TypedDict):
"""API response."""

status: str
plantList: dict[str, Any]
plantList: list[ESolarPlantList]


async def update_listener(hass, entry):
Expand Down
Loading

0 comments on commit df1c6fd

Please sign in to comment.