Added lighting automations to areas and updated README.md
40
README.md
@@ -539,10 +539,10 @@ I'm going to explain each part of the presence detection system in detail includ
|
||||
|
||||
<tr>
|
||||
<td align="center" style="width:50%;">
|
||||
Raspberry Pi Zero W
|
||||
6x Raspberry Pi Zero W
|
||||
</td>
|
||||
<td align="center" style="width:50%;">
|
||||
Nut Mini
|
||||
2x Nut Mini
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1286,7 +1286,7 @@ At the end of all this we should now have for each person a device tracker that
|
||||
<table align="center" border="0">
|
||||
|
||||
<tr><td align="center" colspan="1">
|
||||
Samsung Galaxy S20
|
||||
2x Samsung Galaxy S20
|
||||
</td></tr>
|
||||
|
||||
<tr><td align="center" colspan="1">
|
||||
@@ -1752,10 +1752,10 @@ Aeotec Z-Stick Gen 5
|
||||
<img src="git-pictures/device_pictures/pi_3.jpg" raw=true height="250" alt="Pi 3"/>
|
||||
</td>
|
||||
<td align="center" style="width:33%;">
|
||||
<img src="git-pictures/device_pictures/conbee.jpg" raw=true height="250" alt="ConBee" />
|
||||
<img src="git-pictures/device_pictures/conbee_stick.jpg" raw=true height="250" alt="ConBee" />
|
||||
</td>
|
||||
<td align="center" style="width:34%;">
|
||||
<img src="git-pictures/device_pictures/aeotec-stick.jpg" raw=true height="250" alt="Philips Hue" />
|
||||
<img src="git-pictures/device_pictures/aeotec_stick.jpg" raw=true height="250" alt="Philips Hue" />
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
@@ -1949,24 +1949,42 @@ The web interface can also be used to change device specific configuration such
|
||||
### Hardware used
|
||||
<table align="center" border="0">
|
||||
<tr>
|
||||
<td align="center" style="width:50%;">
|
||||
<td align="center" style="width:20%;">
|
||||
Philips Hue Bulbs (8x Color E27, 3x White Ambiance GU10, 1x LED strip 5m)
|
||||
</td>
|
||||
<td align="center" style="width:50%;">
|
||||
IKEA Tradfri Plug
|
||||
<td align="center" style="width:20%;">
|
||||
1x IKEA Tradfri Plug
|
||||
</td>
|
||||
<td align="center" style="width:20%;">
|
||||
1x Philips Hue Motion Sensor
|
||||
</td>
|
||||
<td align="center" style="width:20%;">
|
||||
4x Aeotec Multisensor 6
|
||||
</td>
|
||||
<td align="center" style="width:20%;">
|
||||
1x Xiaomi Lux Sensor
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="center" style="width:50%;">
|
||||
<td align="center" style="width:20%;">
|
||||
<img src="git-pictures/device_pictures/philips_hue.jpg" raw=true height="250" alt="Philips Hue" />
|
||||
</td>
|
||||
<td align="center" style="width:50%;">
|
||||
<td align="center" style="width:20%;">
|
||||
<img src="git-pictures/device_pictures/ikea_plug.jpg" raw=true height="250" alt="IKEA Plug" />
|
||||
</td>
|
||||
<td align="center" style="width:20%;">
|
||||
<img src="git-pictures/device_pictures/hue_motion.jpg" raw=true height="250" alt="Hue Motion" />
|
||||
</td>
|
||||
<td align="center" style="width:20%;">
|
||||
<img src="git-pictures/device_pictures/aeotec_multi.jpg" raw=true height="250" alt="Aeotec Multisensor" />
|
||||
</td>
|
||||
<td align="center" style="width:20%;">
|
||||
<img src="git-pictures/device_pictures/xiaomi_lux.jpg" raw=true height="250" alt="Xiaomi Lux" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td colspan="2">
|
||||
<tr><td colspan="5">
|
||||
The Hue bulbs are distributed in the different rooms of our apartment and on the balcony is a light strip attached to an IKEA Tradfri Smart Plug.
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
@@ -100,6 +100,7 @@ class Area(AppBase):
|
||||
area_attr = self.adbase.get_state(area, attribute="attributes")
|
||||
occupancy = area_attr["occupancy"]
|
||||
# Check if persons in area
|
||||
persons = len(area_attr["persons"]) > 0
|
||||
# persons = len(area_attr["persons"]) > 0
|
||||
persons = False
|
||||
return persons or any(value == True for key, value in occupancy.items())
|
||||
|
||||
|
||||
@@ -4,4 +4,21 @@ bedroom:
|
||||
area: bedroom
|
||||
attributes:
|
||||
friendly_name: Schlafzimmer
|
||||
priority: 1
|
||||
# occupancy_entities:
|
||||
# - binary_sensor.bed_sabrina: "on"
|
||||
# - binary_sensor.bed_dimitri: "on"
|
||||
priority: 1
|
||||
|
||||
bedroom_lights:
|
||||
module: XXXXXXlighting
|
||||
class: AreaLighting
|
||||
area: bedroom
|
||||
motion_sensors: binary_sensor.motion_bedroom
|
||||
delay_off: 600
|
||||
lights_rgb: light.bedroom_ceiling
|
||||
sleep_lights_ct: light.bedroom_bed
|
||||
sleep_brightness: 10
|
||||
circadian_sensor: sensor.circadian_values
|
||||
min_colortemp: 2000
|
||||
max_colortemp: 6500
|
||||
update_interval: 900
|
||||
@@ -4,4 +4,16 @@ dressroom:
|
||||
area: dressroom
|
||||
attributes:
|
||||
friendly_name: Ankleidezimmer
|
||||
priority: 1
|
||||
priority: 1
|
||||
|
||||
dressroom_lights:
|
||||
module: XXXXXXlighting
|
||||
class: AreaLighting
|
||||
area: dressroom
|
||||
motion_sensors: binary_sensor.motion_dressroom
|
||||
delay_off: 300
|
||||
lights_rgb: light.dressroom
|
||||
circadian_sensor: sensor.circadian_values
|
||||
min_colortemp: 2000
|
||||
max_colortemp: 6500
|
||||
update_interval: 900
|
||||
@@ -33,9 +33,6 @@ class AreaLighting(AppBase):
|
||||
vol.Optional("sleep_brightness"): vol.All(
|
||||
vol.Coerce(int), vol.Range(min=1, max=100)
|
||||
),
|
||||
vol.Optional("sleep_colortemp"): vol.All(
|
||||
vol.Coerce(int), vol.Range(min=1000, max=10000)
|
||||
),
|
||||
vol.Optional("circadian_sensor"): cv.entity_id,
|
||||
vol.Optional("min_brightness", default=1): vol.All(
|
||||
vol.Coerce(int), vol.Range(min=1, max=100)
|
||||
@@ -72,7 +69,6 @@ class AreaLighting(AppBase):
|
||||
self.sleep_lights = self.args.get("sleep_lights")
|
||||
self.sleep_lights_ct = self.args.get("sleep_lights_ct")
|
||||
self.sleep_brightness = self.args.get("sleep_brightness")
|
||||
self.sleep_colortemp = self.args.get("sleep_colortemp")
|
||||
self.circadian_sensor = self.args.get("circadian_sensor")
|
||||
self.min_brightness = self.args.get("min_brightness")
|
||||
self.max_brightness = self.args.get("max_brightness")
|
||||
@@ -124,30 +120,31 @@ class AreaLighting(AppBase):
|
||||
# Set motion state of room to True
|
||||
self.set_area_motion(True)
|
||||
|
||||
# Start timer to turn motion state to False
|
||||
# Start/Restart timer to turn motion state to False
|
||||
self.restart_motion_timer()
|
||||
|
||||
def on_light_change(
|
||||
self, entity: str, attribute: str, old: str, new: str, kwargs: dict
|
||||
) -> None:
|
||||
"""Respond when light changes state."""
|
||||
if new == "on":
|
||||
if "circadian_timer" in self.handles:
|
||||
self.adbase.cancel_timer(self.handles["circadian_timer"])
|
||||
self.handles.pop("circadian_timer")
|
||||
self.handles["circadian_timer"] = self.adbase.run_every(
|
||||
self.turn_lights_on,
|
||||
f"now+{self.update_interval}",
|
||||
self.update_interval,
|
||||
transition=self.transition,
|
||||
)
|
||||
else:
|
||||
if "motion_timer" in self.handles:
|
||||
self.adbase.cancel_timer(self.handles["motion_timer"])
|
||||
self.handles.pop("motion_timer")
|
||||
if "circadian_timer" in self.handles:
|
||||
self.adbase.cancel_timer(self.handles["circadian_timer"])
|
||||
self.handles.pop("circadian_timer")
|
||||
if new != old:
|
||||
if new == "on":
|
||||
if "circadian_timer" in self.handles:
|
||||
self.adbase.cancel_timer(self.handles["circadian_timer"])
|
||||
self.handles.pop("circadian_timer")
|
||||
self.handles["circadian_timer"] = self.adbase.run_every(
|
||||
self.turn_lights_on,
|
||||
f"now+{self.update_interval}",
|
||||
self.update_interval,
|
||||
transition=self.transition,
|
||||
)
|
||||
elif new == "off":
|
||||
if "motion_timer" in self.handles:
|
||||
self.adbase.cancel_timer(self.handles["motion_timer"])
|
||||
self.handles.pop("motion_timer")
|
||||
if "circadian_timer" in self.handles:
|
||||
self.adbase.cancel_timer(self.handles["circadian_timer"])
|
||||
self.handles.pop("circadian_timer")
|
||||
|
||||
def on_occupancy_change(
|
||||
self, entity: str, attribute: str, old: str, new: str, kwargs: dict
|
||||
@@ -224,7 +221,7 @@ class AreaLighting(AppBase):
|
||||
|
||||
def calc_brightness_pct(self) -> float:
|
||||
"""Calculate brightness percentage."""
|
||||
if self.is_sleep():
|
||||
if self.is_sleep() and self.sleep_brightness:
|
||||
return self.sleep_brightness
|
||||
else:
|
||||
if self.circadian_sensor:
|
||||
@@ -240,9 +237,7 @@ class AreaLighting(AppBase):
|
||||
return self.default_brightness
|
||||
|
||||
def calc_colortemp(self, brightness_pct: float) -> float:
|
||||
if self.is_sleep():
|
||||
return self.sleep_colortemp
|
||||
elif brightness_pct > 0:
|
||||
if brightness_pct > 0:
|
||||
return (
|
||||
(self.max_colortemp - self.min_colortemp) * (brightness_pct / 100)
|
||||
) + self.min_colortemp
|
||||
|
||||
@@ -4,4 +4,16 @@ livingroom:
|
||||
area: livingroom
|
||||
attributes:
|
||||
friendly_name: Wohnzimmer
|
||||
priority: 1
|
||||
# occupancy_entities:
|
||||
# - media_player.receiver_livingroom: "on"
|
||||
priority: 1
|
||||
|
||||
livingroom_lights:
|
||||
module: XXXXXXlighting
|
||||
class: AreaLighting
|
||||
area: livingroom
|
||||
motion_sensors: binary_sensor.motion_livingroom
|
||||
delay_off: 600
|
||||
lights_rgb: light.livingroom
|
||||
min_colortemp: 2000
|
||||
max_colortemp: 6500
|
||||
|
||||
@@ -5,7 +5,9 @@ office:
|
||||
attributes:
|
||||
friendly_name: Büro
|
||||
# occupancy_entities:
|
||||
# light.bedroom: "on"
|
||||
# - device_tracker.desktop_dimitri: "home"
|
||||
# - device_tracker.desktop_sabrina: "home"
|
||||
# - media_player.receiver_office: "on"
|
||||
priority: 1
|
||||
|
||||
office_lights:
|
||||
|
||||
@@ -5,4 +5,5 @@ sleep_app:
|
||||
sensors:
|
||||
dimitri: input_boolean.bed_dimitri
|
||||
sabrina: input_boolean.bed_sabrina
|
||||
|
||||
# dimitri: binary_sensor.bed_dimitri
|
||||
# sabrina: binary_sensor.bed_sabrina
|
||||
|
||||
BIN
git-pictures/device_pictures/aeotec_multi.jpg
Executable file
|
After Width: | Height: | Size: 24 KiB |
0
git-pictures/device_pictures/aeotec-stick.jpg → git-pictures/device_pictures/aeotec_stick.jpg
Normal file → Executable file
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.6 KiB |
0
git-pictures/device_pictures/conbee.jpg → git-pictures/device_pictures/conbee_stick.jpg
Normal file → Executable file
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
BIN
git-pictures/device_pictures/hue_motion.jpg
Executable file
|
After Width: | Height: | Size: 94 KiB |
BIN
git-pictures/device_pictures/xiaomi_lux.jpg
Executable file
|
After Width: | Height: | Size: 9.1 KiB |
@@ -23,11 +23,21 @@ homeassistant:
|
||||
friendly_name: Dimitri
|
||||
entity_picture: /local/person_pictures/dimitri_home.jpg
|
||||
icon: mdi:account
|
||||
## Phone
|
||||
sensor.battery_level_phone_dimitri:
|
||||
friendly_name: Handy Dimitri
|
||||
sensor.charging_phone_dimitri:
|
||||
friendly_name: Handy Dimitri
|
||||
friendly_name: Ladestatus Handy Dimitri
|
||||
icon: mdi:cellphone-charging
|
||||
sensor.next_alarm_phone_dimitri:
|
||||
friendly_name: Nächster Wecker Dimitri
|
||||
icon: mdi:alarm
|
||||
sensor.call_state_phone_dimitri:
|
||||
friendly_name: Anruf Dimitri
|
||||
icon: mdi:phone
|
||||
sensor.wifi_connection_phone_dimitri:
|
||||
friendly_name: WiFi Handy Dimitri
|
||||
## Presence
|
||||
device_tracker.gps_presence_dimitri:
|
||||
friendly_name: Standort Dimitri
|
||||
icon: mdi:map-marker
|
||||
|
||||