Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aneisch committed Sep 15, 2023
1 parent da78380 commit 260643c
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 66 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Build Status](https://github.com/aneisch/home-assistant-config/actions/workflows/check-ha-release-compatibility.yml/badge.svg)](https://github.com/aneisch/home-assistant-config/actions)
[![GitHub last commit](https://img.shields.io/github/last-commit/aneisch/home-assistant-config)](https://github.com/aneisch/home-assistant-config/commits/master)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/aneisch/home-assistant-config)](https://github.com/aneisch/home-assistant-config/graphs/commit-activity)
[![HA Version](https://img.shields.io/badge/Running%20Home%20Assistant-2023.9.1%20(Latest)-brightgreen)](https://github.com/home-assistant/home-assistant/releases/latest)
[![HA Version](https://img.shields.io/badge/Running%20Home%20Assistant-2023.9.2%20(Latest)-brightgreen)](https://github.com/home-assistant/home-assistant/releases/latest)
<br><a href="https://www.buymeacoffee.com/aneisch" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-black.png" width="150px" height="35px" alt="Buy Me A Coffee" style="height: 35px !important;width: 150px !important;" ></a>


Expand Down Expand Up @@ -57,16 +57,16 @@ Also using Grafana/Influx for graphing, both running in Docker containers on NUC
Description | value
-- | --
Lines of ESPHome YAML | 2467
Lines of Home Assistant YAML | 7799
[Integrations](https://www.home-assistant.io/integrations/) in use | 50
Lines of Home Assistant YAML | 7821
[Integrations](https://www.home-assistant.io/integrations/) in use | 51
Zigbee devices in [`zha`](https://www.home-assistant.io/integrations/zha/) | 26
Z-Wave devices in [`zwave_js`](https://www.home-assistant.io/integrations/zwave_js/) | 37

Description | value
-- | --
Entities in the [`alarm_control_panel`](https://www.home-assistant.io/components/alarm_control_panel) domain | 1
Entities in the [`automation`](https://www.home-assistant.io/components/automation) domain | 98
Entities in the [`binary_sensor`](https://www.home-assistant.io/components/binary_sensor) domain | 120
Entities in the [`automation`](https://www.home-assistant.io/components/automation) domain | 99
Entities in the [`binary_sensor`](https://www.home-assistant.io/components/binary_sensor) domain | 126
Entities in the [`button`](https://www.home-assistant.io/components/button) domain | 12
Entities in the [`calendar`](https://www.home-assistant.io/components/calendar) domain | 1
Entities in the [`camera`](https://www.home-assistant.io/components/camera) domain | 18
Expand All @@ -91,7 +91,7 @@ Entities in the [`remote`](https://www.home-assistant.io/components/remote) doma
Entities in the [`scene`](https://www.home-assistant.io/components/scene) domain | 2
Entities in the [`script`](https://www.home-assistant.io/components/script) domain | 39
Entities in the [`select`](https://www.home-assistant.io/components/select) domain | 2
Entities in the [`sensor`](https://www.home-assistant.io/components/sensor) domain | 370
Entities in the [`sensor`](https://www.home-assistant.io/components/sensor) domain | 377
Entities in the [`siren`](https://www.home-assistant.io/components/siren) domain | 1
Entities in the [`sun`](https://www.home-assistant.io/components/sun) domain | 1
Entities in the [`switch`](https://www.home-assistant.io/components/switch) domain | 151
Expand All @@ -101,7 +101,7 @@ Entities in the [`update`](https://www.home-assistant.io/components/update) doma
Entities in the [`vacuum`](https://www.home-assistant.io/components/vacuum) domain | 1
Entities in the [`weather`](https://www.home-assistant.io/components/weather) domain | 2
Entities in the [`zone`](https://www.home-assistant.io/components/zone) domain | 6
**Total state objects** | **1010**
**Total state objects** | **1024**
## The HACS integrations/plugins that I use:
**Appdaemon**:<br>
[aneisch/follow_me_appdaemon](https://github.com/aneisch/follow_me_appdaemon)<br>
Expand Down
50 changes: 0 additions & 50 deletions automations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -432,42 +432,6 @@
- service: homeassistant.turn_off
entity_id: switch.nexus_7_screen

- alias: "Water Sensor Alerts"
id: "water_sensor_alert"
trigger:
- platform: state
id: non_esphome
entity_id:
- binary_sensor.guest_bathroom_toilet_water_detector
- binary_sensor.back_bathroom_toilet_water_detector
- binary_sensor.kitchen_sink_water_detector
- binary_sensor.master_bathroom_water_detector
- binary_sensor.water_shutoff_water_leak_detected
to: "on"
- platform: state
id: esphome
entity_id:
- binary_sensor.laundry_room_water_detector
- binary_sensor.water_heater_water_detector
- binary_sensor.kitchen_water_detector
to: "on"
action:
- if: "{{ trigger.id == 'non_esphome' }}"
then:
- service: switch.turn_on
entity_id: switch.water_shutoff
- service: script.notify_wrapper
data:
message: "Water detected by {{ trigger.to_state.name }}. {% if trigger.id == 'non_esphome' %}Shutting off water!{% endif %}"
data:
priority: 2
# - service: notify.alexa_media
# data:
# message: "Water detected by {{ trigger.to_state.name }}. {% if trigger.id == 'non_esphome' %}Shutting off water!{% endif %}"
# data:
# method: all
# type: announce
# target: ["Office", "Kitchen", "Master", "Living Room"]

- alias: "Master Closet Light with Motion"
id: "closet_motion_light"
Expand Down Expand Up @@ -905,20 +869,6 @@
message: >
Turned coffee maker off!
- alias: "Water Shutoff Alert"
id: "water_shutoff_alert"
initial_state: on
trigger:
- platform: state
entity_id: switch.water_shutoff
to: "on"
action:
- service: script.notify_wrapper
data:
message: Water supply has been shut off!
data:
priority: 1

- alias: "Front Door NFC"
id: "front_door_nfc"
initial_state: on
Expand Down
1 change: 1 addition & 0 deletions configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ homeassistant:
smoke_alarms: !include packages/smoke_alarms.yaml
magic_cube: !include packages/magic_cube.yaml
irrigation: !include packages/irrigation.yaml
leak_detection: !include packages/leak_detection.yaml
reminders: !include packages/reminders.yaml
ups_monitoring: !include packages/ups_monitor.yaml
vacuum: !include packages/vacuum.yaml
Expand Down
35 changes: 26 additions & 9 deletions custom_components/dahua/vto.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class DahuaVTOClient(asyncio.Protocol):
lock_status: {}
auth: HTTPDigestAuth
data_handlers: {}
buffer: bytearray

def __init__(self, host: str, username: str, password: str, is_ssl: bool, on_receive_vto_event):
self.dahua_details = {}
Expand All @@ -71,6 +72,7 @@ def __init__(self, host: str, username: str, password: str, is_ssl: bool, on_rec
self.hold_time = 0
self.lock_status = {}
self.data_handlers = {}
self.buffer = bytearray()

# This is the hook back into HA
self.on_receive_vto_event = on_receive_vto_event
Expand All @@ -90,17 +92,26 @@ def connection_made(self, transport):

def data_received(self, data):
_LOGGER.debug(f"Event data {self.host}: '{data}'")
try:
messages = self.parse_response(data)
for message in messages:
message_id = message.get("id")

handler: Callable = self.data_handlers.get(message_id, self.handle_default)
handler(message)
except Exception as ex:
exc_type, exc_obj, exc_tb = sys.exc_info()
self.buffer += data

_LOGGER.error(f"Failed to handle message, error: {ex}, Line: {exc_tb.tb_lineno}")
while b'\n' in self.buffer:

newline_index = self.buffer.find(b'\n') + 1
packet = self.buffer[:newline_index]
self.buffer = self.buffer[newline_index:]

try:
messages = self.parse_response(packet)
for message in messages:
message_id = message.get("id")

handler: Callable = self.data_handlers.get(message_id, self.handle_default)
handler(message)
except Exception as ex:
exc_type, exc_obj, exc_tb = sys.exc_info()

_LOGGER.error(f"Failed to handle message, error: {ex}, Line: {exc_tb.tb_lineno}")

def handle_notify_event_stream(self, params):
try:
Expand Down Expand Up @@ -326,6 +337,12 @@ def keep_alive(self):
def handle_keep_alive(message):
Timer(self.keep_alive_interval, self.keep_alive).start()

message_id = message.get('id')
if message_id is not None and message_id in self.data_handlers:
del self.data_handlers[message_id]
else:
_LOGGER.warning(f'Could not delete keep alive handler with message ID {message_id}.')

request_data = {
"timeout": self.keep_alive_interval,
"action": True
Expand Down
1 change: 1 addition & 0 deletions extras/appdaemon/apps/apps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ Cameras Smallgroup:
module: entity_timer
class: Timer
constrain_presence: anyone
constrain_days: wed
time_off: "17:50:00"
time_on: "21:00:00"
entities: switch.driveway_detect,switch.front_door_detect
Expand Down
73 changes: 73 additions & 0 deletions packages/leak_detection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
template:
- binary_sensor:
- name: "Flume Flow Status"
state: >-
{{ states('sensor.flume_sensor_home_current') != "0" }}
automation:
- alias: "Water Flow Alert"
id: "water_flow_alert"
trigger:
- platform: state
entity_id: binary_sensor.flume_flow_status
from: "off"
to: "on"
# irrigation master off AND trackers away AND guest mode off
condition: "{{ is_state('switch.irrigation_master_valve', 'off') and is_state('group.trackers', 'not_home' ) and is_state('input_boolean.guest_mode', 'off') }}"
action:
- service: script.notify_wrapper
data:
message: Unexpected water flow!
data:
priority: 1

- alias: "Water Shutoff Alert"
id: "water_shutoff_alert"
initial_state: on
trigger:
- platform: state
entity_id: switch.water_shutoff
to: "on"
action:
- service: script.notify_wrapper
data:
message: Water supply has been shut off!
data:
priority: 1

- alias: "Water Sensor Alerts"
id: "water_sensor_alert"
trigger:
- platform: state
id: non_esphome
entity_id:
- binary_sensor.guest_bathroom_toilet_water_detector
- binary_sensor.back_bathroom_toilet_water_detector
- binary_sensor.kitchen_sink_water_detector
- binary_sensor.master_bathroom_water_detector
- binary_sensor.water_shutoff_water_leak_detected
to: "on"
- platform: state
id: esphome
entity_id:
- binary_sensor.laundry_room_water_detector
- binary_sensor.water_heater_water_detector
- binary_sensor.kitchen_water_detector
to: "on"
action:
- if: "{{ trigger.id == 'non_esphome' }}"
then:
- service: switch.turn_on
entity_id: switch.water_shutoff
- service: script.notify_wrapper
data:
message: "Water detected by {{ trigger.to_state.name }}. {% if trigger.id == 'non_esphome' %}Shutting off water!{% endif %}"
data:
priority: 2
# - service: notify.alexa_media
# data:
# message: "Water detected by {{ trigger.to_state.name }}. {% if trigger.id == 'non_esphome' %}Shutting off water!{% endif %}"
# data:
# method: all
# type: announce
# target: ["Office", "Kitchen", "Master", "Living Room"]

0 comments on commit 260643c

Please sign in to comment.