Skip to main content

title: ‘Helpers’ description: ‘Utility functions and modules for Homescript’

This section provides utility functions and modules that can be used to enhance your Homescript scripts. These helpers simplify common tasks and improve code readability. We inject these helpers into the global namespace, so you can use them directly in your scripts.

Available Helpers

Color Helper

The color helper provides functions to work with colors, including conversion between different color formats.
color.xy_to_rgb(x, y, brightness) # CIE XYRGB
color.rgb_to_xy(r, g, b)          # RGBCIE XY
color.xy_to_hsv(x, y, brightness) # CIE XYHSV
color.hsv_to_xy(h, s, v)          # HSVCIE XY
color.rgb_to_hsv(r, g, b)         # RGBHSV
color.hsv_to_rgb(h, s, v)         # HSVRGB
color.describe_color(raw_color_table) # Human-readable description

Frigate Helper

The frigate helper allows interaction with Frigate NVR systems for video surveillance.
-- Parse and log detected objects with details
-- Usage: frigate.log_objects(event.data.objects)
frigate.log_objects(objects)
-- Check if specific object type was detected
-- Usage: if frigate.has_object(event.data.objects, "person") then ...
frigate.has_object(objects, object_type)
-- Get object with highest confidence
-- Usage: local best = frigate.get_best_object(event.data.objects)
frigate.get_best_object(objects)
-- Filter objects by confidence threshold
-- Usage: local high_conf = frigate.filter_by_confidence(event.data.objects, 0.8)
frigate.filter_by_confidence(objects, min_confidence)
-- Filter objects by type
-- Usage: local people = frigate.filter_by_type(event.data.objects, "person")
frigate.filter_by_type(objects, object_type)
-- Check if object is in specific zone
-- Usage: if frigate.in_zone(obj, "driveway") then ...
frigate.in_zone(obj, zone_name)
-- Format object info for logging
-- Usage: log.info(frigate.format_object(obj))
frigate.format_object(obj)
-- Describe camera activity in human-readable format
-- Usage: log.info(frigate.describe_activity(event.data))
frigate.describe_activity(data)
-- Check if this is a new detection (not just movement)
-- Usage: if frigate.is_new_detection(new_objects, old_objects) then ...
frigate.is_new_detection(new_objects, old_objects)
-- Get camera activity summary for state tracking
-- Usage: state.set("camera.last_activity", frigate.get_activity_summary(event.data))
frigate.get_activity_summary(data)