Open villasenor opened 10 months ago
For anyone else who comes across this wondering the same thing - it is in fact possible to set the config with the Home Assistant Add-on version of Swatch.
I was able to figure out that the paths are literally /homeassistant/config/swatch.yml
. You will likely need to create the config
folder under the homeassistant
folder. If you're on a Home Assistant Supervised installation, the homeassistant
folder is at /usr/share/hassio/homeassistant
.
That said, even with the example config.yml
provided in the docs, you'll still get an error at startup:
[2024-09-27 20:08:04,306]: INFO - Starting SwatchApp
[2024-09-27 20:08:04,311]: INFO - Importing SwatchApp Config
[2024-09-27 20:08:04,311]: INFO - Verified SwatchApp Config
[2024-09-27 20:08:04,314]: ERROR - Error parsing config file
1 validation error for SwatchConfig
cameras
field required (type=value_error.missing)
My config (literally copy and pasted from the example):
# REQUIRED: Define a list of objects that are expected to be seen. These can be specific
# to one camera or common between many / all cameras
objects:
# REQUIRED: Name of the object
trash_can:
# REQUIRED: the list of color variants that this object can be detected as. Useful for
# different lighting conditions
color_variants:
# REQUIRED: the name of the color variant
default:
# REQUIRED: the lower R, G, B values that are considered a potential match for the
# color variant of the object.
color_lower: 70, 70, 0
# REQUIRED: the upper R, G, B values that are considered a potential match for the
# color variant of the object.
color_upper: 110, 100, 50
# OPTIONAL: the time range for when this color variant is allowed
# NOTE: make sure that /etc/localtime is passed to the container so it has valid time
time_range:
# OPTIONAL: Color variant is valid if current time is > this 24H time (Default: shown below).
after: "00:00"
# OPTIONAL: Color variant is valid if current time is < this 24H time (Default: shown below).
before: "24:00"
# OPTIONAL: the min area of the bounding box around groups of matching R, G, B pixels
# considered a true positive. This is not recommended to be set as a super small amount
# could be a false positive. (Default: shown below)
min_area: 1000
# OPTIONAL: the max area of the bounding box around groups of pixels with R, G, B
# values within the bounds to be considered a true positive (Default: shown below).
max_area: 100000
# OPTIONAL: the min ratio of width/height of bounding box for valid object detection (default: shown below).
min_ratio: 0
# OPTIONAL: the max ratio of width/height of bounding box for valid object detection (default: shown below).
max_ratio: 24000000
# REQUIRED: Define list of cameras that will be used for color detection.
cameras:
# REQUIRED: Name of the camera
front_doorbell_cam:
# OPTIONAL: Frequency in seconds to run detection on the camera.
# a value of 0 disables auto detection (Default: shown below).
auto_detect: 0
# OPTIONAL: Configure the url and retention of snapshots. (Default: Shown Below)
snapshot_config:
# OPTIONAL: but highly recommended, setting the default url for a snapshot to be
# processed by this camera. This is required for auto detection (Default: none).
url: "http://ip.ad.dr.ess/jpg"
# OPTIONAL: Whether or not to draw bounding boxes for confirmed objects in the snapshots (Default: shown below).
bounding_box: true
# OPTIONAL: Whether or not to save a clean png of the snapshot along with the annotated jpg (Default: shown below).
clean_snapshot: true
# OPTIONAL: Whether or not to save the snapshots of confirmed detections (Default: shown below).
save_detections: true
# OPTIONAL: Whether or not to save the snapshots of missed detections (Default: shown below).
save_misses: false
# OPTIONAL: Variations of snapshots to keep. Options are all, mask, crop (Default: shown below).
mode: "all"
# OPTIONAL: Number of days of snapshots to keep (Default: shown below).
retain_days: 7
# REQUIRED: Zones are cropped areas where the object can be expected to be.
# This makes searching / matches for efficient and more predictable than searching
# the entire image.
zones:
# REQUIRED: Name of the zone.
street:
# REQUIRED: Coordinates to crop the zone by.
# NOTE: The order of the coordinates are: x, y, x+w, y+h starting in the top left corner as 0, 0.
coordinates: 225, 540, 350, 620
# REQUIRED: List of objects that may be in this zone. These correspond to
# the objects list defined previously and are matched by name.
objects:
- trash_can
Would love to get this working but don't have the time to debug further at the moment.
If having a valid
config.yml
is a requirement for Swatch to start, there really should be a text area configuration editor in the Configuration tab of the add-on.I know that this config is mounted into the container, but it might not be clear to someone new to Home Assistant how to get the config into the add-on.
Thanks for making this, and making it open source!