-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
229 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
roles/homeassistant/files/config/blueprints/automation/run_script_at.yaml
This file was deleted.
Oops, something went wrong.
90 changes: 0 additions & 90 deletions
90
roles/homeassistant/files/config/helper/input_datetime.yaml
This file was deleted.
Oops, something went wrong.
140 changes: 140 additions & 0 deletions
140
roles/homeassistant/files/config/python_scripts/control_lights.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
"""Control lights.""" | ||
hass = hass # noqa: F821 | ||
data = data # noqa: F821 | ||
logger = logger # noqa: F821 | ||
|
||
ACTION_ON = "on" | ||
ACTION_DIM = "dim" | ||
ACTION_OFF = "off" | ||
|
||
|
||
def light_on(entity_id): | ||
"""Turn on a light.""" | ||
hass.services.call( | ||
"light", | ||
"turn_on", | ||
{ | ||
"entity_id": entity_id, | ||
"brightness_pct": 80, | ||
"color_temp": 454, | ||
"transition": 10, | ||
}, | ||
False, | ||
) | ||
|
||
|
||
def light_dim(entity_id): | ||
"""Dim a light.""" | ||
hass.services.call( | ||
"light", | ||
"turn_on", | ||
{ | ||
"entity_id": entity_id, | ||
"brightness_pct": 10, | ||
"color_temp": 454, | ||
"transition": 10, | ||
}, | ||
False, | ||
) | ||
|
||
|
||
def light_off(entity_id): | ||
"""Turn off a light.""" | ||
hass.services.call( | ||
"light", | ||
"turn_off", | ||
{ | ||
"entity_id": entity_id, | ||
"transition": 10, | ||
}, | ||
False, | ||
) | ||
|
||
|
||
def switch_on(entity_id): | ||
"""Turn on a switch.""" | ||
hass.services.call( | ||
"switch", | ||
"turn_on", | ||
{ | ||
"entity_id": entity_id, | ||
}, | ||
False, | ||
) | ||
|
||
|
||
def switch_dim(entity_id): | ||
"""Dim a switch.""" | ||
pass | ||
|
||
|
||
def switch_off(entity_id): | ||
"""Turn off a switch.""" | ||
hass.services.call( | ||
"switch", | ||
"turn_off", | ||
{ | ||
"entity_id": entity_id, | ||
}, | ||
False, | ||
) | ||
|
||
|
||
on_control = { | ||
"light": light_on, | ||
"switch": switch_on, | ||
} | ||
|
||
dim_control = { | ||
"light": light_dim, | ||
"switch": switch_dim, | ||
} | ||
|
||
off_control = { | ||
"light": light_off, | ||
"switch": switch_off, | ||
} | ||
|
||
|
||
lights = { | ||
"master_bedroom": [ | ||
"light.tradfri_bulb_0", | ||
], | ||
"guest_room": [ | ||
"switch.shelly_plug_s_0", | ||
], | ||
"kitchen": [ | ||
"switch.tradfri_control_outlet_1", | ||
# "switch.osram_smart_plug_1", # Seems broken? | ||
], | ||
"living_room": [ | ||
"switch.osram_smart_plug_0", | ||
"switch.tradfri_control_outlet_0", | ||
"switch.shelly_plug_s_1", | ||
], | ||
"laundry": [ | ||
"light.tradfri_bulb_2", | ||
], | ||
"closet": [ | ||
"light.bulb_rgbw_8b5534", | ||
], | ||
"kids_bedroom": [ | ||
"switch.tradfri_control_outlet_2", | ||
"switch.tradfri_control_outlet_3", | ||
], | ||
} | ||
|
||
# Get script arguments | ||
area = data.get("area") | ||
action = data.get("action") | ||
|
||
# Perform action on each entity id | ||
entity_ids = lights[area] | ||
for entity_id in entity_ids: | ||
entity_type = entity_id.split(".")[0] | ||
if action == ACTION_ON: | ||
on_control[entity_type](entity_id) | ||
elif action == ACTION_DIM: | ||
dim_control[entity_type](entity_id) | ||
elif action == ACTION_OFF: | ||
off_control[entity_type](entity_id) |
19 changes: 0 additions & 19 deletions
19
roles/homeassistant/files/config/script/lights_bedroom.yaml
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
roles/homeassistant/files/config/script/lights_closet.yaml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.