homebridge-script2 still supports legacy formats for backward compatibility.
| Name | Value | Required | Notes |
|---|---|---|---|
name |
(custom) | yes | Accessory name |
on |
(custom) | yes | ON command |
off |
(custom) | yes | OFF command |
fileState |
(custom) | fileState or state | File-based state source |
state |
(custom) | fileState or state | Script-based state source |
on_value |
(custom) | no (default "true") |
Match token for ON state |
polling |
true/false |
no | Poll state command periodically |
polling_interval |
integer ms | no | Poll interval |
polling_on_start |
true/false |
no | Immediate startup poll |
state_cache_ttl_ms |
integer ms | no | Burst-read cache TTL |
reset_state_cache_on_set |
true/false |
no | Reset cache after manual set |
fail_on_state_exit_code |
true/false |
no | Treat non-zero state exit as read failure |
unique_serial |
(custom) | no | Recommended unique serial |
"platforms": [
{
"platform": "Script2Platform",
"name": "Script2",
"devices": [
{
"name": "Outlet 1",
"on": "/opt/scripts/on.sh 1",
"off": "/opt/scripts/off.sh 1",
"state": "/opt/scripts/state.sh 1",
"on_value": "true"
}
]
}
]| Name | Value | Required | Notes |
|---|---|---|---|
accessory |
"Script2" |
yes | Must be Script2 |
name |
(custom) | yes | Accessory name |
on |
(custom) | yes | ON command |
off |
(custom) | yes | OFF command |
fileState |
(custom) | fileState or state | File-based state source |
state |
(custom) | fileState or state | Script-based state source |
on_value |
(custom) | no (default "true") |
Match token for ON state |
unique_serial |
(custom) | no | Recommended unique serial |
"accessories": [
{
"accessory": "Script2",
"name": "Outlet 1",
"on": "/opt/scripts/on.sh 1",
"off": "/opt/scripts/off.sh 1",
"state": "/opt/scripts/state.sh 1",
"on_value": "true"
}
]Use the newer platform format with:
on_off_switchesstateless_switches
It provides a better UI and clearer configuration intent.
This migration is usually smoother if names stay the same.
- Homebridge accessory UUIDs in this plugin are name-based in platform mode (
homebridge-script2:<name>). - If you move a legacy
devicesitem intoon_off_switchesorstateless_switchesand keep the exact samename, Homebridge usually preserves accessory identity. - If you rename, HomeKit treats it as a new accessory identity.
Recommended steps:
- Stop Homebridge.
- Move one legacy
devicesitem at a time intoon_off_switchesorstateless_switches. - Keep the exact same
name. - Remove the moved entry from
devices. - Start Homebridge and verify in Home app.
Treat this as a fresh migration.
- Accessory mode and platform mode are different registration paths.
- In practice, many users will need to re-place accessories into rooms and re-link scenes/automations after migration.
Recommended steps:
- Backup
config.json. - Remove legacy
accessoriesentries for Script2. - Add a new
platformsentry withon_off_switches/stateless_switches. - Restart Homebridge and re-check Home app placement/scenes/automations.