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

Wanted to share some ColorLogic light tips to the Wiki but don't know how #52

Open
ahuffman opened this issue Aug 29, 2023 · 3 comments

Comments

@ahuffman
Copy link

Hi @djtimca , I had some tips to add to the wiki for the new v2 lights, and used some of the stuff you have in the documentation and wiki as a starting point.

This is the result of what I put together for my pool dashboard using the OmniLogic HACS integration:

image

Step 1) Input Select Custom Order and Text

For one thing, I wanted to beautify and re-order how my light shows/solid light colors were displayed. What I wanted was to have clean names without the all capital letters and underscores, and also wanted to move the shows (non-solid colors) to the top of the list because I use those most frequently.

To do this I created a new input select in Settings > Devices & Services > Helpers.
The raw file from my home assistant storage is this:

{
  "version": 1,
  "minor_version": 2,
  "key": "input_select",
  "data": {
    "items": [
      {
        "id": "colorlogic_show",
        "name": "ColorLogic Show",
        "icon": "mdi:alarm-light",
        "options": [
          "Cool Cabaret",
          "Gemstone",
          "Mardi Gras",
          "Tranquility",
          "Twilight",
          "USA",
          "Voodoo Lounge",
          "Afternoon Sky",
          "Aqua Green",
          "Bright Yellow",
          "Burnt Orange",
          "Cloud White",
          "Crisp White",
          "Deep Blue Sea",
          "Emerald",
          "Flamingo",
          "Gold",
          "Mint",
          "Orange",
          "Pure White",
          "Royal Blue",
          "Sangria",
          "Teal",
          "Vivid Violet",
          "Warm Red",
          "Warm White",
          "Yellow"
        ]
      }
    ]
  }
}

Step 2 & 3) Input Sliders

I needed to have sliders to set my brightness and speed, aka input_number. I created 2 helpers in Settings > Devices & Services > Helpers to achieve this. Here is the raw code from .storage in home assistant config:

{
  "version": 1,
  "minor_version": 1,
  "key": "input_number",
  "data": {
    "items": [
      {
        "id": "colorlogic_speed",
        "min": 0.0,
        "max": 8.0,
        "name": "ColorLogic Speed",
        "icon": "mdi:speedometer",
        "step": 1.0,
        "mode": "slider"
      },
      {
        "id": "colorlogic_brightness",
        "min": 0.0,
        "max": 4.0,
        "name": "ColorLogic Brightness",
        "icon": "mdi:brightness-7",
        "step": 1.0,
        "mode": "slider"
      }
    ]
  }
}

Step 4) Toggle

Since I need something specific to happen to use the v2 light API I cannot use the normal light object's on/off toggle. I created a input_boolean (toggle) in Settings > Devices & Services > Helpers. Here is the raw configuration from .storage:

{
  "version": 1,
  "minor_version": 1,
  "key": "input_boolean",
  "data": {
    "items": [
      {
        "id": "colorlogic_light",
        "name": "ColorLogic Light",
        "icon": "mdi:lightbulb"
      }
    ]
  }
}

Now that we have helpers, we can assemble automation. In my case I was able to initially get things working with a single automation, however I found that if I power my lights on with the Hayward OmniLogic phone app, my helper toggle would be out of sync, and therefore landed on 2 automations. Here is the raw code to save time:

Step 5) Setup automations

Automation 1) Main custom light control for v2 lights

alias: Pool - Control Lights with Settings
description: Uses helpers to properly control Hayward OmniLogic v2 lights.
trigger:
  - platform: state
    entity_id:
      - input_boolean.colorlogic_light
  - platform: state
    entity_id:
      - input_number.colorlogic_brightness
  - platform: state
    entity_id:
      - input_number.colorlogic_speed
  - platform: state
    entity_id:
      - input_select.colorlogic_show
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: light.home_huff_pool_color_lights_2
            state: "off"
          - condition: state
            entity_id: input_boolean.colorlogic_light
            state: "on"
        sequence:
          - service: omnilogic.set_v2_lights
            data:
              entity_id: light.home_huff_pool_color_lights_2
              speed: "{{ states('input_number.colorlogic_speed') }}"
              brightness: "{{ states('input_number.colorlogic_brightness') }}"
          - service: light.turn_on
            data:
              effect: >-
                {{ states('input_select.colorlogic_show') | upper | replace(' ',
                '_') }}
            target:
              entity_id: light.home_huff_pool_color_lights_2
      - conditions:
          - condition: state
            entity_id: light.home_huff_pool_color_lights_2
            state: "on"
          - condition: state
            entity_id: input_boolean.colorlogic_light
            state: "on"
        sequence:
          - service: omnilogic.set_v2_lights
            data:
              entity_id: light.home_huff_pool_color_lights_2
              speed: "{{ states('input_number.colorlogic_speed') }}"
              brightness: "{{ states('input_number.colorlogic_brightness') }}"
          - service: light.turn_on
            data:
              effect: >-
                {{ states('input_select.colorlogic_show') | upper | replace(' ',
                '_') }}
            target:
              entity_id: light.home_huff_pool_color_lights_2
      - conditions:
          - condition: state
            entity_id: light.home_huff_pool_color_lights_2
            state: "on"
          - condition: state
            entity_id: input_boolean.colorlogic_light
            state: "off"
        sequence:
          - service: light.turn_off
            data: {}
            target:
              entity_id: light.home_huff_pool_color_lights_2
mode: single

Automation 2) Keep state of light and toggle in sync

alias: Pool - Ensure Pool Lights helper toggle button matches light state
description: >-
  Ensures if the light is turned off with the Hayward app that the boolean
  toggle reflects the state of the actual light and stays in sync.
trigger:
  - platform: state
    entity_id:
      - light.home_huff_pool_color_lights_2
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: light.home_huff_pool_color_lights_2
            state: "off"
        sequence:
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.colorlogic_light
      - conditions:
          - condition: state
            entity_id: light.home_huff_pool_color_lights_2
            state: "on"
        sequence:
          - service: input_boolean.turn_on
            data: {}
            target:
              entity_id: input_boolean.colorlogic_light
mode: single

Step 6) Create a nice all in one dashboard experience

Here's the code to my card setup for all of the above configurations, and it works really nice.

      - square: false
        type: grid
        cards:
          - show_name: true
            show_icon: true
            type: button
            tap_action:
              action: toggle
            entity: input_boolean.colorlogic_light
            name: Pool Lights
            show_state: true
          - type: entities
            entities:
              - entity: input_number.colorlogic_brightness
                name: Brightness
              - entity: input_number.colorlogic_speed
                name: Speed
              - entity: input_select.colorlogic_show
                name: Light Show
            state_color: true
            show_header_toggle: true
        columns: 2

Again, this is what you will end up with:
image

@soupman98
Copy link

Is all this still necessary or has the integration gotten better ?

@ahuffman
Copy link
Author

None of it is "necessary" unless you want a nice dashboard for your lights. This was an example on how to achieve that.

@soupman98
Copy link

soupman98 commented Jul 31, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants