Only add night_light if True. (#82)

* Only add night_light if True.

* update pre-commit
This commit is contained in:
Vincent Le Bourlot 2023-02-01 09:46:06 +01:00 committed by GitHub
parent f49d265061
commit 057cbb71e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 29 deletions

View File

@ -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']
@ -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

View File

@ -13,10 +13,6 @@ from .const import DOMAIN
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]:

View File

@ -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)
@ -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):

View File

@ -1,17 +0,0 @@
[tool.black]
target-version = ["py38"]
exclude = 'generated'
[tool.isort]
# https://github.com/PyCQA/isort/wiki/isort-Settings
profile = "black"
# will group `import x` and `from x import` of the same module.
force_sort_within_sections = true
known_first_party = [
"homeassistant",
"tests",
]
forced_separate = [
"tests",
]
combine_as_imports = true