diff --git a/.github/workflows/hassfest.yaml b/.github/workflows/hassfest.yaml index 8fe5df7..e3e3d53 100644 --- a/.github/workflows/hassfest.yaml +++ b/.github/workflows/hassfest.yaml @@ -1,10 +1,10 @@ name: Validate with hassfest on: - push: + #push: pull_request: - schedule: - - cron: "0 0 * * *" + #schedule: + # - cron: "0 0 * * *" jobs: validate: diff --git a/CHANGES.md b/CHANGES.md index 89f7b6d..de06a6e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Change log for Charge Amps for Home Assistant +## 1.9.4 (2024-05-03) + +- Update light color modes + ## 1.9.3 (2023-12-04) - Show zero max current correctly diff --git a/custom_components/chargeamps/light.py b/custom_components/chargeamps/light.py index c2e733b..23e5631 100644 --- a/custom_components/chargeamps/light.py +++ b/custom_components/chargeamps/light.py @@ -2,7 +2,11 @@ import logging -from homeassistant.components.light import SUPPORT_BRIGHTNESS, LightEntity +from homeassistant.components.light import ( + ColorMode, + LightEntity, + filter_supported_color_modes, +) from . import ChargeampsEntity from .const import DOMAIN, DOMAIN_DATA, SCAN_INTERVAL # noqa @@ -36,21 +40,21 @@ class ChargeampsLight(LightEntity, ChargeampsEntity): def __init__(self, hass, name, charge_point_id, light_type): super().__init__(hass, name, charge_point_id) self._light_type = light_type - self._supported_features = 0 - if light_type == "dimmer": - self._supported_features |= SUPPORT_BRIGHTNESS self._attributes["light_type"] = light_type + supported_color_modes = set() + if light_type == "dimmer": + supported_color_modes.add(ColorMode.BRIGHTNESS) + else: + supported_color_modes.add(ColorMode.ONOFF) + supported_color_modes = filter_supported_color_modes(supported_color_modes) + self._attr_supported_color_modes = supported_color_modes + self._attr_color_mode = next(iter(self._attr_supported_color_modes)) @property def unique_id(self): """Return a unique ID to use for this sensor.""" return f"{DOMAIN}_{self.charge_point_id}_{self._light_type}" - @property - def supported_features(self): - """Return supported features.""" - return self._supported_features - @property def is_on(self): settings = self.handler.get_chargepoint_settings(self.charge_point_id) diff --git a/custom_components/chargeamps/manifest.json b/custom_components/chargeamps/manifest.json index 786ea33..04e1fe2 100644 --- a/custom_components/chargeamps/manifest.json +++ b/custom_components/chargeamps/manifest.json @@ -1,20 +1,20 @@ { "domain": "chargeamps", "name": "Chargeamps", - "version": "1.9.3", - "documentation": "https://github.com/kirei/hass-chargeamps", - "issue_tracker": "https://github.com/kirei/hass-chargeamps/issues", + "codeowners": [ + "@kirei" + ], + "config_flow": false, "dependencies": [ ], - "config_flow": false, + "documentation": "https://github.com/kirei/hass-chargeamps", "iot_class": "cloud_polling", - "codeowners": [ - "@kirei" - ], + "issue_tracker": "https://github.com/kirei/hass-chargeamps/issues", "requirements": [ "chargeamps==1.6.1", "dataclasses-json>=0.5.2", "homeassistant>=2022.11.0" - ] -} + ], + "version": "1.9.4" +} \ No newline at end of file