# Subscribe to internal state
ref = subscribe(:state_variable) do |notify|
notification.value # => value of the status variable that triggered this notification
notification.old_value # => the value of the variable before this change
# Also comes with the subscription information
notify.sys_name # => The system name
notify.sys_id # => The system ID this value originated from
notify.mod_name # => The generic module name
notify.mod_id # => The module database ID
notify.index # => The device index
notify.status # => the name of the status variable
# And a reference to the subscription should you want to unsubscribe
unsubscribe(notification.subscription)