Skip to content

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:
TypeOperations
SwitchTurn on, Turn off, Toggle, Set to…
ModeSet to…
CounterAdd one, Subtract one, Reset, Set to…
TimerStart, Cancel, Pause, Resume, Finish now
NumberSet to…, Increase, Decrease
Text, Date & timeSet 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:

  1. Device Changed → porch motion detected
  2. IF → {{ virtual('porch-cooldown') != 'active' }}
  3. (true) Set Device → porch light on
  4. (true) Set Virtual Accessory → Porch Cooldown → Start

Count the door opens, alert past ten:

  1. Device Changed → back door contact opens
  2. Set Virtual Accessory → Door Opens Today → Add one
  3. IF → {{ nodes['virtual1'].data.state > 10 }}
  4. (true) Notify → "Back door opened {{ nodes['virtual1'].data.state }} times today"

Reset it overnight:

  1. Schedule → 00:00
  2. Set Virtual Accessory → Door Opens Today → Reset

Set the mode when everyone leaves:

  1. Device Changed → presence sensor inactive
  2. 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, active or paused — compare against those, not against a number.
  • 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