def _update_attr(self, surepy_entity: SurepyEntity) -> None: """Get the latest data and update the state.""" state = surepy_entity.raw_data()["status"] self._attr_is_on = self._attr_available = bool(state["online"]) if surepy_entity.raw_data(): self._attr_extra_state_attributes = { "led_mode": int(surepy_entity.raw_data()["status"]["led_mode"]), "pairing_mode": bool( surepy_entity.raw_data()["status"]["pairing_mode"] ), } else: self._attr_extra_state_attributes = {}
def _update_attr(self, surepy_entity: SurepyEntity) -> None: """Update the state.""" status = surepy_entity.raw_data()["status"] self._attr_is_locked = (LockState( status["locking"]["mode"]).name.lower() == self._lock_state) self._available = bool(status.get("online"))
def _update_attr(self, surepy_entity: SurepyEntity) -> None: state = surepy_entity.raw_data()["status"] self._attr_is_on = bool(state) if state: self._attr_extra_state_attributes = { "device_rssi": f'{state["signal"]["device_rssi"]:.2f}', "hub_rssi": f'{state["signal"]["hub_rssi"]:.2f}', } else: self._attr_extra_state_attributes = {}
def _update_attr(self, surepy_entity: SurepyEntity) -> None: """Update the state and attributes.""" state = surepy_entity.raw_data()["status"] try: per_battery_voltage = state["battery"] / 4 voltage_diff = per_battery_voltage - SURE_BATT_VOLTAGE_LOW self._attr_native_value = min( int(voltage_diff / SURE_BATT_VOLTAGE_DIFF * 100), 100) except (KeyError, TypeError): self._attr_native_value = None if state: voltage_per_battery = float(state["battery"]) / 4 self._attr_extra_state_attributes = { ATTR_VOLTAGE: f"{float(state['battery']):.2f}", f"{ATTR_VOLTAGE}_per_battery": f"{voltage_per_battery:.2f}", } else: self._attr_extra_state_attributes = {}