Skip to content

Commit

Permalink
Merge pull request #10 from Cyberbeni/readme
Browse files Browse the repository at this point in the history
Add readme and sample config, schedule BLE away trigger at start
  • Loading branch information
Cyberbeni authored Nov 3, 2024
2 parents 5c211a1 + db89b2e commit 610284b
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Description

This tool provides various utilities for Home Assistant via MQTT autodiscovery.

See [sample config](sample_config).

## Features

### Presence detection

This feature is for aggregating network presence (you have to set up a fix IP address for the device you want to track) and BLE presence (via [ESPresense](https://github.com/ESPresense/ESPresense)).

## Experimental features

These features might have breaking changes without a major version bump.

### Cover control

You will be able to set up covers with different opening/closing durations controlled by a remote device in Home Assistant (for example via the [Broadlink integration](https://www.home-assistant.io/integrations/broadlink)).
5 changes: 5 additions & 0 deletions Sources/Wiring/Presence/BlePresenceDetector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ actor BlePresenceDetector {
await updateOutput()
}
}
scheduleAway()
}

private func updateOutput() async {
await presenceDetectorAggregator.setBlePresence(true)
scheduleAway()
}

private func scheduleAway() {
presenceTimeoutTask?.cancel()
presenceTimeoutTask = Task {
try await Task.sleep(for: .seconds(presenceConfig.espresenseTimeout.seconds), tolerance: .seconds(0.1))
Expand Down
9 changes: 9 additions & 0 deletions sample_config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Description

Config files other than `config.general.json` are optional.

Comments are not supported in config files, they are only included in the sample config to help setting up.

Optional parameters that have a value in the sample will default to that value if you omit them.

`*_interval` and `*_timeout` parameters support both numeric values (seconds) and text values ("hours:minutes:seconds" or "minutes:seconds").
11 changes: 11 additions & 0 deletions sample_config/config/config.general.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"mqtt": {
"host": "localhost",
"port": 1883,
"user": null, // optional
"password": null, // optional
"base_topic": "wiring", // optional
"home_assistant_base_topic": "homeassistant" // optional
},
"enable_debug_logging": false // optional
}
17 changes: 17 additions & 0 deletions sample_config/config/config.presence.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"espresense_devices_base_topic": "espresense/devices", // optional
"ping_interval": 5, // optional, ping is used to speed up detecting away status for network presence detection, usually takes around 0.5-1 minutes
"arp_interval": 5, // optional, arp reads the systems network neighbour cache, it adds a bit of CPU load and devices are usually discovered via BLE first
"espresense_timeout": 11, // optional, ESPresense sends updates about every 5-6 seconds if the device is nearby and there hasn't been any significant change
"away_timeout": "05:00", // optional
"entries": {
"Person_1": { // Supported characters in Home Assistant: [a-zA-Z0-9_-] (alphanumerics, underscore and hyphen)
"ip": "192.168.1.11", // optional
"espresense_device": "person_1_phone" // optional
},
"Person_2": {
"ip": "192.168.1.12",
"espresense_device": "person_2_phone"
}
}
}
14 changes: 14 additions & 0 deletions sample_config/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
wiring:
image: ghcr.io/cyberbeni/wiring:v1
container_name: wiring
mem_limit: '128m'
cpus: 1
restart: unless-stopped
user: 1000:1000
network_mode: host
environment:
TZ: 'Europe/Budapest' # Time-zone identifier, used for the time in logs
LANG: 'hu' # Language identifier, used for the time format in logs
volumes:
- ./config:/config

0 comments on commit 610284b

Please sign in to comment.