Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
add debug option
Browse files Browse the repository at this point in the history
  • Loading branch information
dynasticorpheus committed Dec 5, 2023
1 parent db21a07 commit 73823de
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
23 changes: 21 additions & 2 deletions custom_components/gigasetelements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
AUTH_GSE_EXPIRE,
BUTTON_PRESS_MAP,
CONF_CODE_ARM_REQUIRED,
CONF_ENABLE_DEBUG,
DEVICE_MODE_MAP,
DEVICE_TRIGGERS,
DOMAIN,
Expand All @@ -63,6 +64,7 @@
vol.Optional(CONF_SWITCHES, default=True): cv.boolean,
vol.Optional(CONF_CODE_ARM_REQUIRED, default=True): cv.boolean,
vol.Optional(CONF_CODE, "code validation"): cv.string,
vol.Optional(CONF_ENABLE_DEBUG, default=False): cv.boolean,
}
),
},
Expand Down Expand Up @@ -96,11 +98,18 @@ def toggle_api_updates(event):
alarm_switch = config[DOMAIN].get(CONF_SWITCHES)
time_zone = str(hass.config.time_zone)
name = config[DOMAIN].get(CONF_NAME)
enable_debug = config[DOMAIN].get(CONF_ENABLE_DEBUG)

_LOGGER.debug("Initializing %s client API", DOMAIN)

client = GigasetelementsClientAPI(
username, password, code, code_arm_required, time_zone, alarm_switch
username,
password,
code,
code_arm_required,
time_zone,
alarm_switch,
enable_debug,
)

hass.data[DOMAIN] = {"client": client, "name": name}
Expand All @@ -114,14 +123,22 @@ def toggle_api_updates(event):

class GigasetelementsClientAPI:
def __init__(
self, username, password, code, code_arm_required, time_zone, alarm_switch
self,
username,
password,
code,
code_arm_required,
time_zone,
alarm_switch,
enable_debug,
):
self._username = username
self._password = password
self._time_zone = time_zone
self._alarm_switch = alarm_switch
self._code = code
self._code_arm_required = code_arm_required
self._enable_debug = enable_debug
self._mode_transition = False
self._target_state = STATE_ALARM_DISARMED
self._state = STATE_ALARM_DISARMED
Expand All @@ -143,6 +160,8 @@ def __init__(
)

_LOGGER.debug("Property id: %s", self._property_id)
if self._enable_debug:
_LOGGER.warn("API response object: %s %s", "\n", self._elements_data)

@staticmethod
def _do_request(request_type, url, payload=""):
Expand Down
1 change: 1 addition & 0 deletions custom_components/gigasetelements/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
}

CONF_CODE_ARM_REQUIRED = "code_arm_required"
CONF_ENABLE_DEBUG = "enable_debug"

DEVICE_CLASS_MAP = {
"base": None,
Expand Down

0 comments on commit 73823de

Please sign in to comment.