djtimca / haomnilogic

Hayward Omnilogic integration for Home Assistant available through HACS
Apache License 2.0
17 stars 6 forks source link

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

Open ahuffman opened 1 year ago

ahuffman commented 1 year ago

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 commented 2 months ago

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

ahuffman commented 2 months ago

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

soupman98 commented 2 months ago

I guess by necessary I meant it hadn't been baked in more and still needs the relatively heavy customzation done.


From: Andrew J. Huffman @.> Sent: Tuesday, July 30, 2024 5:51 PM To: djtimca/haomnilogic @.> Cc: Steve Campbell @.>; Comment @.> Subject: Re: [djtimca/haomnilogic] Wanted to share some ColorLogic light tips to the Wiki but don't know how (Issue #52)

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

— Reply to this email directly, view it on GitHubhttps://github.com/djtimca/haomnilogic/issues/52#issuecomment-2259331923, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADUPRMICL544RMJEKCQUP4DZPAKGHAVCNFSM6AAAAABLXGMB66VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJZGMZTCOJSGM. You are receiving this because you commented.Message ID: @.***>