Skip to content

Commit

Permalink
filter dimmers for brightness attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
schmic committed Dec 12, 2023
1 parent 69b70fe commit 617ed7d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 11 additions & 3 deletions HaPlugin/Adjustments/DimmerAdjustment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@
{
using System;
using System.Collections.Generic;

using Loupedeck.HomeAssistant.Json;

using Newtonsoft.Json.Linq;

public class DimmerAdjustment : PluginDynamicAdjustment
{
private HaPlugin plugin;

public DimmerAdjustment() : base(true) => this.GroupName = "Dimmer";
public DimmerAdjustment() : base(true)
{
this.GroupName = "Dimmer";
this.ResetDisplayName = "Toggle";
}

protected override Boolean OnLoad()
{
Expand All @@ -21,9 +28,8 @@ protected override Boolean OnLoad()
foreach (KeyValuePair<String, Json.HaState> group in this.plugin.States)
{
var state = group.Value;
if (state.Entity_Id.StartsWith("light."))
if (this.IsDimmer(state))
{
// TODO: filter supported_color_modes["brightness"]
this.AddParameter(state.Entity_Id, state.FriendlyName, "Dimmer");
}
}
Expand All @@ -36,6 +42,8 @@ protected override Boolean OnLoad()
return true;
}

private Boolean IsDimmer(HaState state) => state.Entity_Id.StartsWith("light.") && state.Attributes.ContainsKey("brightness");

protected override String GetCommandDisplayName(String actionParameter, PluginImageSize imageSize)
{
if (actionParameter.IsNullOrEmpty())
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ To get a token you have to log into your Home-Assistant, then go to your Profile
Someone explained it [here](https://community.home-assistant.io/t/how-to-get-long-lived-access-token/162159/5) as well.

## Bugs & Issues
- Dimmers
- currently every light is also registered as a dimmer
- you must only configure entities as Dimmer if they have a `brightness` attribute
- Climate Control, current state is WIP
- visually different to others, no icons, no colors
- only shows the current state reported from HA
Expand All @@ -93,4 +90,5 @@ All icons used from the [Material Design Icons](https://pictogrammers.com/docs/g
- are they actually of any use?

## Lights
- filter dimmers by `brightness` attribute
- add support for different modes
- rgbw/led

0 comments on commit 617ed7d

Please sign in to comment.