diff --git a/bundles/bootshorn/files/process b/bundles/bootshorn/files/process index 45ac2d7..7cebd36 100755 --- a/bundles/bootshorn/files/process +++ b/bundles/bootshorn/files/process @@ -112,6 +112,11 @@ def process_recording(filename): sample_num += samples_per_block - overlapping_samples + # move to PROCESSED_RECORDINGS_DIR + + os.makedirs(PROCESSED_RECORDINGS_DIR, exist_ok=True) + shutil.move(os.path.join(RECORDINGS_DIR, filename), os.path.join(PROCESSED_RECORDINGS_DIR, filename)) + # write a spectrogram using the sound from start to end of the event def write_event(current_event, soundfile, samplerate): diff --git a/bundles/bootshorn/files/record b/bundles/bootshorn/files/record index b65b1a7..ce3d740 100755 --- a/bundles/bootshorn/files/record +++ b/bundles/bootshorn/files/record @@ -7,7 +7,6 @@ do # get date in ISO 8601 format with nanoseconds PROGRAMM=$(test $(uname) = "Darwin" && echo "gdate" || echo "date") DATE=$($PROGRAMM "+%Y-%m-%d_%H-%M-%S.%6N%z") - FILE="recordings/$DATE.flac" # record audio using ffmpeg ffmpeg \ @@ -20,7 +19,7 @@ do -t "3600" \ -c:a flac \ -compression_level 12 \ - "$FILE.part" + "recordings/current/$DATE.flac" - mv "$FILE.part" "$FILE" + mv "recordings/current/$DATE.flac" "recordings/$DATE.flac" done diff --git a/bundles/bootshorn/files/temperature b/bundles/bootshorn/files/temperature index 0599ce5..677a21f 100755 --- a/bundles/bootshorn/files/temperature +++ b/bundles/bootshorn/files/temperature @@ -8,7 +8,7 @@ urllib3.disable_warnings() import os -HUE_IP = "10.0.0.134" # replace with your bridge IP +HUE_IP = "${hue_ip}" # replace with your bridge IP HUE_APP_KEY = "${hue_app_key}" # local only HUE_DEVICE_ID = "31f58786-3242-4e88-b9ce-23f44ba27bbe" TEMPERATURE_LOG_DIR = "/opt/bootshorn/temperatures" diff --git a/bundles/bootshorn/items.py b/bundles/bootshorn/items.py index b4082eb..f7d8ee5 100644 --- a/bundles/bootshorn/items.py +++ b/bundles/bootshorn/items.py @@ -7,11 +7,15 @@ directories = { 'owner': 'ckn', 'group': 'ckn', }, + '/opt/bootshorn/temperatures': { + 'owner': 'ckn', + 'group': 'ckn', + }, '/opt/bootshorn/recordings': { 'owner': 'ckn', 'group': 'ckn', }, - '/opt/bootshorn/temperatures': { + '/opt/bootshorn/recordings/current': { 'owner': 'ckn', 'group': 'ckn', }, @@ -34,6 +38,7 @@ files = { '/opt/bootshorn/temperature': { 'content_type': 'mako', 'context': { + 'hue_ip': repo.get_node('home.hue').hostname, 'hue_app_key': repo.vault.decrypt('encrypt$gAAAAABoc2WxZCLbxl-Z4IrSC97CdOeFgBplr9Fp5ujpd0WCCCPNBUY_WquHN86z8hKLq5Y04dwq8TdJW0PMSOSgTFbGgdp_P1q0jOBLEKaW9IIT1YM88h-JYwLf9QGDV_5oEfvnBCtO'), }, 'owner': 'ckn', diff --git a/hass_get_temp.py b/hass_get_temp.py new file mode 100644 index 0000000..f562e24 --- /dev/null +++ b/hass_get_temp.py @@ -0,0 +1,30 @@ +#! /usr/bin/env python3 + +import requests +from datetime import datetime, timedelta, timezone + +BASE = "https://homeassistant.ckn.li" +TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI1YjY0ZWE5N2FiMzM0NTQ0OGMyNjhmZTIxYzAxZTE1MSIsImlhdCI6MTc1NjAzOTAxNCwiZXhwIjoyMDcxMzk5MDE0fQ.X-sQli-NTpCjeXpn19zf-maPRDldkSeTuhKZua1k8uM" +ENTITY = "sensor.hue_outdoor_motion_sensor_2_temperature" + +HEADERS = { + "Authorization": f"Bearer {TOKEN}", + "Content-Type": "application/json", +} + +begin = datetime(2025, 7, 1, 0, 0, 0, tzinfo=timezone.utc) +current = begin +now = datetime.now(timezone.utc) + +while current < now: + current += timedelta(hours=1) + resp = requests.get( + f"{BASE}/api/history/period/{current.isoformat()}", + params={ + "end_time": current.isoformat(), + "filter_entity_id": ENTITY + }, + headers=HEADERS, + timeout=15, + ) + print(current, resp.json()) diff --git a/nodes/home.bootshorn-laptop.py b/nodes/home.bootshorn-laptop.py index 23672c7..a5d585d 100644 --- a/nodes/home.bootshorn-laptop.py +++ b/nodes/home.bootshorn-laptop.py @@ -15,3 +15,5 @@ }, }, } + +# rsync -avh --progress -e 'ssh -o "StrictHostKeyChecking no"' 10.0.0.150:/opt/bootshorn/recordings /tank/bootshorn diff --git a/nodes/home.homeassistant.py b/nodes/home.homeassistant.py index 61a2055..e3a77f6 100644 --- a/nodes/home.homeassistant.py +++ b/nodes/home.homeassistant.py @@ -33,6 +33,9 @@ # ssh-ed25519 # AAAAC3NzaC1lZDI1NTE5AAAAIJT9Spe+BYue7iiutl3rSf6PlU6dthHizyK+ZWnLodrA # root@home.server +# - >- +# ssh-ed25519 +# AAAAC3NzaC1lZDI1NTE5AAAAILMVroYmswD4tLk6iH+2tvQiyaMe42yfONDsPDIdFv6I ckn # sftp: true # compatibility_mode: false # allow_agent_forwarding: false