Skip to content

Commit

Permalink
Add additional validation for CONF_ENTRY_MAX_VOLUME value in the setu…
Browse files Browse the repository at this point in the history
…p process to be greater than zero (#24)

Fixes #19
  • Loading branch information
samuelspagl authored Apr 1, 2024
1 parent 3bcabb8 commit 430f6a1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [0.3.2] Fix division by zero

### Added

- The config flow now also checks whether the `int` provided for `CONF_ENTRY_MAX_VOLUME` is
greater than `1` and lower than `100`. This will make sure that a division by zero cannot happen.
- Add default value `100` to `CONF_ENTRY_MAX_VOLUME`

## [0.3.1] Documentation enhancements

### Changed
Expand Down
3 changes: 2 additions & 1 deletion custom_components/samsung_soundbar/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from homeassistant import config_entries
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from pysmartthings import APIResponseError
from voluptuous import All, Range

from .const import (CONF_ENTRY_API_KEY, CONF_ENTRY_DEVICE_ID,
CONF_ENTRY_DEVICE_NAME, CONF_ENTRY_MAX_VOLUME, DOMAIN)
Expand Down Expand Up @@ -45,7 +46,7 @@ async def async_step_user(self, user_input=None):
vol.Required(CONF_ENTRY_API_KEY): str,
vol.Required(CONF_ENTRY_DEVICE_ID): str,
vol.Required(CONF_ENTRY_DEVICE_NAME): str,
vol.Required(CONF_ENTRY_MAX_VOLUME): int,
vol.Required(CONF_ENTRY_MAX_VOLUME, default=100): All(int, Range(min=1, max=100))
}
),
)
2 changes: 1 addition & 1 deletion custom_components/samsung_soundbar/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/samuelspagl/ha_samsung_soundbar/issues",
"requirements": ["pysmartthings"],
"version": "0.3.1"
"version": "0.3.2"
}

0 comments on commit 430f6a1

Please sign in to comment.