diff --git a/configuration.yaml b/configuration.yaml index ad712ff..8f17db1 100644 --- a/configuration.yaml +++ b/configuration.yaml @@ -16,14 +16,14 @@ homeassistant: packages: !include_dir_named packages allowlist_external_dirs: - - "/home/homeassistant/.homeassistant/www/downloads/camera/patio/" - - "/home/homeassistant/.homeassistant/www/downloads/camera/garage/" - - "/home/homeassistant/.homeassistant/www/downloads/camera/playarea/" - - "/home/homeassistant/.homeassistant/www/downloads/camera/driveway/" - - "/home/homeassistant/.homeassistant/www/downloads/camera/frontdoor/" - - "/home/homeassistant/.homeassistant/www/downloads/camera/kitchen/" - - "/home/homeassistant/.homeassistant/www/downloads/camera/frontroom/" - - "/home/homeassistant/.homeassistant/www/downloads/camera/3dprinter/" + - /home/homeassistant/.homeassistant/www/downloads/camera/patio/ + - /home/homeassistant/.homeassistant/www/downloads/camera/garage/ + - /home/homeassistant/.homeassistant/www/downloads/camera/playarea/ + - /home/homeassistant/.homeassistant/www/downloads/camera/driveway/ + - /home/homeassistant/.homeassistant/www/downloads/camera/frontdoor/ + - /home/homeassistant/.homeassistant/www/downloads/camera/kitchen/ + - /home/homeassistant/.homeassistant/www/downloads/camera/frontroom/ + - /home/homeassistant/.homeassistant/www/downloads/camera/3dprinter/ sun: alexa: @@ -32,8 +32,6 @@ discovery: ignore: - homekit -# shopping_list: - octoprint: host: !secret octoprint_ip api_key: !secret octoprint_key @@ -50,33 +48,15 @@ homekit: include_entities: - binary_sensor.door_window_sensor_158d00040ad8fc # Back Door - binary_sensor.door_window_sensor_158d000424a6d6 # Front Door - - binary_sensor.door_window_sensor_158d0004248d5b - - binary_sensor.door_window_sensor_158d0004231f7b + - binary_sensor.door_window_sensor_158d0004248d5b # Single Car Garage + - binary_sensor.door_window_sensor_158d0004231f7b # Double Car Garage mobile_app: -# map: -# updater: -# logbook: -# history: -# recorder: -# db_url: !secret my_sql_url -# influxdb: -# host: 192.168.1.125 -# include: -# entities: -# - sensor.dining_room_thermostat_temperature -# - sensor.downstairs_multi_sensor_temperature -# - sensor.front_room_multi_sensor_temperature -# - sensor.guest_bedroom_multi_sensor_temperature -# - sensor.tv_multi_sensor_temperature - websocket_api: python_script: logger: !include logging.yaml - zeroconf: -#owntracks: system_health: life360: @@ -123,63 +103,4 @@ emulated_hue: - light - switch - input_boolean - -panel_iframe: - front_room_ha: - title: Front Room HA - icon: mdi:home-assistant - url: !secret front_room_ha_url - tv_room_ha: - title: TV Room HA - icon: mdi:home-assistant - url: !secret tv_room_ha_url - snapcast_server: - title: Snapcast Server - icon: mdi:music - url: !secret snapcast_server_url - -ios: - push: - categories: - - name: Single Car Garage Door - identifier: "1CAR_GARAGE" - actions: - - identifier: "1CAR_GARAGE_CLOSE" - title: "Close Garage Door" - activationMode: "background" - authenticationRequired: yes - destructive: yes - behavior: "default" - - name: Two Car Garage Door - identifier: "2CAR_GARAGE" - actions: - - identifier: "2CAR_GARAGE_CLOSE" - title: "Close Garage Door" - activationMode: "background" - authenticationRequired: yes - destructive: yes - behavior: "default" - - name: Trash Recycle - identifier: "trash_recycle" - actions: - - identifier: "TRASH_LEFT" - title: "Done" - activationMode: "background" - authenticationRequired: yes - destructive: yes - behavior: "default" - - identifier: "TRASH_REMIND_LATER" - title: "Remind Later" - activationMode: "background" - authenticationRequired: yes - destructive: yes - behavior: "default" - - name: Welcome Home - identifier: "welcome_home" - actions: - - identifier: "DISABLE_SECURITY" - title: "Yes" - activationMode: "background" - authenticationRequired: yes - destructive: yes - behavior: "default" + - group diff --git a/custom_components/octoprint/__init__.py b/custom_components/octoprint/__init__.py index 734f609..17b07c3 100644 --- a/custom_components/octoprint/__init__.py +++ b/custom_components/octoprint/__init__.py @@ -18,9 +18,9 @@ from homeassistant.const import ( CONF_SENSORS, CONF_SSL, CONTENT_TYPE_JSON, + PERCENTAGE, TEMP_CELSIUS, TIME_SECONDS, - UNIT_PERCENTAGE, ) from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv @@ -76,7 +76,7 @@ SENSOR_TYPES = { "job", "progress", "completion", - UNIT_PERCENTAGE, + PERCENTAGE, "mdi:file-percent", ], "Time Remaining": [ @@ -146,9 +146,10 @@ def setup(hass, config): for printer in config[DOMAIN]: name = printer[CONF_NAME] - ssl = "s" if printer[CONF_SSL] else "" - base_url = "http{}://{}:{}{}api/".format( - ssl, printer[CONF_HOST], printer[CONF_PORT], printer[CONF_PATH] + protocol = "https" if printer[CONF_SSL] else "http" + base_url = ( + f"{protocol}://{printer[CONF_HOST]}:{printer[CONF_PORT]}" + f"{printer[CONF_PATH]}api/" ) api_key = printer[CONF_API_KEY] number_of_tools = printer[CONF_NUMBER_OF_TOOLS] @@ -230,7 +231,6 @@ class OctoPrintAPI: return self.printer_last_reading[0] url = self.api_url + endpoint - try: response = requests.get(url, headers=self.headers, timeout=9) response.raise_for_status() diff --git a/custom_components/octoprint/binary_sensor.py b/custom_components/octoprint/binary_sensor.py index a866319..4c0209b 100644 --- a/custom_components/octoprint/binary_sensor.py +++ b/custom_components/octoprint/binary_sensor.py @@ -3,7 +3,7 @@ import logging import requests -from homeassistant.components.binary_sensor import BinarySensorDevice +from homeassistant.components.binary_sensor import BinarySensorEntity from . import BINARY_SENSOR_TYPES, DOMAIN as COMPONENT_DOMAIN @@ -36,7 +36,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices, True) -class OctoPrintBinarySensor(BinarySensorDevice): +class OctoPrintBinarySensor(BinarySensorEntity): """Representation an OctoPrint binary sensor.""" def __init__( diff --git a/custom_components/octoprint/sensor.py b/custom_components/octoprint/sensor.py index 337ed8e..7b31d70 100644 --- a/custom_components/octoprint/sensor.py +++ b/custom_components/octoprint/sensor.py @@ -3,7 +3,7 @@ import logging import requests -from homeassistant.const import TEMP_CELSIUS, UNIT_PERCENTAGE +from homeassistant.const import PERCENTAGE, TEMP_CELSIUS from homeassistant.helpers.entity import Entity from . import DOMAIN as COMPONENT_DOMAIN, SENSOR_TYPES @@ -32,7 +32,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): "If you do not want to have your printer on
" " at all times, and you would like to monitor
" "temperatures, please add
" - "bed and/or number_of_tools to your configuration
" + "bed and/or number_of_tools to your configuration
" "and restart.", title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID, @@ -91,7 +91,7 @@ class OctoPrintSensor(Entity): if tool is None: self._name = f"{sensor_name} {condition}" else: - self._name = "{} {} {} {}".format(sensor_name, condition, tool, "temp") + self._name = f"{sensor_name} {condition} {tool} temp" self.sensor_type = sensor_type self.api = api self._state = None @@ -111,7 +111,7 @@ class OctoPrintSensor(Entity): def state(self): """Return the state of the sensor.""" sensor_unit = self.unit_of_measurement - if sensor_unit in (TEMP_CELSIUS, UNIT_PERCENTAGE): + if sensor_unit in (TEMP_CELSIUS, PERCENTAGE): # API sometimes returns null and not 0 if self._state is None: self._state = 0 diff --git a/logging.yaml b/logging.yaml index e86ed04..1263f40 100644 --- a/logging.yaml +++ b/logging.yaml @@ -20,7 +20,6 @@ logs: homeassistant.components.wemo: critical homeassistant.components.sensor: critical homeassistant.components.cloud.iot: warning - homeassistant.components.hue: critical homeassistant.components.http: warning homeassistant.components.camera: warning homeassistant.components.zwave: warning diff --git a/lovelace/12_automations_view.yaml b/lovelace/12_automations_view.yaml index 46a74fb..4c1e89b 100644 --- a/lovelace/12_automations_view.yaml +++ b/lovelace/12_automations_view.yaml @@ -132,7 +132,6 @@ cards: - automation.home_security_system_watchdog_10_minutes - automation.home_security_system_watchdog_30_minutes - automation.notify_home_security_status_change - - automation.night_homesecurity_on - automation.turn_on_thermostat_upon_reaching_home - type: conditional @@ -178,12 +177,10 @@ cards: entities: - automation.reset_trash_reminders - automation.restore_trash_recycle_settings_on_startup - - automation.trash_and_recycle_bin_left_outside_already - automation.trash_and_recycle_pickup_reminder - automation.trash_pickup_day_changed - automation.recycle_pickup_day_changed - automation.recycle_pickup_week_changed - - automation.remind_later - type: entities title: Camera Automations diff --git a/packages/cameras.yaml b/packages/cameras.yaml index 4a09876..af026ff 100644 --- a/packages/cameras.yaml +++ b/packages/cameras.yaml @@ -108,7 +108,6 @@ binary_sensor: image_processing: - platform: tensorflow scan_interval: 10000 - # confidence: 75 source: - entity_id: camera.frontdoor_camera - entity_id: camera.driveway_camera @@ -121,11 +120,6 @@ image_processing: - "/home/homeassistant/.homeassistant/www/downloads/camera/{{- camera_entity.split('.')[1].split('_')[0] -}}/{{ camera_entity.split('.')[1].split('_')[0] }}_{{ now().strftime('%Y%m%d_%H%M%S') }}.jpg" model: graph: /home/homeassistant/.homeassistant/tensorflow/models/efficientdet_d0_coco17_tpu-32/ - # graph: /home/homeassistant/.homeassistant/tensorflow/frozen_inference_graph.pb - # categories: - # - person - # - car - # - truck input_label: current_stream: @@ -214,7 +208,7 @@ automation: action: - condition: template value_template: "{{ states('input_boolean.notify_camera_alerts') == 'on' }}" - - service: script.frontdoor_cam + - service: script.frontdoor_cam # change to front door camera stream on chromecast - condition: template value_template: "{{ states('alarm_control_panel.home') == 'armed_home' or states('alarm_control_panel.home') == 'armed_away' }}" - service: image_processing.scan @@ -234,6 +228,7 @@ automation: {% else %} false {% endif %} + - service: script.voice_notify data_template: message: >- @@ -247,6 +242,7 @@ automation: {{ " detected in the front yard." }} {%- endif -%} greeting: "no" + - service: notify.notify_smtp data_template: title: 'Front door motion {{ now().strftime("%d %h %Y, %I:%M:%S %p") }}' @@ -260,11 +256,30 @@ automation: {%- endfor -%} {{ " detected in the front yard on " ~ now().strftime("%d %h %Y, at %I:%M:%S %p") ~ ". Please see the images below." }} {% else %} - Motion detected in the front door on {{ now().strftime("%d %h %Y, at %I:%M:%S %p") }}. Please see the images below. + Motion detected at the front door on {{ now().strftime("%d %h %Y, at %I:%M:%S %p") }}. Please see the images below. {%- endif -%} data: images: - "/home/homeassistant/.homeassistant/www/downloads/camera/frontdoor/frontdoor_latest.jpg" + + - service: script.notify_me_with_picture + data_template: + title: "Front Door Motion" + message: > + {%- set e_id = "image_processing.tensorflow_frontdoor_camera" -%} + {%- if state_attr(e_id, 'summary') -%} + {%- set count = state_attr(e_id, 'summary') | count -%} + {%- for x in state_attr(e_id, 'summary') | list -%} + {%- if loop.first %}{% elif loop.last %}, and {% else %}, {% endif -%} + {{- state_attr(e_id, 'summary')[x]}} {{ x ~ 's' if state_attr(e_id, 'summary')[x] > 1 else x }} + {%- endfor -%} + {{ " detected in the front yard on " ~ now().strftime("%d %h %Y, at %I:%M:%S %p") ~ ". Please see the images below." }} + {% else %} + Motion detected at the front door on {{ now().strftime("%d %h %Y, at %I:%M:%S %p") }}. Please see the images below. + {%- endif %} + file: "/home/homeassistant/.homeassistant/www/downloads/camera/frontdoor/frontdoor_latest.jpg" + caption: "Front Door Motion" + - condition: template value_template: > {% if states('binary_sensor.door_window_sensor_158d0004248d5b') == "on" or @@ -313,6 +328,7 @@ automation: {% else %} false {% endif %} + - service: script.voice_notify data_template: message: >- @@ -325,6 +341,25 @@ automation: {%- endfor -%} {{ " detected in the driveway" }} {%- endif -%} + + - service: script.notify_me_with_picture + data_template: + title: "Driveway Motion" + message: > + {%- set e_id = "image_processing.tensorflow_driveway_camera" -%} + {%- if state_attr(e_id, 'summary') -%} + {%- set count = state_attr(e_id, 'summary') | count -%} + {%- for x in state_attr(e_id, 'summary') | list -%} + {%- if loop.first %}{% elif loop.last %}, and {% else %}, {% endif -%} + {{- state_attr(e_id, 'summary')[x]}} {{ x ~ 's' if state_attr(e_id, 'summary')[x] > 1 else x }} + {%- endfor -%} + {{ " detected in the driveway on " ~ now().strftime("%d %h %Y, at %I:%M:%S %p") ~ ". Please see the images below." }} + {% else %} + Motion detected at the driveway on {{ now().strftime("%d %h %Y, at %I:%M:%S %p") }}. Please see the images below. + {%- endif -%} + file: "/home/homeassistant/.homeassistant/www/downloads/camera/driveway/driveway_latest.jpg" + caption: "Driveway Motion" + - service: notify.notify_smtp data_template: title: 'Driveway motion {{ now().strftime("%d %h %Y, %I:%M:%S %p") }}' @@ -343,6 +378,7 @@ automation: data: images: - "/home/homeassistant/.homeassistant/www/downloads/camera/driveway/driveway_latest.jpg" + - condition: template value_template: > {% if states('binary_sensor.door_window_sensor_158d0004248d5b') == "on" or @@ -351,6 +387,7 @@ automation: {% else %} False {% endif %} + - service: image_processing.scan data_template: entity_id: image_processing.tensorflow_garage_camera @@ -400,6 +437,7 @@ automation: {% else %} false {% endif %} + - service: script.voice_notify data_template: message: >- @@ -412,6 +450,25 @@ automation: {%- endfor -%} {{ " detected in the garage." }} {%- endif -%} + + - service: script.notify_me_with_picture + data_template: + title: "Garage Motion" + message: > + {%- set e_id = "image_processing.tensorflow_garage_camera" -%} + {%- if state_attr(e_id, 'summary') -%} + {%- set count = state_attr(e_id, 'summary') | count -%} + {%- for x in state_attr(e_id, 'summary') | list -%} + {%- if loop.first %}{% elif loop.last %}, and {% else %}, {% endif -%} + {{- state_attr(e_id, 'summary')[x]}} {{ x ~ 's' if state_attr(e_id, 'summary')[x] > 1 else x }} + {%- endfor -%} + {{ " detected in the garage on " ~ now().strftime("%d %h %Y, at %I:%M:%S %p") ~ ". Please see the images below." }} + {% else %} + Motion detected in the garage on {{ now().strftime("%d %h %Y, at %I:%M:%S %p") }}. Please see the images below. + {%- endif -%} + file: "/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_latest.jpg" + caption: "Garage Motion" + - service: notify.notify_smtp data_template: title: 'Garage motion {{ now().strftime("%d %h %Y, %I:%M:%S %p") }}' @@ -466,6 +523,7 @@ automation: {% else %} false {% endif %} + - service: script.voice_notify data_template: message: >- @@ -478,6 +536,25 @@ automation: {%- endfor -%} {{ " detected in the backyard." }} {%- endif -%} + + - service: script.notify_me_with_picture + data_template: + title: "Backyardge Motion" + message: > + {%- set e_id = "image_processing.tensorflow_patio_camera" -%} + {%- if state_attr(e_id, 'summary') -%} + {%- set count = state_attr(e_id, 'summary') | count -%} + {%- for x in state_attr(e_id, 'summary') | list -%} + {%- if loop.first %}{% elif loop.last %}, and {% else %}, {% endif -%} + {{- state_attr(e_id, 'summary')[x]}} {{ x ~ 's' if state_attr(e_id, 'summary')[x] > 1 else x }} + {%- endfor -%} + {{ " detected in the backyard on " ~ now().strftime("%d %h %Y, at %I:%M:%S %p") ~ ". Please see the images below." }} + {% else %} + Motion detected in the backyard on {{ now().strftime("%d %h %Y, at %I:%M:%S %p") }}. Please see the images below. + {%- endif -%} + file: "/home/homeassistant/.homeassistant/www/downloads/camera/patio/patio_latest.jpg" + caption: "Backyard Motion" + - service: notify.notify_smtp data_template: title: 'Backyard motion {{ now().strftime("%d %h %Y, %I:%M:%S %p") }}' @@ -566,6 +643,26 @@ automation: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~ (states.binary_sensor.motion_sensor_158d00024ee084.last_updated ~ '').replace('-','_') .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + + - service: notify.telegram + data_template: + title: "Front Door Motion" + message: "Motion Detected At Front Door, Check images:" + data: + photo: + - file: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/frontdoor/frontdoor_' ~ + (states.binary_sensor.motion_sensor_158d00024ee084.last_updated ~ '').replace('-','_') + .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + caption: "Front Door" + - file: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/driveway/driveway_' ~ + (states.binary_sensor.motion_sensor_158d00024ee084.last_updated ~ '').replace('-','_') + .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + caption: "Driveway" + - file: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~ + (states.binary_sensor.motion_sensor_158d00024ee084.last_updated ~ '').replace('-','_') + .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + caption: "Garage" + - service: notify.notify_smtp data_template: title: 'Front door motion {{ now().strftime("%d %h %Y, %I:%M:%S %p") }}' @@ -581,8 +678,10 @@ automation: - "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~ (states.binary_sensor.motion_sensor_158d00024ee084.last_updated ~ '').replace('-','_') .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + - condition: template value_template: "{{ states('device_tracker.life360_suresh') == 'home' }}" + - service: notify.ios_devices data_template: message: "Check Front Door camera!" @@ -636,6 +735,26 @@ automation: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~ (states.binary_sensor.motion_sensor_158d00024e57fb.last_updated ~ '').replace('-','_') .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + + - service: notify.telegram + data_template: + title: "Driveway Motion" + message: "Motion Detected At Driveway, Check images:" + data: + photo: + - file: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/frontdoor/frontdoor_' ~ + (states.binary_sensor.motion_sensor_158d00024e57fb.last_updated ~ '').replace('-','_') + .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + caption: "Front Door" + - file: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/driveway/driveway_' ~ + (states.binary_sensor.motion_sensor_158d00024e57fb.last_updated ~ '').replace('-','_') + .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + caption: "Driveway" + - file: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~ + (states.binary_sensor.motion_sensor_158d00024e57fb.last_updated ~ '').replace('-','_') + .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + caption: "Garage" + - service: notify.notify_smtp data_template: title: 'Driveway motion {{ now().strftime("%d %h %Y, %I:%M:%S %p") }}' @@ -651,6 +770,7 @@ automation: - "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~ (states.binary_sensor.motion_sensor_158d00024e57fb.last_updated ~ '').replace('-','_') .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + - condition: template value_template: "{{ states('device_tracker.life360_suresh') == 'home' }}" - service: notify.ios_devices @@ -696,6 +816,7 @@ automation: {% else %} false {% endif %} + - service: camera.snapshot data_template: entity_id: "camera.patio_camera" @@ -703,6 +824,7 @@ automation: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/patio/patio_' ~ (states.binary_sensor.motion_sensor_158d00024e842c.last_updated ~ '').replace('-','_') .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + - service: camera.snapshot data_template: entity_id: "camera.playarea_camera" @@ -710,6 +832,22 @@ automation: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/playarea/playarea_' ~ (states.binary_sensor.motion_sensor_158d00024e842c.last_updated ~ '').replace('-','_') .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + + - service: notify.telegram + data_template: + title: "Backyard Motion" + message: "Motion Detected in the Backyard, Check images:" + data: + photo: + - file: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/patio/patio_' ~ + (states.binary_sensor.motion_sensor_158d00024e842c.last_updated ~ '').replace('-','_') + .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + caption: "Patio" + - file: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/playarea/playarea_' ~ + (states.binary_sensor.motion_sensor_158d00024e842c.last_updated ~ '').replace('-','_') + .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + caption: "Playarea" + - service: notify.notify_smtp data_template: title: 'Backyard motion {{ now().strftime("%d %h %Y, %I:%M:%S %p") }}' @@ -722,6 +860,7 @@ automation: - "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/playarea/playarea_' ~ (states.binary_sensor.motion_sensor_158d00024e842c.last_updated ~ '').replace('-','_') .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + - condition: template value_template: "{{ states('device_tracker.life360_suresh') == 'home' }}" - service: notify.ios_devices diff --git a/packages/door_sensors.yaml b/packages/door_sensors.yaml index 4f52641..191a10d 100644 --- a/packages/door_sensors.yaml +++ b/packages/door_sensors.yaml @@ -144,8 +144,8 @@ automation: trigger: platform: state entity_id: - - binary_sensor.door_window_sensor_158d0004231f7b - - binary_sensor.door_window_sensor_158d0004248d5b + - binary_sensor.door_window_sensor_158d0004231f7b # 2 Car Garage + - binary_sensor.door_window_sensor_158d0004248d5b # Single car garage condition: - condition: template value_template: "{{ trigger.from_state.state != trigger.to_state.state }}" @@ -178,39 +178,59 @@ automation: entity_id: "camera.garage_camera" filename: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~ - (states.automation.notify_garage_door_status.last_triggered ~ '').replace('-','_') - .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + ((state_attr('automation.notify_garage_door_status', 'last_triggered') |string).replace('-','_') + .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg') }}" + + - service: script.notify_me_with_picture + data_template: + title: 'Garage Door Status {{ now().strftime("%d %h %Y, %I:%M:%S %p") }}' + message: >- + {%- set doors = "" -%} + {%- if states('binary_sensor.door_window_sensor_158d0004231f7b') == "on" and + states('binary_sensor.door_window_sensor_158d0004248d5b') == "on" -%} + {% set doors = "Both Garage Doors are OPEN" -%} + {%- elif states('binary_sensor.door_window_sensor_158d0004231f7b') == "off" and + states('binary_sensor.door_window_sensor_158d0004248d5b') == "off" -%} + {% set doors = "Both Garage Doors are CLOSED" -%} + {%- else -%} + {% set doors = states.binary_sensor.door_window_sensor_158d0004248d5b.name ~ " is " ~ + ('Closed' if states('binary_sensor.door_window_sensor_158d0004248d5b') == 'off' else 'OPEN') + ~ " and " ~ state_attr('binary_sensor.door_window_sensor_158d0004231f7b', 'friendly_name') ~ " is " ~ + ('Closed' if states('binary_sensor.door_window_sensor_158d0004231f7b') == 'off' else 'OPEN') %} + {%- endif %} + Your {{doors}} on {{ now().strftime("%d %h %Y, at %I:%M:%S %p") }}. Please check the garage snapshot below. + file: > + {{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~ + ((state_attr('automation.notify_garage_door_status', 'last_triggered') |string).replace('-','_') + .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg') }} + caption: "{{ trigger.to_state.attributes.friendly_name }}: {{ 'OPEN' if trigger.to_state.state == 'on' else 'CLOSED' }}" + - service: notify.notify_smtp data_template: title: 'Garage Door Status {{ now().strftime("%d %h %Y, %I:%M:%S %p") }}' message: >- - {% set doors = "" %} - {% if states('binary_sensor.door_window_sensor_158d0004231f7b') == "on" and - states('binary_sensor.door_window_sensor_158d0004248d5b') == "on" %} - {% set doors = "Both Garage Doors are OPEN" %} - {% elif states('binary_sensor.door_window_sensor_158d0004231f7b') == "off" and - states('binary_sensor.door_window_sensor_158d0004248d5b') == "off" %} - {% set doors = "Both Garage Doors are CLOSED" %} - {% else %} - {% set doors = states.binary_sensor.door_window_sensor_158d0004248d5b.name ~ " is " ~ + {%- set doors = "" -%} + {%- if states('binary_sensor.door_window_sensor_158d0004231f7b') == "on" and + states('binary_sensor.door_window_sensor_158d0004248d5b') == "on" -%} + {%- set doors = "Both Garage Doors are OPEN" -%} + {%- elif states('binary_sensor.door_window_sensor_158d0004231f7b') == "off" and + states('binary_sensor.door_window_sensor_158d0004248d5b') == "off" -%} + {%- set doors = "Both Garage Doors are CLOSED" -%} + {%- else -%} + {%- set doors = states.binary_sensor.door_window_sensor_158d0004248d5b.name ~ " is " ~ ('Closed' if states('binary_sensor.door_window_sensor_158d0004248d5b') == 'off' else 'OPEN') ~ " and " ~ state_attr('binary_sensor.door_window_sensor_158d0004231f7b', 'friendly_name') ~ " is " ~ - ('Closed' if states('binary_sensor.door_window_sensor_158d0004231f7b') == 'off' else 'OPEN') %} - {% endif %} + ('Closed' if states('binary_sensor.door_window_sensor_158d0004231f7b') == 'off' else 'OPEN') -%} + {%- endif -%} Your {{doors}} on {{ now().strftime("%d %h %Y, at %I:%M:%S %p") }}. Please check the garage snapshot below. data: images: - "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~ - (states.automation.notify_garage_door_status.last_triggered ~ '').replace('-','_') - .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" - - service_template: > - {% if trigger.to_state.state | lower == "on" %} - switch.turn_on - {% else %} - switch.turn_off - {% endif%} - data: - entity_id: switch.garage + ((state_attr('automation.notify_garage_door_status', 'last_triggered') |string).replace('-','_') + .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg') }}" + + - service_template: "switch.turn_{{- trigger.to_state.state }}" + entity_id: switch.garage # Notify Entry Door Status ############################################################################### diff --git a/packages/emergency.yaml b/packages/emergency.yaml deleted file mode 100644 index b84a4c3..0000000 --- a/packages/emergency.yaml +++ /dev/null @@ -1,288 +0,0 @@ -# ############################################################################### -# # @author : Mahasri Kalavala -# # @date : 11/22/2017 -# # @package : Emergency Stuff -# # @description : When $hit hapens, this package gets called! -# # -# # In case of emergency - turn on the emergency_mode (input boolean) -# # lights, crazy sounds and alarms repeatedly until someone turns off -# # input boolean and/or Home Security System is turned OFF. -# # -# # All automations that alert during emerency situations, will turn on -# # input boolean emergency_mode and notify using standard notification -# # -# # My Home TTS/voice notifications will not work when music is being played -# # The automations will stop MPD media player ( just to makesure), so that -# # the TTS notifications will be played in case if someone plays music and -# # forgot to turn if off. -# ############################################################################### - -# homeassistant: -# customize: -# script.emergency_script: -# friendly_name: Emergency Script -# hidden: true -# script.emergency_script_loop: -# friendly_name: Emergency Script Loop -# hidden: true -# script.emergency_all_lights_switches_on: -# friendly_name: All Lights & Switches ON -# script.all_indoor_lights_off: -# friendly_name: All Indoor Lights OFF - -# input_boolean: -# emergency_mode: -# name: Emergency Mode -# initial: 'off' - -# ############################################################################### -# # _ _ _ -# # /\ | | | | (_) -# # / \ _ _| |_ ___ _ __ ___ __ _| |_ _ ___ _ __ ___ -# # / /\ \| | | | __/ _ \| '_ ` _ \ / _` | __| |/ _ \| '_ \/ __| -# # / ____ \ |_| | || (_) | | | | | | (_| | |_| | (_) | | | \__ \ -# # /_/ \_\__,_|\__\___/|_| |_| |_|\__,_|\__|_|\___/|_| |_|___/ -# # -# ############################################################################### - -# automation: - -# ############################################################################### -# # When emergency mode is OFF, Keep the lights ON -# ############################################################################### -# - alias: Emergency Mode Disabled -# initial_state: true -# trigger: -# platform: state -# entity_id: input_boolean.emergency_mode -# from: 'on' -# to: 'off' -# action: -# - delay: '00:00:05' -# - service: script.voice_notify -# data_template: -# message: "Attention! Emergency mode is now deactivated!" -# - service: script.notify_me -# data_template: -# message: "Emergency mode is now deactivated!" - -# # # Carbon Monoxide Detected in the house -# # ############################################################################### -# # - alias: CO Detected -# # initial_state: true -# # trigger: -# # - platform: state -# # entity_id: sensor.audio_detector_carbon_monoxide -# # from: '0' -# # condition: -# # - condition: template -# # value_template: "{{ trigger.to_state.state != '0' }}" -# # action: -# # - service: script.voice_notify -# # data_template: -# # message: "Attention!: CARBON MONOXIDE DETECTED! GET THE HELL OUT OF THE HOUSE!" -# # - service: script.notify_me -# # data_template: -# # message: "Attention!: CARBON MONOXIDE DETECTED!. GET THE HELL OUT OF THE HOUSE!" -# # - service: input_boolean.turn_on -# # entity_id: input_boolean.emergency_mode -# # - service: media_player.media_stop -# # entity_id: media_player.mpd -# # - service: script.emergency_script -# # data: -# # volume_level: 99 -# # alarm_code: 2 -# # message: "Attention! Cabon Monoxide detected. Leave the house immediately!" - -# # # Smoke Detected in the house -# # ############################################################################### -# # - alias: Smoke Detected -# # initial_state: true -# # trigger: -# # - platform: state -# # entity_id: sensor.audio_detector_smoke -# # from: '0' -# # condition: -# # - condition: template -# # value_template: "{{ trigger.to_state.state != '0' }}" -# # action: -# # - service: script.voice_notify -# # data_template: -# # message: "Attention!: SMOKE DETECTED! CALL 911!" -# # - service: script.notify_me -# # data_template: -# # message: "Attention!: SMOKE DETECTED!. CALL 911!" -# # - service: input_boolean.turn_on -# # entity_id: input_boolean.emergency_mode -# # - service: media_player.media_stop -# # entity_id: media_player.mpd -# # - service: script.emergency_script -# # data: -# # volume_level: 99 -# # alarm_code: 2 -# # message: "Smoke Detected. Please get out of the home and call 911 immediately!" - -# # Disable Emergency Mode upon Disabling Home Security System -# ############################################################################### -# - alias: Disable Emergency Mode Upon Disabling Home Security -# initial_state: true -# trigger: -# platform: state -# entity_id: alarm_control_panel.home -# to: 'disarmed' -# condition: -# - condition: template -# value_template: "{{ states('input_boolean.emergency_mode') == 'on' }}" -# action: -# - service: input_boolean.turn_off -# entity_id: input_boolean.emergency_mode - -# - alias: Home Security Away Motion Deteted Inside -# initial_state: true -# trigger: -# platform: state -# entity_id: -# - binary_sensor.back_door_sensor_sensor -# - binary_sensor.aeotec_zw120_door_window_sensor_gen5_sensor -# - binary_sensor.basement_door_sensor_sensor -# - binary_sensor.garage_door_sensor_sensor -# - binary_sensor.front_room_multi_sensor_sensor -# - binary_sensor.tv_multi_sensor_sensor -# - binary_sensor.kitchen_motion_sensor_sensor -# - binary_sensor.stairs_motion_sensor_sensor -# - binary_sensor.upstairs_multi_sensor_sensor -# - binary_sensor.door_window_sensor_158d0004231f7b -# - binary_sensor.door_window_sensor_158d0004248d5b -# - binary_sensor.motion_sensor_158d0001a662fe -# - binary_sensor.motion_sensor_158d0001a25041 -# - binary_sensor.motion_sensor_158d00016db6d2 -# - binary_sensor.motion_sensor_158d00016c2d0e -# from: 'off' -# to: 'on' -# condition: -# - condition: template -# value_template: "{{ trigger.from_state }}" -# - condition: template -# value_template: > -# {% set state = states.alarm_control_panel.home.state %} -# {% if state != "" and state != "unknown" and state == "armed_away" %} -# true -# {% else %} -# false -# {% endif %} -# - condition: template -# value_template: > -# {% set suresh = states.device_tracker.suresh_suresh.state %} -# {% set mallika = states.device_tracker.mallika_mallika.state %} -# {% set srinika = states.device_tracker.srinika_srinika.state %} -# {% set hasika = states.device_tracker.hasika_hasika.state %} -# {% if suresh != "home" and mallika != "home" and srinika != "home" and hasika != "home" %} -# True -# {% else %} -# False -# {% endif %} -# action: -# - service: input_boolean.turn_on -# entity_id: input_boolean.emergency_mode -# - service: script.emergency_all_lights_switches_on -# - service: script.notify_me -# data_template: -# message: "MOTION DETECTED '{{ trigger.to_state.attributes.friendly_name | upper }}', -# BUT NO ONE IS HOME. CALL FOR EMERGENCY!" -# - service: notify.ios_devices -# data_template: -# title: > -# {{ trigger.to_state.attributes.friendly_name }} -# message: > -# Attention: "MOTION DETECTED '{{ trigger.to_state.attributes.friendly_name | upper }}', -# BUT NO ONE IS HOME. CALL FOR EMERGENCY!" -# - service: script.emergency_script -# data: -# volume_level: 99 -# alarm_code: 1 -# message: "Police are on the way!...Police are on the way!...Police are on the way!...Police are on the way!...Police are on the way!" - -# script: - -# # Main Emergency Script -# ############################################################################### -# emergency_script: -# sequence: -# - condition: template -# value_template: '{{ states.input_boolean.emergency_mode.state | lower == "on" }}' -# - service: script.voice_notify -# data_template: -# message: '{{ message }}' -# greeting: 'no' -# - service: xiaomi_aqara.play_ringtone -# data_template: -# ringtone_id: '{{ alarm_code }}' -# ringtone_vol: '{{ volume_level }}' -# - delay: '00:00:01' -# - service: script.emergency_script_loop -# data_template: -# message: '{{ message }}' -# alarm_code: '{{ alarm_code }}' -# volume_level: '{{ volume_level }}' - -# # This script checks for the emergency_mode input_boolean and continue to -# # stay in emergency mode based on the input_boolean value -# ############################################################################### -# emergency_script_loop: -# sequence: -# - condition: template -# value_template: '{{ states.input_boolean.emergency_mode.state == "on" }}' -# - delay: '00:00:02' -# - service: script.emergency_script -# data_template: -# message: '{{ message }}' -# alarm_code: '{{ alarm_code }}' -# volume_level: '{{ volume_level }}' - -# # Turns ALL lights & Switches ON (Lights in RED where possible) -# ############################################################################### -# emergency_all_lights_switches_on: -# sequence: -# - service: script.xiaomi_red -# - service: script.ifttt_leeo_color_change -# data_template: -# value1: "#FF0000" -# - service: light.turn_on -# entity_id: light.family_room -# data: -# transition: 0 -# brightness: 255 -# rgb_color: [255,0,0] -# - service: light.turn_on -# entity_id: light.master_bedroom -# data: -# transition: 0 -# brightness: 255 -# rgb_color: [255,0,0] -# - service: switch.turn_on -# entity_id: -# - switch.basement_left -# - switch.basement_right -# - switch.garage -# - switch.guest_bedroom -# - switch.prayer_room -# - switch.kids_bed_accent -# - switch.kids_bedroom -# - switch.office_room -# - switch.smart_outlet_1 -# - switch.kitchen -# - switch.rf_switch_five -# - switch.rf_switch_four -# - switch.rf_switch_one -# - switch.rf_switch_three -# - switch.rf_switch_two -# - switch.wemobackyardlightswitch -# - switch.frontyard_light -# - switch.downstairs_fragrance -# - switch.upstairs_fragrance -# - switch.kitchen_siren_switch -# - switch.kitchen_siren_switch_2 -# - switch.kitchen_siren_switch_3 -# - switch.kitchen_siren_switch_4 -# - switch.kitchen_siren_switch_5 -# - switch.wemoswitch1 diff --git a/packages/homesecurity.yaml b/packages/homesecurity.yaml index bbd7550..ff8fa10 100644 --- a/packages/homesecurity.yaml +++ b/packages/homesecurity.yaml @@ -59,18 +59,6 @@ automation: {% elif states('alarm_control_panel.home') == "disarmed" %} script.xiaomi_red {% endif %} - - service: script.ifttt_leeo_color_change - data_template: - value1: > - {% if states('alarm_control_panel.home') == "armed_home" %} - "#0000FF" - {% elif states('alarm_control_panel.home') == "armed_away" %} - "#00FF00" - {% elif states('alarm_control_panel.home') == "triggered" %} - "#FF0000" - {% elif states('alarm_control_panel.home') == "disarmed" %} - "#FF0000" - {% endif %} ############################################################################### # Notify Security System State Change @@ -181,115 +169,95 @@ automation: entity_id: climate.dining_room away_mode: "false" - ############################################################################### - # TURN HOME SECURITY SYSTEM ON AT BED TIME - ############################################################################### - - alias: Night HomeSecurity On - initial_state: true - trigger: - platform: time_pattern - minutes: "/5" - seconds: 00 - condition: - - condition: template - value_template: "{{ states('sensor.bedtime_hour')|int == now().hour|int }}" - - condition: template - value_template: "{{ states('sensor.bedtime_minute')|int == now().minute|int }}" - - condition: template - value_template: "{{ states('alarm_control_panel.home') != 'away' }}" - - condition: template - value_template: "{{ states('alarm_control_panel.home') == 'disarmed' }}" - - condition: template - value_template: "{{ states('input_boolean.security_system_alerts') == 'on' }}" - action: - - service: alarm_control_panel.alarm_arm_home - data: - entity_id: alarm_control_panel.home - - service: script.notify_me - data: - message: "It's bedtime, you forgot to turn ON Home Security System. Turned it ON for you." + # ############################################################################### + # # TURN HOME SECURITY SYSTEM ON AT BED TIME + # ############################################################################### + # - alias: Night HomeSecurity On + # initial_state: true + # trigger: + # platform: time_pattern + # minutes: "/5" + # seconds: 00 + # condition: + # - condition: template + # value_template: "{{ states('sensor.bedtime_hour')|int == now().hour|int }}" + # - condition: template + # value_template: "{{ states('sensor.bedtime_minute')|int == now().minute|int }}" + # - condition: template + # value_template: "{{ states('alarm_control_panel.home') != 'away' }}" + # - condition: template + # value_template: "{{ states('alarm_control_panel.home') == 'disarmed' }}" + # - condition: template + # value_template: "{{ states('input_boolean.security_system_alerts') == 'on' }}" + # action: + # - service: alarm_control_panel.alarm_arm_home + # data: + # entity_id: alarm_control_panel.home + # - service: script.notify_me + # data: + # message: "It's bedtime, you forgot to turn ON Home Security System. Turned it ON for you." + ############################################################################### # Check for Garage Door Status when Home Security System State changes ############################################################################### -# - alias: Home Security System And Garage Door Check -# initial_state: true -# trigger: -# - platform: time_pattern -# minutes: '/15' -# seconds: 00 -# condition: -# condition: and -# conditions: -# - condition: template -# value_template: '{{ states('alarm_control_panel.home') == "armed_home" or states('alarm_control_panel.home') == "armed_away" }}' -# - condition: or -# conditions: -# - condition: template -# value_template: '{{ states('binary_sensor.door_window_sensor_158d0004231f7b') == "on" }}' -# - condition: template -# value_template: '{{ states('binary_sensor.door_window_sensor_158d0004248d5b') == "on" }}' -# action: -# - service: switch.turn_on -# entity_id: switch.garage -# - service: script.notify_me -# data_template: -# message: > -# Attention! Your home Security system is set to {{ states('alarm_control_panel.home').split('_')[1] | upper }} mode. -# BUT THE {% if states('binary_sensor.door_window_sensor_158d0004231f7b') == "on" -%}DOUBLE CAR {%- else %}SINGLE CAR {% endif %}GARAGE DOOR IS STILL OPEN! -# - service: camera.snapshot -# data_template: -# entity_id: "camera.garage_camera" -# filename: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~ (states('automation.home_security_system_and_garage_door_check.last_updated ~ '').replace('-','_').replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" -# - service: camera.snapshot -# data_template: -# entity_id: "camera.driveway_camera" -# filename: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/driveway/driveway_' ~ (states('automation.home_security_system_and_garage_door_check.last_updated ~ '').replace('-','_').replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" -# - service: camera.snapshot -# data_template: -# entity_id: "camera.frontdoor_camera" -# filename: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/frontdoor/frontdoor_' ~ (states('automation.home_security_system_and_garage_door_check.last_updated ~ '').replace('-','_').replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" -# - service: notify.notify_smtp -# data_template: -# title: 'Garage Picture {{ now().strftime("%d %h %Y, %I:%M:%S %p") }}' -# message: >- -# {%- macro get_date(dt) %} -# {%- set date_suffix = ["th", "st", "nd", "rd"] -%} -# {{ dt.day }} -# {%- if dt.day % 10 in [1, 2, 3] and dt.day not in [11, 12, 13] -%} -# {{ date_suffix[dt.day%10] }} -# {%- else -%} -# {{ date_suffix[0] }} -# {%- endif %} {{ dt.strftime("%B %Y")}} -# {%- endmacro -%} -# {% set doors = "" %} -# {% if states('binary_sensor.door_window_sensor_158d0004231f7b') == "on" and states('binary_sensor.door_window_sensor_158d0004248d5b') == "on" %} -# {% set doors = "Both garage doors" %} -# {% elif states('binary_sensor.door_window_sensor_158d0004248d5b') == "on"%} -# {% set doors = states('binary_sensor.door_window_sensor_158d0004248d5b.name %} -# {% elif states('binary_sensor.door_window_sensor_158d0004231f7b') == "on" %} -# {% set doors = states('binary_sensor.door_window_sensor_158d0004231f7b.name %} -# {% endif %} -# Your {{ doors }} seem to be open while your home security system is set to "{{ states('alarm_control_panel.home').split('_')[1]| title }}" mode. Today is {{ get_date(now()) }}, and time is {{ now().strftime("%I:%M:%S %p") }}. Please see the attached pictures and make sure everything is okay. -# data: -# images: -# - "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~ (states('automation.home_security_system_and_garage_door_check.last_updated ~ '').replace('-','_').replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" -# - "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/driveway/driveway_' ~ (states('automation.home_security_system_and_garage_door_check.last_updated ~ '').replace('-','_').replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" -# - "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/frontdoor/frontdoor_' ~ (states('automation.home_security_system_and_garage_door_check.last_updated ~ '').replace('-','_').replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" -# - condition: template -# value_template: '{{ states('alarm_control_panel.home') == "armed_home" }}' -# - service: script.voice_notify -# data_template: -# message: > -# {% set doors = "" %} -# {% if states('binary_sensor.door_window_sensor_158d0004231f7b') == "on" and states('binary_sensor.door_window_sensor_158d0004248d5b') == "on" %} -# {% set doors = "Both garage doors" %} -# {% elif states('binary_sensor.door_window_sensor_158d0004248d5b') == "on"%} -# {% set doors = states('binary_sensor.door_window_sensor_158d0004248d5b.name %} -# {% elif states('binary_sensor.door_window_sensor_158d0004248d5b') == "on" %} -# {% set doors = states('binary_sensor.door_window_sensor_158d0004231f7b.name %} -# {% endif %} -# Attention! Your home Security system is set to {{ states('alarm_control_panel.home').split('_')[1] | upper }} mode. -# BUT the {{ doors }} {{ 'are' if doors.endswith('s') else 'is' }} open. + - alias: Home Security System And Garage Door Check + initial_state: true + trigger: + - platform: time_pattern + minutes: '/15' + seconds: 00 + condition: + condition: and + conditions: + - condition: template + value_template: "{{ states('alarm_control_panel.home') == 'armed_home' or states('alarm_control_panel.home') == 'armed_away' }}" + - condition: or + conditions: + - condition: template + value_template: "{{ states('binary_sensor.door_window_sensor_158d0004231f7b') == 'on' }}" + - condition: template + value_template: "{{ states('binary_sensor.door_window_sensor_158d0004248d5b') == 'on' }}" + action: + - service: switch.turn_on + entity_id: switch.garage + + - service: script.notify_me + data_template: + message: > + Attention! Your home Security system is set to {{ states('alarm_control_panel.home').split('_')[1] | upper }} mode. BUT THE {% if states('binary_sensor.door_window_sensor_158d0004231f7b') == "on" -%}DOUBLE CAR {%- else %}SINGLE CAR {% endif %}GARAGE DOOR IS STILL OPEN! + + - service: camera.snapshot + data_template: + entity_id: "camera.garage_camera" + filename: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~ (state_attr('automation.home_security_system_and_garage_door_check','last_updated') ~ '').replace('-','_').replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + + - service: notify.telegram + data_template: + title: "Garage" + message: "Home Security System is ON, but Garage Doors are OPEN!" + data: + photo: + - file: "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~ + (states.binary_sensor.motion_sensor_158d00024ee084.last_updated ~ '').replace('-','_') + .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}" + caption: "Garage" + + - condition: template + value_template: "{{ states('alarm_control_panel.home') == 'armed_home' }}" + + - service: script.voice_notify + data_template: + message: > + {%- set doors = "" %} + {%- if states('binary_sensor.door_window_sensor_158d0004231f7b') == "on" and states('binary_sensor.door_window_sensor_158d0004248d5b') == "on" %} + {%- set doors = "Both garage doors" %} + {%- elif states('binary_sensor.door_window_sensor_158d0004248d5b') == "on"%} + {%- set doors = state_attr('binary_sensor.door_window_sensor_158d0004248d5b', 'friendly_name') %} + {%- elif states('binary_sensor.door_window_sensor_158d0004248d5b') == "on" %} + {%- set doors = state_attr('binary_sensor.door_window_sensor_158d0004231f7b', 'friendly_name') %} + {%- endif %} + Attention! Your home Security system is set to {{ states('alarm_control_panel.home').split('_')[1] | upper }} mode. + BUT the {{ doors }} {{ 'are' if doors.endswith('s') else 'is' }} open. ############################################################################### # Turn Home Security System ON at sunset time @@ -388,74 +356,3 @@ automation: # {%- endif -%} # Your {{ doors}} {%- if 'and' in doors -%}s are {%- else %} is {%- endif %} open. Home Security System could not be turned on. # {% endif %} - -############################################################################## -# Ask me if I want to turn off Home Security System upon reaching front door -# Ask me only when the security system is ON or AWAY mode -############################################################################## -# - alias: Turn Off Security Upon Reaching Home -# initial_state: true -# trigger: -# - platform: state -# entity_id: device_tracker.life360_suresh -# from: 'not_home' -# to: 'home' -# condition: -# condition: or -# conditions: -# - condition: template -# value_template: '{{ states('alarm_control_panel.home') | lower == "armed_away" }}' -# - condition: template -# value_template: '{{ states('alarm_control_panel.home') | lower == "armed_home" }}' -# action: -# - service: notify.ios_suresh -# data_template: -# title: 'Welcome Home, Suresh!' -# message: 'Turn Off Home Security System?' -# data: -# push: -# badge: 0 -# category: 'welcome_home' - -############################################################################## -# Ask me if I want to turn off Home Security System when garage door is opened -# Ask me only when the security system is ON or AWAY mode -############################################################################## -# - alias: Notify Garage Status And Home Security System -# initial_state: true -# trigger: -# platform: state -# entity_id: -# - binary_sensor.door_window_sensor_158d0004231f7b -# - binary_sensor.door_window_sensor_158d0004248d5b -# to: 'on' -# condition: -# - condition: template -# value_template: '{{ states('alarm_control_panel.home') == "armed_home" or states('alarm_control_panel.home') == "armed_away" }}' -# action: -# - service: notify.ios_suresh -# data_template: -# title: > -# Your Home is armed, and {{ trigger.entity_id.split('.')[1].split('_')[0] |title }} Car Garage is just opened! -# message: 'Turn Off Home Security System?' -# data: -# push: -# badge: 0 -# category: 'welcome_home' - -############################################################################## -# iOS Actionable Notification that disables Home Security System -############################################################################## -# - alias: Disable Home Security iOS Action -# initial_state: true -# trigger: -# platform: event -# event_type: ios.notification_action_fired -# event_data: -# actionName: 'DISABLE_SECURITY' -# action: -# - service: alarm_control_panel.alarm_disarm -# entity_id: alarm_control_panel.home -# - service: notify.ios_suresh -# data: -# message: "Unlocked your home!" diff --git a/packages/lights.yaml b/packages/lights.yaml index e031a79..f7f6daa 100644 --- a/packages/lights.yaml +++ b/packages/lights.yaml @@ -88,9 +88,9 @@ homeassistant: input_boolean.animate_upstairs_lights: icon: mdi:flash-outline friendly_name: Animate Master Bedroom Lights -hue: - bridges: - - host: !secret philips_hue_ipaddress +# hue: +# bridges: +# - host: !secret philips_hue_ipaddress tplink: discovery: false diff --git a/packages/recycle_trash.yaml b/packages/recycle_trash.yaml index c2c9b3e..805805b 100644 --- a/packages/recycle_trash.yaml +++ b/packages/recycle_trash.yaml @@ -6,7 +6,6 @@ ############################################################################### homeassistant: customize: - sensor.trash_day: friendly_name: Is it Trash Day today? icon: mdi:delete-variant @@ -42,33 +41,33 @@ input_select: trash_pickup_day: name: Current Trash Pickup Day (Evey Week) options: - - Monday - - Tuesday - - Wednesday - - Thursday - - Friday - - Saturday - - Sunday - - unknown + - Monday + - Tuesday + - Wednesday + - Thursday + - Friday + - Saturday + - Sunday + - unknown icon: mdi:delete-variant recycle_pickup_day: name: Current Recycle Pickup Day (Every Other Week) options: - - Monday - - Tuesday - - Wednesday - - Thursday - - Friday - - Saturday - - Sunday - - unknown + - Monday + - Tuesday + - Wednesday + - Thursday + - Friday + - Saturday + - Sunday + - unknown icon: mdi:recycle recycle_pickup_week: name: Select Recycle Pickup Week based on Current Week above options: - - Even Weeks - - Odd Weeks - - unknown + - Even Weeks + - Odd Weeks + - unknown icon: mdi:recycle ############################################################################### @@ -87,7 +86,7 @@ sensor: state_topic: "/home/trashpickupday" name: "Trash Pickup Day" value_template: "{{ value }}" - qos: 1 + qos: 1 - platform: mqtt state_topic: "/home/recyclepickupday" name: "Recycle Pickup Day" @@ -99,9 +98,9 @@ sensor: value_template: "{{ value }}" qos: 1 -############################################################################### -# Sensor to hold info about current week is an odd week or an even week of the year -############################################################################### + ############################################################################### + # Sensor to hold info about current week is an odd week or an even week of the year + ############################################################################### - platform: template sensors: current_week: @@ -116,10 +115,10 @@ sensor: Odd Week (Week# {{ as_timestamp(today) | timestamp_custom('%U', true) }}) {%- endif -%} -############################################################################### -# Trash - Pickup schedule is EVERY week. -# Set the day to a day before the actual day leaving time for reminders -############################################################################### + ############################################################################### + # Trash - Pickup schedule is EVERY week. + # Set the day to a day before the actual day leaving time for reminders + ############################################################################### - platform: template sensors: trash_day: @@ -135,10 +134,10 @@ sensor: no {%- endif -%} -############################################################################### -# Recycle - Pickup schedule is every other week. -# Set the day to a day before the actual day leaving time for reminders -############################################################################### + ############################################################################### + # Recycle - Pickup schedule is every other week. + # Set the day to a day before the actual day leaving time for reminders + ############################################################################### - platform: template sensors: recycle_day: @@ -188,22 +187,21 @@ sensor: {{- is_it_today() -}} ############################################################################### -# _ _ _ -# /\ | | | | (_) -# / \ _ _| |_ ___ _ __ ___ __ _| |_ _ ___ _ __ ___ +# _ _ _ +# /\ | | | | (_) +# / \ _ _| |_ ___ _ __ ___ __ _| |_ _ ___ _ __ ___ # / /\ \| | | | __/ _ \| '_ ` _ \ / _` | __| |/ _ \| '_ \/ __| # / ____ \ |_| | || (_) | | | | | | (_| | |_| | (_) | | | \__ \ -# /_/ \_\__,_|\__\___/|_| |_| |_|\__,_|\__|_|\___/|_| |_|___/ -# +# /_/ \_\__,_|\__\___/|_| |_| |_|\__,_|\__|_|\___/|_| |_|___/ +# ############################################################################### automation: - -############################################################################### -# The schedule can be changed via UI. The updated schedules are saved in MQTT -# The input_selects don't maintain state automatically - hence this code -# These automations are hidden - no interaction with user is required. -# Save & Restore Functionality -############################################################################### + ############################################################################### + # The schedule can be changed via UI. The updated schedules are saved in MQTT + # The input_selects don't maintain state automatically - hence this code + # These automations are hidden - no interaction with user is required. + # Save & Restore Functionality + ############################################################################### - alias: Trash Pickup Day Changed initial_state: true trigger: @@ -214,7 +212,7 @@ automation: data_template: topic: "/home/trashpickupday" retain: true - payload: '{{ states.input_select.trash_pickup_day.state }}' + payload: "{{ states.input_select.trash_pickup_day.state }}" - alias: Recycle Pickup Day Changed initial_state: true @@ -226,7 +224,7 @@ automation: data_template: topic: "/home/recyclepickupday" retain: true - payload: '{{ states.input_select.recycle_pickup_day.state }}' + payload: "{{ states.input_select.recycle_pickup_day.state }}" - alias: Recycle Pickup Week Changed initial_state: true @@ -238,7 +236,7 @@ automation: data_template: topic: "/home/recyclepickupweek" retain: true - payload: '{{ states.input_select.recycle_pickup_week.state }}' + payload: "{{ states.input_select.recycle_pickup_week.state }}" - alias: Restore Trash Recycle Settings on Startup initial_state: true @@ -247,7 +245,7 @@ automation: event: start action: - delay: - minutes: 1 + minutes: 1 - service: input_select.select_option data_template: entity_id: input_select.trash_pickup_day @@ -261,62 +259,39 @@ automation: entity_id: input_select.recycle_pickup_week option: "{{states.sensor.recycle_pickup_week.state}}" -############################################################################### -# Reminder code - Reminds 5 times every hour starting 4 PM -# Conditions: Only notifies when someone is at home -############################################################################### + ############################################################################### + # Reminder code - Reminds 5 times every hour starting 4 PM + # Conditions: Only notifies when someone is at home + ############################################################################### - alias: Trash and Recycle Pickup Reminder initial_state: true trigger: - platform: time - at: '16:00:00' + at: "16:00:00" - platform: time - at: '17:00:00' + at: "17:00:00" - platform: time - at: '18:00:00' + at: "18:00:00" - platform: time - at: '19:00:00' + at: "19:00:00" - platform: time - at: '20:00:00' + at: "20:00:00" - platform: time - at: '21:00:00' + at: "21:00:00" condition: condition: and conditions: - - condition: template - value_template: '{{ states.input_boolean.trash_reminders.state == "on" }}' - - condition: or - conditions: - - condition: state - entity_id: sensor.trash_day - state: 'yes' - - condition: state - entity_id: sensor.recycle_day - state: 'yes' + - condition: template + value_template: '{{ states.input_boolean.trash_reminders.state == "on" }}' + - condition: or + conditions: + - condition: state + entity_id: sensor.trash_day + state: "yes" + - condition: state + entity_id: sensor.recycle_day + state: "yes" action: - - service: notify.ios_suresh - data_template: - title: > - {% if states.sensor.trash_day.state == "yes" and states.sensor.recycle_day.state == "yes" %} - Trash and Recycle Pickup Tomorrow! - {% elif states.sensor.trash_day.state == "yes" %} - Trash Pickup Tomorrow! - {% elif states.sensor.recycle_day.state == "yes" %} - Recycle Pickup Tomorrow! - {% endif %} - message: > - {% if states.sensor.trash_day.state == "yes" and states.sensor.recycle_day.state == "yes" %} - Please leave Trash AND Recycle bins out tonight! - {% elif states.sensor.trash_day.state == "yes" %} - Please leave Trash bin outside tonight! - {% elif states.sensor.recycle_day.state == "yes" %} - Please leave Recycle bin outside tonight! - {% endif %} - data: - push: - badge: 0 - category: "trash_recycle" - - service: script.notify_me data_template: message: > @@ -340,39 +315,11 @@ automation: Attention!: Tomorrow is the Recycle Pickup day. Please don't forget to put the recycle bin outside tonight! {% endif %} - - alias: Trash and Recycle Bin Left Outside Already - initial_state: true - trigger: - platform: event - event_type: ios.notification_action_fired - event_data: - actionName: TRASH_LEFT - action: - - service: notify.ios_suresh - data: - message: "Great job, Thank you!" - - service: input_boolean.turn_off - entity_id: input_boolean.trash_reminders - - - alias: Remind later - initial_state: true - trigger: - platform: event - event_type: ios.notification_action_fired - event_data: - actionName: TRASH_REMIND_LATER - action: - - service: notify.ios_suresh - data: - message: "Will remind you again in an hour!" - - service: input_boolean.turn_on - entity_id: input_boolean.trash_reminders - - alias: Reset Trash Reminders initial_state: true trigger: - platform: time - at: '09:00:00' + at: "09:00:00" action: - service: input_boolean.turn_on entity_id: input_boolean.trash_reminders @@ -387,4 +334,4 @@ automation: - service: input_select.select_option data_template: entity_id: input_select.recycle_pickup_week - option: "{{states.sensor.recycle_pickup_week.state}}" \ No newline at end of file + option: "{{states.sensor.recycle_pickup_week.state}}" diff --git a/packages/scripts.yaml b/packages/scripts.yaml index 0d6b9a9..4c391d4 100644 --- a/packages/scripts.yaml +++ b/packages/scripts.yaml @@ -122,11 +122,15 @@ script: entity_id: > {%- for state in states.switch if state.entity_id != 'switch.3d_printer' and + state.entity_id != 'switch.tesla_model_3_charger_switch' and + state.entity_id != 'switch.tesla_model_3_maxrange_switch' and + state.entity_id != 'switch.tesla_model_3_update_switch' and + state.entity_id != 'switch.mahasri_tesla_sentry_mode_switch' and state.entity_id != 'switch.wemoswitch1' and state.entity_id != 'switch.wallmote_switch' and state.entity_id != 'switch.wemobackyardlightswitch' and state.entity_id != 'switch.frontyard_light' and - not '_siren_' in state.entity_id -%} + not 'ecolink' in state.entity_id -%} {{- "," if not loop.first-}}{{ state.entity_id }}{{-endif-}} {%- endfor -%} @@ -280,24 +284,21 @@ script: # |___/ # Notify Related Scripts ############################################################################### - ifttt_notify: + notify_me_with_picture: sequence: + - condition: state + entity_id: input_boolean.text_alerts + state: "on" - condition: template - value_template: '{{ message | trim != "" }}' - - service: ifttt.trigger + value_template: '{{- message | trim != "" -}}' + - service: notify.telegram data_template: - event: "Smart_Home" - value1: "{{ message }}" - value2: "" - - ifttt_leeo_color_change: - sequence: - - condition: template - value_template: '{{ value1 | trim != "" }}' - - service: ifttt.trigger - data_template: - event: "LEEO_COLOR_CHANGE" - value1: "{{ value1 }}" + title: "{{- title -}}" + message: "{{- message -}}" + data: + photo: + - file: "{{- file -}}" + caption: "{{- caption -}}" notify_me: sequence: @@ -306,9 +307,6 @@ script: state: "on" - condition: template value_template: '{{ message | trim != "" }}' - - service: script.ifttt_notify - data_template: - message: "{{ message }}" - service: notify.telegram data_template: message: "{{ message }}" @@ -327,9 +325,6 @@ script: ############################################################################### voice_notify: sequence: - # - service: script.led_message - # data_template: - # message: "{{ message }}" - condition: template value_template: "{{ states('input_boolean.voice_notifications') == 'on' }}" - condition: template diff --git a/zwcfg_0xd89c4f0c.xml b/zwcfg_0xd89c4f0c.xml index 078afd1..c4cf6db 100644 --- a/zwcfg_0xd89c4f0c.xml +++ b/zwcfg_0xd89c4f0c.xml @@ -243,7 +243,7 @@ - + @@ -259,9 +259,9 @@ - - - + + + @@ -547,9 +547,9 @@ - + - + @@ -719,7 +719,7 @@ - + @@ -728,8 +728,8 @@ - - + + @@ -749,7 +749,7 @@ - + @@ -1139,7 +1139,7 @@ - + @@ -1357,9 +1357,9 @@ - + - +