gjohansson-ST / sector

Integration to Sector Alarm for Home Assistant
35 stars 16 forks source link

Get Temperature #169

Open cerede2000 opened 11 months ago

cerede2000 commented 11 months ago

Hi, I have a smoke detector and several door opening shock detectors on my Sector Alarm installation. When I activate the temperature rise option, the initialization of the component fails.

After analysis and testing on the code side, there are several things that need to be corrected.

In the file coordinator.py line 266 I added exception handling to firstly correct the error during initialization : 263 to 268 : LOGGER.debug("Temps refreshed: %s", response_temp) for temp in response_temp: if serial := temp.get("SerialNo"): data[key]["temp"][serial]["temperature"] = temp.get( "Temprature" ) To : LOGGER.debug("Temps refreshed: %s", response_temp) for temp in response_temp: if serial := temp.get("SerialNo"): try: data[key]["temp"][serial]["temperature"] = temp.get( "Temprature" ) except Exception as e: LOGGER.error("Error on %s - %s", serial, e)

After this correction I noticed that the temperatures of my opening sensors were not present either. I modified like this coordinator.py: 169 : if self._update_sensors: LOGGER.debug("Trying to refresh temperatures") response_temp = await self._request( API_URL + f"/Panel/GetTemperatures?panelId={panel_id}" ) if not response_temp: LOGGER.debug("Could not retrieve temp data for panel %s", panel_id) else: LOGGER.debug("Temps refreshed: %s", response_temp) temp_dict = {} for temp in response_temp: temp_dict[temp.get("SerialNo")] = { "name": temp.get("Label"), "serial": temp.get("SerialNo"), } data[panel["PanelId"]]["temp"] = temp_dict

Nolux commented 10 months ago

I had the same issue. Thanks for the fix. It only pulled half of my temp sensors tho.