mirror of
https://github.com/micahqcade/custom_vesync.git
synced 2025-03-12 07:40:07 +01:00
Only add night_light if True. (#82)
* Only add night_light if True. * update pre-commit
This commit is contained in:
parent
f49d265061
commit
057cbb71e0
@ -5,7 +5,7 @@ repos:
|
|||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: [--py37-plus]
|
args: [--py37-plus]
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 22.10.0
|
rev: 23.1.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
additional_dependencies: ['click==8.0.4']
|
additional_dependencies: ['click==8.0.4']
|
||||||
@ -31,10 +31,10 @@ repos:
|
|||||||
- pydocstyle==5.1.1
|
- pydocstyle==5.1.1
|
||||||
files: ^(custom_components)/.+\.py$
|
files: ^(custom_components)/.+\.py$
|
||||||
- repo: https://github.com/PyCQA/isort
|
- repo: https://github.com/PyCQA/isort
|
||||||
rev: 5.10.1
|
rev: 5.12.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: isort
|
- id: isort
|
||||||
- repo: https://github.com/adrienverge/yamllint.git
|
- repo: https://github.com/adrienverge/yamllint.git
|
||||||
rev: v1.28.0
|
rev: v1.29.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: yamllint
|
- id: yamllint
|
||||||
|
@ -13,10 +13,6 @@ from .const import DOMAIN
|
|||||||
TO_REDACT = {"cid", "uuid", "mac_id"}
|
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(
|
async def async_get_config_entry_diagnostics(
|
||||||
hass: HomeAssistant, entry: ConfigEntry
|
hass: HomeAssistant, entry: ConfigEntry
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
|
@ -50,7 +50,7 @@ def _setup_entities(devices, async_add_entities):
|
|||||||
entities.append(VeSyncDimmableLightHA(dev))
|
entities.append(VeSyncDimmableLightHA(dev))
|
||||||
if DEV_TYPE_TO_HA.get(dev.device_type) in ("bulb-tunable-white",):
|
if DEV_TYPE_TO_HA.get(dev.device_type) in ("bulb-tunable-white",):
|
||||||
entities.append(VeSyncTunableWhiteLightHA(dev))
|
entities.append(VeSyncTunableWhiteLightHA(dev))
|
||||||
if hasattr(dev, "night_light"):
|
if hasattr(dev, "night_light") and dev.night_light:
|
||||||
entities.append(VeSyncNightLightHA(dev))
|
entities.append(VeSyncNightLightHA(dev))
|
||||||
|
|
||||||
async_add_entities(entities, update_before_add=True)
|
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))
|
brightness = max(1, min(brightness, 255))
|
||||||
# convert to percent that vesync api expects
|
# convert to percent that vesync api expects
|
||||||
brightness = round((brightness / 255) * 100)
|
brightness = round((brightness / 255) * 100)
|
||||||
# ensure value between 1-100
|
return max(1, min(brightness, 100))
|
||||||
brightness = max(1, min(brightness, 100))
|
|
||||||
|
|
||||||
return brightness
|
|
||||||
|
|
||||||
|
|
||||||
class VeSyncBaseLight(VeSyncDevice, LightEntity):
|
class VeSyncBaseLight(VeSyncDevice, LightEntity):
|
||||||
|
@ -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
|
|
Loading…
x
Reference in New Issue
Block a user