Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix light color modes #53

Merged
merged 10 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
Loading