This example demonstrates how to handle module-level settings in SinricPro.
SinricPro supports two types of settings:
- Configuration for the module (dev board) itself
- Registered via:
sinric_pro.on_set_setting(callback) - Examples: WiFi retry count, log level, heartbeat interval
- Callback signature:
async def callback(setting_id: str, value: Any) -> bool
- Configuration for individual devices
- Registered via:
device.on_setting(callback) - Examples: Device-specific modes, thresholds, tilt settings
- Callback signature:
async def callback(setting_id: str, value: Any) -> bool
from sinricpro import SinricPro
sinric_pro = SinricPro.get_instance()
# Register module-level setting callback
async def on_module_setting(setting_id: str, value: Any) -> bool:
if setting_id == "wifi_retry_count":
set_wifi_retry_count(value)
return True
return False
sinric_pro.on_set_setting(on_module_setting)- Replace
YOUR_DEVICE_ID_HEREwith your actual device ID - Set environment variables or replace credentials:
export SINRICPRO_APP_KEY="your-app-key" export SINRICPRO_APP_SECRET="your-app-secret"
- Run the example:
python modulesettings_example.py
Module settings can have different value types:
- Integer:
wifi_retry_count,heartbeat_interval - String:
log_level - Boolean:
debug_mode - Float:
temperature_offset
Always validate the value type and range before applying settings.