Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging for api errors #108

Merged
merged 3 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion custom_components/sessy/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/PimDoos/ha-sessy/issues",
"requirements": ["sessypy==0.1.12"],
"version": "0.7.1",
"version": "0.7.2",
"zeroconf":[
{"type":"_http._tcp.local.","name":"sessy-*"}
]
Expand Down
6 changes: 4 additions & 2 deletions custom_components/sessy/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ async def partial_update_settings(key,value):
# Firmware or hardware-revision specific settings
try:
settings: dict = get_cache_command(hass, config_entry, SessyApiCommand.SYSTEM_SETTINGS)

if "error" in settings:
_LOGGER.warning(f"Sessy settings api returned an error:\n{ settings.get("error") }\nSome entities might not work until settings are saved in the Sessy portal or web UI.")

# Noise controls
if settings.get("disable_noise_level", True) == False:
numbers.append(
Expand Down Expand Up @@ -99,7 +101,7 @@ async def partial_update_settings(key,value):

)
except Exception as e:
_LOGGER.warning(f"Error setting firmware specific settings: {e}")
_LOGGER.warning(f"Error setting up firmware specific settings: {e}\n{settings}")


elif isinstance(device, SessyMeter):
Expand Down
4 changes: 3 additions & 1 deletion custom_components/sessy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ async def update(event_time_utc: datetime = None):
cache: dict = hass.data[DOMAIN][config_entry.entry_id][SESSY_CACHE]

try:
result = await device.api.get(command)
result: dict = await device.api.get(command)
cache[command] = result
if "error" in result:
_LOGGER.debug(f"Sessy api returned an error while updating cache for {command}: {result.get("error")}")
except Exception as e:
result = None
cache[command] = None
Expand Down