Skip to content

Commit

Permalink
Merge pull request #53 from kirei/color_modes
Browse files Browse the repository at this point in the history
Fix light color modes
  • Loading branch information
jschlyter authored May 15, 2024
2 parents b1f21a6 + be69f59 commit 4275382
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/hassfest.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Validate with hassfest

on:
push:
#push:
pull_request:
schedule:
- cron: "0 0 * * *"
#schedule:
# - cron: "0 0 * * *"

jobs:
validate:
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 13 additions & 9 deletions custom_components/chargeamps/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions custom_components/chargeamps/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 4275382

Please sign in to comment.