mirror of
https://github.com/GeorgeSG/sarah.git
synced 2026-05-07 17:34:42 +00:00
Workaround Tuya lag by using Tuya scenes
This commit is contained in:
@@ -13,8 +13,8 @@ cards:
|
|||||||
cards:
|
cards:
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: small
|
template: small
|
||||||
entity: light.all_lights
|
entity: light.ceiling_lights
|
||||||
name: All
|
name: Ceiling
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: small
|
template: small
|
||||||
entity: light.living_room_main_lights
|
entity: light.living_room_main_lights
|
||||||
@@ -25,13 +25,13 @@ cards:
|
|||||||
name: Bedroom
|
name: Bedroom
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: small
|
template: small
|
||||||
entity: light.hallway_main_lights
|
entity: light.tuya_hallway_main_lights
|
||||||
name: Hallway
|
name: Hallway
|
||||||
- type: horizontal-stack
|
- type: horizontal-stack
|
||||||
cards:
|
cards:
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: small
|
template: small
|
||||||
entity: light.kitchen_main_lights
|
entity: light.tuya_kitchen_main_lights
|
||||||
name: Kitchen
|
name: Kitchen
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: small
|
template: small
|
||||||
@@ -42,7 +42,7 @@ cards:
|
|||||||
name: Bedside
|
name: Bedside
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: small
|
template: small
|
||||||
entity: light.hallway_entrance_lights
|
entity: light.tuya_hallway_entrance_lights
|
||||||
name: Entrance
|
name: Entrance
|
||||||
|
|
||||||
- type: entities
|
- type: entities
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ cards:
|
|||||||
show_header_toggle: false
|
show_header_toggle: false
|
||||||
entities:
|
entities:
|
||||||
- type: custom:fold-entity-row
|
- type: custom:fold-entity-row
|
||||||
entity: light.kitchen_main_lights
|
entity: light.tuya_kitchen_main_lights
|
||||||
name: Main lights
|
name: Main lights
|
||||||
entities:
|
entities:
|
||||||
- light.light_le_11
|
- light.light_le_11
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ cards:
|
|||||||
title: Lights
|
title: Lights
|
||||||
show_header_toggle: false
|
show_header_toggle: false
|
||||||
entities:
|
entities:
|
||||||
- light.hallway_all_lights
|
- light.tuya_hallway_all_lights
|
||||||
|
- light.tuya_hallway_entrance_light
|
||||||
|
- light.tuya_hallway_main_lights
|
||||||
- type: custom:fold-entity-row
|
- type: custom:fold-entity-row
|
||||||
entity: light.hallway_entrance_lights
|
entity: light.hallway_entrance_lights
|
||||||
name: Entrance lights
|
name: Entrance lights
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ cards:
|
|||||||
title: Living room
|
title: Living room
|
||||||
icon: mdi:sofa
|
icon: mdi:sofa
|
||||||
entities:
|
entities:
|
||||||
|
- light.tuya_living_room_main_lights
|
||||||
|
- type: divider
|
||||||
- light.living_room_all_lights
|
- light.living_room_all_lights
|
||||||
- light.living_room_main_lights
|
- light.living_room_main_lights
|
||||||
- light.light_lohas_1
|
- light.light_lohas_1
|
||||||
@@ -32,6 +34,8 @@ cards:
|
|||||||
title: Kitchen
|
title: Kitchen
|
||||||
icon: mdi:chef-hat
|
icon: mdi:chef-hat
|
||||||
entities:
|
entities:
|
||||||
|
- light.tuya_kitchen_main_lights
|
||||||
|
- type: divider
|
||||||
- light.kitchen_main_lights
|
- light.kitchen_main_lights
|
||||||
- light.light_le_11
|
- light.light_le_11
|
||||||
- light.light_le_12
|
- light.light_le_12
|
||||||
@@ -41,6 +45,10 @@ cards:
|
|||||||
title: Hallway
|
title: Hallway
|
||||||
icon: mdi:door-closed
|
icon: mdi:door-closed
|
||||||
entities:
|
entities:
|
||||||
|
- light.tuya_hallway_all_lights
|
||||||
|
- light.tuya_hallway_main_lights
|
||||||
|
- light.tuya_hallway_entrance_lights
|
||||||
|
- type: divider
|
||||||
- light.hallway_all_lights
|
- light.hallway_all_lights
|
||||||
- light.hallway_main_lights
|
- light.hallway_main_lights
|
||||||
- light.hallway_entrance_lights
|
- light.hallway_entrance_lights
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
light:
|
light:
|
||||||
|
# Used only to set correct initial state of tuya_living_room_main_lights
|
||||||
|
- platform: group
|
||||||
|
name: Living room tuya lights
|
||||||
|
entities:
|
||||||
|
- light.light_le_9
|
||||||
|
- light.light_le_10
|
||||||
|
|
||||||
- platform: group
|
- platform: group
|
||||||
name: Living room main lights
|
name: Living room main lights
|
||||||
entities:
|
entities:
|
||||||
- light.light_lohas_1
|
- light.light_lohas_1
|
||||||
- light.light_lohas_2
|
- light.light_lohas_2
|
||||||
- light.light_le_9
|
- light.tuya_living_room_main_lights
|
||||||
- light.light_le_10
|
|
||||||
|
|
||||||
- platform: group
|
- platform: group
|
||||||
name: Living room all lights
|
name: Living room all lights
|
||||||
@@ -52,18 +58,48 @@ light:
|
|||||||
- light.hallway_entrance_lights
|
- light.hallway_entrance_lights
|
||||||
- light.hallway_main_lights
|
- light.hallway_main_lights
|
||||||
|
|
||||||
|
- platform: group
|
||||||
|
name: Tuya Hallway all lights
|
||||||
|
entities:
|
||||||
|
- light.tuya_hallway_entrance_lights
|
||||||
|
- light.tuya_hallway_main_lights
|
||||||
|
|
||||||
- platform: group
|
- platform: group
|
||||||
name: Ceiling lights
|
name: Ceiling lights
|
||||||
entities:
|
entities:
|
||||||
- light.living_room_all_lights
|
- light.living_room_all_lights
|
||||||
- light.master_bedroom_main_lights
|
- light.master_bedroom_main_lights
|
||||||
- light.kitchen_main_lights
|
- light.tuya_kitchen_main_lights
|
||||||
- light.hallway_all_lights
|
- light.tuya_hallway_all_lights
|
||||||
|
|
||||||
- platform: group
|
- platform: group
|
||||||
name: All lights
|
name: All lights
|
||||||
entities:
|
entities:
|
||||||
- light.living_room_all_lights
|
- light.living_room_all_lights
|
||||||
- light.master_bedroom_all_lights
|
- light.master_bedroom_all_lights
|
||||||
- light.kitchen_main_lights
|
- light.tuya_kitchen_main_lights
|
||||||
- light.hallway_all_lights
|
- light.tuya_hallway_all_lights
|
||||||
|
|
||||||
|
|
||||||
|
homeassistant:
|
||||||
|
customize:
|
||||||
|
light.living_room_main_lights:
|
||||||
|
icon: mdi:vanity-light
|
||||||
|
light.living_room_all_lights:
|
||||||
|
icon: mdi:vanity-light
|
||||||
|
light.master_bedroom_main_lights:
|
||||||
|
icon: mdi:vanity-light
|
||||||
|
light.kitchen_main_lights:
|
||||||
|
icon: mdi:vanity-light
|
||||||
|
light.hallway_entrance_lights:
|
||||||
|
icon: mdi:vanity-light
|
||||||
|
light.hallway_main_lights:
|
||||||
|
icon: mdi:vanity-light
|
||||||
|
light.hallway_all_lights:
|
||||||
|
icon: mdi:vanity-light
|
||||||
|
light.tuya_hallway_all_lights:
|
||||||
|
icon: mdi:vanity-light
|
||||||
|
light.ceiling_lights:
|
||||||
|
icon: mdi:ceiling-light
|
||||||
|
light.pc:
|
||||||
|
icon: mdi:ceiling-light
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
# Tuya Light groups setup via scenes
|
||||||
|
# Credit: https://community.home-assistant.io/t/personal-setup-vps-vpn-faster-tuya-and-more/180995
|
||||||
|
|
||||||
|
# Tuya lights respond faster if they're grouped into scenes in the Tuya app.
|
||||||
|
# 1. Create ON and OFF scenes for every Tuya light group and sync them with Home Assistant.
|
||||||
|
# 2. Create an input_boolean marking each scene on/off.
|
||||||
|
# 3. Create template light acting as a group light for every input_boolean / tuya scene pair.
|
||||||
|
# 4. Automate ON/OFF when an input_boolean is toggled.
|
||||||
|
|
||||||
|
# Light groups in Tuya. Name: "tuya_{{scene_name}}_lights_state"
|
||||||
|
input_boolean:
|
||||||
|
tuya_living_room_main_lights_state:
|
||||||
|
tuya_kitchen_main_lights_state:
|
||||||
|
tuya_hallway_main_lights_state:
|
||||||
|
tuya_hallway_entrance_lights_state:
|
||||||
|
|
||||||
|
light:
|
||||||
|
- platform: template
|
||||||
|
lights:
|
||||||
|
tuya_living_room_main_lights:
|
||||||
|
friendly_name: Living room main lights (scene)
|
||||||
|
value_template: "{{ is_state('input_boolean.tuya_living_room_main_lights_state', 'on') }}"
|
||||||
|
icon_template: mdi:vanity-light
|
||||||
|
turn_on:
|
||||||
|
service: input_boolean.turn_on
|
||||||
|
data:
|
||||||
|
entity_id: input_boolean.tuya_living_room_main_lights_state
|
||||||
|
turn_off:
|
||||||
|
service: input_boolean.turn_off
|
||||||
|
data:
|
||||||
|
entity_id: input_boolean.tuya_living_room_main_lights_state
|
||||||
|
|
||||||
|
tuya_kitchen_main_lights:
|
||||||
|
friendly_name: Kitchen main lights (scene)
|
||||||
|
value_template: "{{ is_state('input_boolean.tuya_kitchen_main_lights_state', 'on') }}"
|
||||||
|
icon_template: mdi:vanity-light
|
||||||
|
turn_on:
|
||||||
|
service: input_boolean.turn_on
|
||||||
|
data:
|
||||||
|
entity_id: input_boolean.tuya_kitchen_main_lights_state
|
||||||
|
turn_off:
|
||||||
|
service: input_boolean.turn_off
|
||||||
|
data:
|
||||||
|
entity_id: input_boolean.tuya_kitchen_main_lights_state
|
||||||
|
|
||||||
|
tuya_hallway_main_lights:
|
||||||
|
friendly_name: Hallway main lights (scene)
|
||||||
|
value_template: "{{ is_state('input_boolean.tuya_hallway_main_lights_state', 'on') }}"
|
||||||
|
icon_template: mdi:vanity-light
|
||||||
|
turn_on:
|
||||||
|
service: input_boolean.turn_on
|
||||||
|
data:
|
||||||
|
entity_id: input_boolean.tuya_hallway_main_lights_state
|
||||||
|
turn_off:
|
||||||
|
service: input_boolean.turn_off
|
||||||
|
data:
|
||||||
|
entity_id: input_boolean.tuya_hallway_main_lights_state
|
||||||
|
|
||||||
|
tuya_hallway_entrance_lights:
|
||||||
|
friendly_name: Entrance lights (scene)
|
||||||
|
value_template: "{{ is_state('input_boolean.tuya_hallway_entrance_lights_state', 'on') }}"
|
||||||
|
icon_template: mdi:vanity-light
|
||||||
|
turn_on:
|
||||||
|
service: input_boolean.turn_on
|
||||||
|
data:
|
||||||
|
entity_id: input_boolean.tuya_hallway_entrance_lights_state
|
||||||
|
turn_off:
|
||||||
|
service: input_boolean.turn_off
|
||||||
|
data:
|
||||||
|
entity_id: input_boolean.tuya_hallway_entrance_lights_state
|
||||||
|
|
||||||
|
|
||||||
|
# Try to keep input_booleans consistent.
|
||||||
|
automation:
|
||||||
|
- alias: Lighting · Tuya · Update kitchen lights
|
||||||
|
trigger:
|
||||||
|
platform: state
|
||||||
|
entity_id:
|
||||||
|
- input_boolean.tuya_living_room_main_lights_state
|
||||||
|
- input_boolean.tuya_kitchen_main_lights_state
|
||||||
|
- input_boolean.tuya_hallway_main_lights_state
|
||||||
|
- input_boolean.tuya_hallway_entrance_lights_state
|
||||||
|
action:
|
||||||
|
- service: scene.turn_on
|
||||||
|
data_template:
|
||||||
|
entity_id: >
|
||||||
|
|
||||||
|
{% set scene_name = trigger.entity_id.split('tuya_')[1].split('_lights')[0] %}
|
||||||
|
{% set state = states(trigger.entity_id) %}
|
||||||
|
scene.tuya_{{ scene_name }}_{{ state }}
|
||||||
|
|
||||||
|
- alias: Lighting · Tuya · Update states on start
|
||||||
|
trigger:
|
||||||
|
platform: homeassistant
|
||||||
|
event: start
|
||||||
|
action:
|
||||||
|
- delay: 00:00:03
|
||||||
|
- service_template: "input_boolean.turn_{{ states('light.living_room_tuya_lights') }}"
|
||||||
|
data:
|
||||||
|
entity_id: input_boolean.tuya_living_room_main_lights_state
|
||||||
|
|
||||||
|
- service_template: "input_boolean.turn_{{ states('light.kitchen_main_lights') }}"
|
||||||
|
data:
|
||||||
|
entity_id: input_boolean.tuya_kitchen_main_lights_state
|
||||||
|
|
||||||
|
- service_template: "input_boolean.turn_{{ states('light.hallway_main_lights') }}"
|
||||||
|
data:
|
||||||
|
entity_id: input_boolean.tuya_hallway_main_lights_state
|
||||||
|
|
||||||
|
- service_template: "input_boolean.turn_{{ states('light.hallway_entrance_lights') }}"
|
||||||
|
data:
|
||||||
|
entity_id: input_boolean.tuya_hallway_entrance_lights_state
|
||||||
@@ -32,8 +32,8 @@ script:
|
|||||||
- service: light.turn_off
|
- service: light.turn_off
|
||||||
entity_id:
|
entity_id:
|
||||||
- light.living_room_all_lights
|
- light.living_room_all_lights
|
||||||
- light.hallway_all_lights
|
- light.tuya_hallway_all_lights
|
||||||
- light.kitchen_main_lights
|
- light.tuya_kitchen_main_lights
|
||||||
|
|
||||||
automation:
|
automation:
|
||||||
- alias: Routine · Bedtime · Toggle on bedside switch hold
|
- alias: Routine · Bedtime · Toggle on bedside switch hold
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ script:
|
|||||||
# Enter home mode.
|
# Enter home mode.
|
||||||
- service: script.security_camera_off
|
- service: script.security_camera_off
|
||||||
- service: light.turn_on
|
- service: light.turn_on
|
||||||
entity_id: light.hallway_entrance_lights
|
entity_id:
|
||||||
- service: light.turn_on
|
- light.tuya_hallway_entrance_lights
|
||||||
entity_id: light.hallway_main_lights
|
- light.tuya_hallway_main_lights
|
||||||
|
|
||||||
# TODO: Only if it's dark in the living room
|
# TODO: Only if it's dark in the living room
|
||||||
- service: light.turn_on
|
- service: light.turn_on
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ views:
|
|||||||
cards:
|
cards:
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: small
|
template: small
|
||||||
entity: light.all_lights
|
entity: light.ceiling_lights
|
||||||
name: All
|
name: Ceiling
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: small
|
template: small
|
||||||
entity: light.living_room_main_lights
|
entity: light.living_room_main_lights
|
||||||
@@ -36,13 +36,13 @@ views:
|
|||||||
name: Bedroom
|
name: Bedroom
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: small
|
template: small
|
||||||
entity: light.hallway_main_lights
|
entity: light.tuya_hallway_main_lights
|
||||||
name: Hallway
|
name: Hallway
|
||||||
- type: horizontal-stack
|
- type: horizontal-stack
|
||||||
cards:
|
cards:
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: small
|
template: small
|
||||||
entity: light.kitchen_main_lights
|
entity: light.tuya_kitchen_main_lights
|
||||||
name: Kitchen
|
name: Kitchen
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: small
|
template: small
|
||||||
@@ -53,7 +53,7 @@ views:
|
|||||||
name: Bedside
|
name: Bedside
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: small
|
template: small
|
||||||
entity: light.hallway_entrance_lights
|
entity: light.tuya_hallway_entrance_lights
|
||||||
name: Entrance
|
name: Entrance
|
||||||
|
|
||||||
- type: horizontal-stack
|
- type: horizontal-stack
|
||||||
|
|||||||
Reference in New Issue
Block a user