Преглед изворни кода

got cam notification working

justadri пре 1 месец
родитељ
комит
f0b1be1348

+ 2 - 0
.gitignore

@@ -12,3 +12,5 @@ home-assistant_v2.db
 .storage
 .secrets
 .cloud
+www/snapshots/*
+

+ 1 - 0
alexa.yaml

@@ -40,3 +40,4 @@ smart_home:
       - switch.tz3000_okaz9tjs_ts011f
       - switch.ewelink_sa_003_zigbee_switch
       - switch.office_heater_switch
+      - switch.lava_lamp

+ 14 - 6
automations.yaml

@@ -606,12 +606,13 @@
   conditions: []
   actions:
   - variables:
-      timestamp: '{{ now().strftime("%Y%m%d_%H%M%S") }}'
+      timestamp: '{{ now().strftime(''%Y%m%d_%H%M%S'') }}'
       image_file: '{{ trigger.payload_json.oid }}_{{ timestamp }}.jpg'
-  - action: shell_command.save_payload_image
+      recording: '{{ trigger.payload_json.file.split(''/'')[-1] }}'
+  - action: shell_command.base64_to_image
     data:
       payload: '{{ trigger.payload_json.image }}'
-      filename: '{{ image_file }}'
+      filename: /config/www/snapshots/{{ image_file }}
   - delay: 00:00:01
   - action: notify.adris_mobile_devices
     data:
@@ -620,12 +621,19 @@
       data:
         channel: Indoor Activity
         group: motion_detection
-        image: /local/snapshots/{{ image_file }}.jpg
+        image: https://hass.dgtlu.net/local/snapshots/{{ image_file }}
+        clickAction: http://athena.dgtlu.net:8090/streamFile.cgi?oid={{ trigger.payload_json.oid
+          }}&ot=2&fn={{ recording }}
         actions:
-        - action: VIEW
+        - action: URI
           title: View Recording
           uri: http://athena.dgtlu.net:8090/streamFile.cgi?oid={{ trigger.payload_json.oid
-            }}&ot=2&fn={{ trigger.payload_json.file }}
+            }}&ot=2&fn={{ recording }}
+  - delay:
+      hours: 0
+      minutes: 0
+      seconds: 40
+      milliseconds: 0
   mode: single
   max_exceeded: silent
 - id: '1767242164550'

+ 8 - 12
configuration.yaml

@@ -1,22 +1,19 @@
-# Configure a default setup of Home Assistant (frontend, api, etc)
+# ha core
 default_config:
-
 logger:
   default: info
-
 http:
   ip_ban_enabled: true
   login_attempts_threshold: 5
   use_x_forwarded_for: true
   trusted_proxies:
     - 192.168.0.30
-
 homeassistant:
   allowlist_external_dirs:
     - /config
-
 recorder: !include recorder.yaml
 
+# integrations
 notify:  
 - name: adris_mobile_devices
   platform: group
@@ -24,18 +21,17 @@ notify:
     - service: mobile_app_adri_s_pixel_4a
     - service: mobile_app_adri_s_gs22
 
-alexa: !include alexa.yaml
-
-# google_assistant: !include google.yaml
-
-uniled:
-
 zha:
   enable_quirks: true
   custom_quirks_path: /config/thirdreality_quirks
 
+# helpers
 automation: !include automations.yaml
 script: !include scripts.yaml
 scene: !include scenes.yaml
-
 shell_command: !include shell.yaml
+
+# assistants
+alexa: !include alexa.yaml
+# google_assistant: !include google.yaml
+

+ 21 - 0
scripts/base64_to_image.py

@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+import sys
+import base64
+
+# Read arguments: payload and filename
+if len(sys.argv) != 3:
+    print("Usage: base64_to_image.py <base64_payload> <filename>")
+    sys.exit(1)
+
+payload = sys.argv[1]
+filename = sys.argv[2]
+
+try:
+    # Decode base64 and save
+    image_data = base64.b64decode(payload)
+    with open(filename, 'wb') as f:
+        f.write(image_data)
+    print(f"Saved {len(image_data)} bytes to {filename}")
+except Exception as e:
+    print(f"Error: {e}")
+    sys.exit(1)

+ 0 - 19
scripts/sync_to_alexa.sh

@@ -1,19 +0,0 @@
-#!/bin/sh
-
-# Read entity registry from storage
-TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhNTk3MGM3YTQxNTE0YjZhYjg1OTNjZjJjMWY2NGQ0MyIsImlhdCI6MTc2NzI1OTE1MCwiZXhwIjoyMDgyNjE5MTUwfQ.hjng9QODqQsGLly3OXCKp7f5CPM6XcpgRLztVnPynTU"
-
-# Parse entity registry and expose each entity
-cat /homeassistant/.storage/core.entity_registry | \
-  grep -B2 '"should_expose":true' | \
-  grep '"entity_id"' | \
-  cut -d'"' -f4 | \
-while read entity; do
-  if [ ! -z "$entity" ]; then
-    wget -q -O- --post-data="{\"entity_id\":\"$entity\",\"assistants\":[\"alexa\"]}" \
-      --header="Authorization: Bearer $TOKEN" \
-      --header="Content-Type: application/json" \
-      http://localhost:8123/api/services/homeassistant/expose_entity
-    echo "Exposed: $entity"
-  fi
-done

+ 2 - 3
shell.yaml

@@ -1,4 +1,3 @@
+base64_to_image: python3 /config/scripts/base64_to_image.py "{{ payload }}" "{{ filename }}"
 cleanup_snapshots: 'find /config/www/snapshots -name "*.jpg" -mtime +7 -delete'
-save_payload_image: |
-  echo "{{ payload }}" | base64 -d > "/config/www/snapshots/{{ filename }}"
-# sync_to_alexa: python3 /config/scripts/sync_to_alexa.py
+# sync_to_alexa: python3 /config/scripts/sync_to_alexa.py

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
www/community/lovelace-mushroom/mushroom.js


BIN
www/community/lovelace-mushroom/mushroom.js.gz



Неке датотеке нису приказане због велике количине промена