djansen1987 / SAJeSolar

SAJ eSolar Portal Sensors
GNU General Public License v3.0
21 stars 13 forks source link

Battery temperature sensor #46

Closed cypherbits closed 1 year ago

cypherbits commented 1 year ago

H1 with batteries you can get the average battery temperature.

Will make a pull request soon. I have this working.

cypherbits commented 1 year ago

@djansen1987 Some questions about the lastest beta:

I implemented the batteryTemperature that is working for me on a H1. Reenabled the configuration and the sensors check. I want to check for the configuration batteryTemperature before calling and trying to get the temperature, that is why I reenabled them.

djansen1987 commented 1 year ago

Hi @cypherbits,

THanks for your interest, I am looking in to making the setup more easy. No more advanced config yaml, and let the component find out what type or modules you have. But as you can see i am a bit stuck. This is partly due to the lack of enough python knowledge and also time.

Maybe you can help out, only thing important to me is backward competible sensor names to maintain Energy dashboard statistics.

djansen1987 commented 1 year ago

I have checked one of my account with a battery but can't seem to find a api endpoint showing battery tempature. Please reopen the issue if you have found more information.

cypherbits commented 1 year ago

Some code I have:

url_findBatteryRealTimeList = f"https://fop.saj-electric.com/saj/cloudMonitor/deviceInfo/findBatteryRealTimeList"
                #"2022-11-10+21:30:00"
                datetime_now = datetime.datetime.now().strftime("%Y-%m-%d+%H:%M:%S")
                _LOGGER.debug(datetime_now)
                payloadBattery= f"devicesn={deviceSnArr}&timeStr={datetime_now}"
                response_findBatteryRealTimeList = await self._session.post(url_findBatteryRealTimeList, headers=headers, data=payloadBattery)
                result_findBatteryRealTimeList = await response_findBatteryRealTimeList.json()
                result_batteryTemperature = dict()
                result_batteryTemperature["batteryTemperature"]=result_findBatteryRealTimeList["list"][0][0]["batTemperature"]
                plantDetails.update(result_batteryTemperature)
                _LOGGER.debug(result_findBatteryRealTimeList)

                if response_findBatteryRealTimeList.status != 200:
                    _LOGGER.error(f"{response_findBatteryRealTimeList.url} returned {response_findBatteryRealTimeList.status}")
                    return