From 86acd96e07b030cec4e4758c44eb8edb7c67a4d6 Mon Sep 17 00:00:00 2001 From: mjallen18 Date: Thu, 5 Mar 2026 16:01:07 -0600 Subject: [PATCH] hasp --- .../services/homeassistant/default.nix | 416 +++++++++++++++++- 1 file changed, 413 insertions(+), 3 deletions(-) diff --git a/modules/nixos/homeassistant/services/homeassistant/default.nix b/modules/nixos/homeassistant/services/homeassistant/default.nix index c14c773..9fb0bea 100644 --- a/modules/nixos/homeassistant/services/homeassistant/default.nix +++ b/modules/nixos/homeassistant/services/homeassistant/default.nix @@ -354,7 +354,7 @@ in # -- Living Room Lights --- { - obj = "p1b11"; # Toggle button + obj = "p1b11"; # Toggle button — short press toggles, long press opens color picker properties = { val = ''{{ 1 if is_state("light.living_room_lights", "on") else 0 }}''; text = ''{{ "\uE6E8" if is_state("light.living_room_lights", "on") else "\uE335" | e }}''; @@ -367,6 +367,14 @@ in entity_id = "light.living_room_lights"; }; }; + long = { + action = "openhasp.command"; + data = { + node = "plate"; + command = "page"; + parameters = "4"; + }; + }; }; } { @@ -400,7 +408,7 @@ in } # -- Bedroom Lights --- { - obj = "p1b21"; # Toggle button + obj = "p1b21"; # Toggle button — short press toggles, long press opens color picker properties = { val = ''{{ 1 if is_state("light.bedroom_lights", "on") else 0 }}''; text = ''{{ "\uE6E8" if is_state("light.bedroom_lights", "on") else "\uE335" | e }}''; @@ -413,6 +421,14 @@ in entity_id = "light.bedroom_lights"; }; }; + long = { + action = "openhasp.command"; + data = { + node = "plate"; + command = "page"; + parameters = "5"; + }; + }; }; } { @@ -446,7 +462,7 @@ in } # -- Front Closet Lights --- { - obj = "p1b31"; # Toggle button + obj = "p1b31"; # Toggle button — short press toggles, long press opens color picker properties = { val = ''{{ 1 if is_state("light.front_closet_lights", "on") else 0 }}''; text = ''{{ "\uE6E8" if is_state("light.front_closet_lights", "on") else "\uE335" | e }}''; @@ -459,6 +475,400 @@ in entity_id = "light.front_closet_lights"; }; }; + long = { + action = "openhasp.command"; + data = { + node = "plate"; + command = "page"; + parameters = "6"; + }; + }; + }; + } + + # ----------------------------------------------------------------------- + # PAGE 3 LIGHT COLOR TEMPERATURE + # ----------------------------------------------------------------------- + + # -- Living Room color temp -- + { + obj = "p3b11"; # Toggle button (mirrors p1b11) + properties = { + val = ''{{ 1 if is_state("light.living_room_lights", "on") else 0 }}''; + text = ''{{ "\uE6E8" if is_state("light.living_room_lights", "on") else "\uE335" }}''; + text_color = ''{{ "#FFD700" if is_state("light.living_room_lights", "on") else "#666666" }}''; + }; + event = { + down = { + action = "homeassistant.toggle"; + target = { + entity_id = "light.living_room_lights"; + }; + }; + }; + } + { + obj = "p3b15"; # Color temp slider (153=cool, 500=warm mireds) + properties = { + val = '' + {{ state_attr('light.living_room_lights', 'color_temp') | int(default=250) + if state_attr('light.living_room_lights', 'color_temp') != None else 250 }}''; + click = "{{ 'false' if is_state('light.living_room_lights', 'off') else 'true' }}"; + }; + event = { + changed = { + action = "light.turn_on"; + data = { + color_temp = "{{ val }}"; + }; + target = { + entity_id = "light.living_room_lights"; + }; + }; + up = { + action = "light.turn_on"; + data = { + color_temp = "{{ val }}"; + }; + target = { + entity_id = "light.living_room_lights"; + }; + }; + }; + } + + # -- Bedroom color temp -- + { + obj = "p3b21"; # Toggle button (mirrors p1b21) + properties = { + val = ''{{ 1 if is_state("light.bedroom_lights", "on") else 0 }}''; + text = ''{{ "\uE6E8" if is_state("light.bedroom_lights", "on") else "\uE335" }}''; + text_color = ''{{ "#FFD700" if is_state("light.bedroom_lights", "on") else "#666666" }}''; + }; + event = { + down = { + action = "homeassistant.toggle"; + target = { + entity_id = "light.bedroom_lights"; + }; + }; + }; + } + { + obj = "p3b25"; # Color temp slider + properties = { + val = '' + {{ state_attr('light.bedroom_lights', 'color_temp') | int(default=250) + if state_attr('light.bedroom_lights', 'color_temp') != None else 250 }}''; + click = "{{ 'false' if is_state('light.bedroom_lights', 'off') else 'true' }}"; + }; + event = { + changed = { + action = "light.turn_on"; + data = { + color_temp = "{{ val }}"; + }; + target = { + entity_id = "light.bedroom_lights"; + }; + }; + up = { + action = "light.turn_on"; + data = { + color_temp = "{{ val }}"; + }; + target = { + entity_id = "light.bedroom_lights"; + }; + }; + }; + } + + # -- Front Closet color temp -- + { + obj = "p3b31"; # Toggle button (mirrors p1b31) + properties = { + val = ''{{ 1 if is_state("light.front_closet_lights", "on") else 0 }}''; + text = ''{{ "\uE6E8" if is_state("light.front_closet_lights", "on") else "\uE335" }}''; + text_color = ''{{ "#FFD700" if is_state("light.front_closet_lights", "on") else "#666666" }}''; + }; + event = { + down = { + action = "homeassistant.toggle"; + target = { + entity_id = "light.front_closet_lights"; + }; + }; + }; + } + { + obj = "p3b35"; # Color temp slider + properties = { + val = '' + {{ state_attr('light.front_closet_lights', 'color_temp') | int(default=250) + if state_attr('light.front_closet_lights', 'color_temp') != None else 250 }}''; + click = "{{ 'false' if is_state('light.front_closet_lights', 'off') else 'true' }}"; + }; + event = { + changed = { + action = "light.turn_on"; + data = { + color_temp = "{{ val }}"; + }; + target = { + entity_id = "light.front_closet_lights"; + }; + }; + up = { + action = "light.turn_on"; + data = { + color_temp = "{{ val }}"; + }; + target = { + entity_id = "light.front_closet_lights"; + }; + }; + }; + } + + # ----------------------------------------------------------------------- + # PAGES 4/5/6 RGB COLOR PICKERS (long-press from page 1 buttons) + # ----------------------------------------------------------------------- + + # -- Page 4: Living Room RGB -- + { + obj = "p4b11"; # Brightness slider (vertical) + properties = { + val = '' + {{ state_attr('light.living_room_lights', 'brightness') | int(default=128) + if state_attr('light.living_room_lights', 'brightness') != None else 128 }}''; + }; + event = { + changed = { + action = "light.turn_on"; + data = { + brightness = "{{ val }}"; + }; + target = { + entity_id = "light.living_room_lights"; + }; + }; + up = { + action = "light.turn_on"; + data = { + brightness = "{{ val }}"; + }; + target = { + entity_id = "light.living_room_lights"; + }; + }; + }; + } + { + obj = "p4b12"; # Color picker + properties = { + color = '' + {% if is_state('light.living_room_lights', 'on') %} + {% set rgb = state_attr('light.living_room_lights', 'rgb_color') %} + {% if rgb %}{{ "#%02x%02x%02x" | format(rgb[0], rgb[1], rgb[2]) }}{% endif %} + {% endif %}''; + }; + event = { + up = { + action = "light.turn_on"; + data = { + rgb_color = "[{{ r }},{{ g }},{{ b }}]"; + }; + target = { + entity_id = "light.living_room_lights"; + }; + }; + }; + } + { + obj = "p4b13"; # Color temp slider + properties = { + val = '' + {{ state_attr('light.living_room_lights', 'color_temp') | int(default=250) + if state_attr('light.living_room_lights', 'color_temp') != None else 250 }}''; + }; + event = { + changed = { + action = "light.turn_on"; + data = { + color_temp = "{{ val }}"; + }; + target = { + entity_id = "light.living_room_lights"; + }; + }; + up = { + action = "light.turn_on"; + data = { + color_temp = "{{ val }}"; + }; + target = { + entity_id = "light.living_room_lights"; + }; + }; + }; + } + + # -- Page 5: Bedroom RGB -- + { + obj = "p5b11"; # Brightness slider (vertical) + properties = { + val = '' + {{ state_attr('light.bedroom_lights', 'brightness') | int(default=128) + if state_attr('light.bedroom_lights', 'brightness') != None else 128 }}''; + }; + event = { + changed = { + action = "light.turn_on"; + data = { + brightness = "{{ val }}"; + }; + target = { + entity_id = "light.bedroom_lights"; + }; + }; + up = { + action = "light.turn_on"; + data = { + brightness = "{{ val }}"; + }; + target = { + entity_id = "light.bedroom_lights"; + }; + }; + }; + } + { + obj = "p5b12"; # Color picker + properties = { + color = '' + {% if is_state('light.bedroom_lights', 'on') %} + {% set rgb = state_attr('light.bedroom_lights', 'rgb_color') %} + {% if rgb %}{{ "#%02x%02x%02x" | format(rgb[0], rgb[1], rgb[2]) }}{% endif %} + {% endif %}''; + }; + event = { + up = { + action = "light.turn_on"; + data = { + rgb_color = "[{{ r }},{{ g }},{{ b }}]"; + }; + target = { + entity_id = "light.bedroom_lights"; + }; + }; + }; + } + { + obj = "p5b13"; # Color temp slider + properties = { + val = '' + {{ state_attr('light.bedroom_lights', 'color_temp') | int(default=250) + if state_attr('light.bedroom_lights', 'color_temp') != None else 250 }}''; + }; + event = { + changed = { + action = "light.turn_on"; + data = { + color_temp = "{{ val }}"; + }; + target = { + entity_id = "light.bedroom_lights"; + }; + }; + up = { + action = "light.turn_on"; + data = { + color_temp = "{{ val }}"; + }; + target = { + entity_id = "light.bedroom_lights"; + }; + }; + }; + } + + # -- Page 6: Front Closet RGB -- + { + obj = "p6b11"; # Brightness slider (vertical) + properties = { + val = '' + {{ state_attr('light.front_closet_lights', 'brightness') | int(default=128) + if state_attr('light.front_closet_lights', 'brightness') != None else 128 }}''; + }; + event = { + changed = { + action = "light.turn_on"; + data = { + brightness = "{{ val }}"; + }; + target = { + entity_id = "light.front_closet_lights"; + }; + }; + up = { + action = "light.turn_on"; + data = { + brightness = "{{ val }}"; + }; + target = { + entity_id = "light.front_closet_lights"; + }; + }; + }; + } + { + obj = "p6b12"; # Color picker + properties = { + color = '' + {% if is_state('light.front_closet_lights', 'on') %} + {% set rgb = state_attr('light.front_closet_lights', 'rgb_color') %} + {% if rgb %}{{ "#%02x%02x%02x" | format(rgb[0], rgb[1], rgb[2]) }}{% endif %} + {% endif %}''; + }; + event = { + up = { + action = "light.turn_on"; + data = { + rgb_color = "[{{ r }},{{ g }},{{ b }}]"; + }; + target = { + entity_id = "light.front_closet_lights"; + }; + }; + }; + } + { + obj = "p6b13"; # Color temp slider + properties = { + val = '' + {{ state_attr('light.front_closet_lights', 'color_temp') | int(default=250) + if state_attr('light.front_closet_lights', 'color_temp') != None else 250 }}''; + }; + event = { + changed = { + action = "light.turn_on"; + data = { + color_temp = "{{ val }}"; + }; + target = { + entity_id = "light.front_closet_lights"; + }; + }; + up = { + action = "light.turn_on"; + data = { + color_temp = "{{ val }}"; + }; + target = { + entity_id = "light.front_closet_lights"; + }; + }; }; }