Skip to content

Commit

Permalink
Only add night_light if True. (vlebourl#82)
Browse files Browse the repository at this point in the history
* Only add night_light if True.

* update pre-commit
  • Loading branch information
vlebourl authored Feb 1, 2023
1 parent f49d265 commit 057cbb7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 29 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.1.0
hooks:
- id: black
additional_dependencies: ['click==8.0.4']
Expand All @@ -31,10 +31,10 @@ repos:
- pydocstyle==5.1.1
files: ^(custom_components)/.+\.py$
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0
rev: v1.29.0
hooks:
- id: yamllint
4 changes: 0 additions & 4 deletions custom_components/vesync/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
TO_REDACT = {"cid", "uuid", "mac_id"}


def _if_has_attr_else_none(obj, attr):
return getattr(obj, attr) if hasattr(obj, attr) else None


async def async_get_config_entry_diagnostics(
hass: HomeAssistant, entry: ConfigEntry
) -> dict[str, Any]:
Expand Down
7 changes: 2 additions & 5 deletions custom_components/vesync/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _setup_entities(devices, async_add_entities):
entities.append(VeSyncDimmableLightHA(dev))
if DEV_TYPE_TO_HA.get(dev.device_type) in ("bulb-tunable-white",):
entities.append(VeSyncTunableWhiteLightHA(dev))
if hasattr(dev, "night_light"):
if hasattr(dev, "night_light") and dev.night_light:
entities.append(VeSyncNightLightHA(dev))

async_add_entities(entities, update_before_add=True)
Expand Down Expand Up @@ -78,10 +78,7 @@ def _ha_brightness_to_vesync(ha_brightness):
brightness = max(1, min(brightness, 255))
# convert to percent that vesync api expects
brightness = round((brightness / 255) * 100)
# ensure value between 1-100
brightness = max(1, min(brightness, 100))

return brightness
return max(1, min(brightness, 100))


class VeSyncBaseLight(VeSyncDevice, LightEntity):
Expand Down
17 changes: 0 additions & 17 deletions pyproject.toml

This file was deleted.

0 comments on commit 057cbb7

Please sign in to comment.