Set Virtual Accessory
Category: Action
Changes a virtual accessory — a mode, switch, counter, timer or number that your automations own. This is how an automation writes to the state it later reads back with virtual().
When to use
- Put the house into a mode (
Home Mode→Away) from a schedule or a location trigger - Start a cooldown timer so an automation can't re-trigger for a while
- Count something — door opens, motion events, failed requests
- Record a value for other automations to read, without touching a real device
Configuration
- Virtual accessory — which one to change. Create them from the home or room menu; if the list is empty there are none in this home yet.
- Do what — the operation. Only the ones the chosen type can perform are offered:
| Type | Operations |
|---|---|
| Switch | Turn on, Turn off, Toggle, Set to… |
| Mode | Set to… |
| Counter | Add one, Subtract one, Reset, Set to… |
| Timer | Start, Cancel, Pause, Resume, Finish now |
| Number | Set to…, Increase, Decrease |
| Text, Date & time | Set to… |
- To — the value, for Set to…. A Mode offers its own options; everything else takes free text and supports
{{ templates }}. - For — for a Timer Start only. Overrides the accessory's configured duration; leave blank to use its own.
Changing the selected accessory re-checks the operation and drops it if the new type can't perform it, so a node can't be left asking a counter to pause.
Output data
{{ nodes['<id>'].data.accessoryId }}— The virtual accessory that was changed{{ nodes['<id>'].data.operation }}— The operation performed{{ nodes['<id>'].data.state }}— The value after the change{{ nodes['<id>'].data.success }}— Whether it succeeded
state is the value after the operation, so a downstream node can branch on the result rather than re-reading it and racing whatever changes it next.
Examples
Cooldown — don't re-trigger for five minutes:
- Device Changed → porch motion detected
- IF →
{{ virtual('porch-cooldown') != 'active' }} - (true) Set Device → porch light on
- (true) Set Virtual Accessory → Porch Cooldown → Start
Count the door opens, alert past ten:
- Device Changed → back door contact opens
- Set Virtual Accessory → Door Opens Today → Add one
- IF →
{{ nodes['virtual1'].data.state > 10 }} - (true) Notify → "Back door opened {{ nodes['virtual1'].data.state }} times today"
Reset it overnight:
- Schedule → 00:00
- Set Virtual Accessory → Door Opens Today → Reset
Set the mode when everyone leaves:
- Device Changed → presence sensor inactive
- Set Virtual Accessory → Home Mode → Set to →
Away
Tips
- An automation changing a virtual accessory does not re-trigger itself through it — engine actions don't feed back in as device events.
- Read a virtual accessory anywhere a condition or template is accepted:
{{ virtual('home-mode') == 'Night' }} - A read-only virtual accessory can still be set by this node. Read-only only removes the dashboard control, so people can't knock a value out of step by hand.
- Deleting a virtual accessory leaves any node pointing at it failing. Check what references one before removing it.
- Timers report
idle,activeorpaused— compare against those, not against a number.
Related
- Virtual Accessories — what they are and how to create them
- IF — branch on a virtual accessory's value
- Delay — pauses this automation; a Timer is visible to all of them