Output Messages
Updated October 15, 2021 by crxporter and ShaquuStarting with version 1.3.0
, there are some changes in the hap
part of the messages coming from this node.
Previous versions would have msg.hap.newValue
and msg.hap.oldValue
only if the message originated from the Home.app. Additionally there was a message part msg.hap.context
with some information that nobody really knows what it means, but it was there.
From version 1.3.0
on, the parts of the message will always include msg.hap.newValue
and msg.hap.oldValue
. If the message originated from the Home.app (iPhone, iPad, Mac, or Home Hub automation) then the message will contain msg.hap.context
(deprecated, will be empty object {}
), and the new part msg.hap.session
.
Note, msg.hap.context
is left for compatibility with previous versions of the plugin but is considered deprecated and will be removed in version 2.0.0
. Please transfer your flows to use msg.hap.session
instead.
The new message part msg.hap.session
will exist only if the message is initiated from Home.app. This object will include the following:
msg.hap.session.sessionID
: UUID unique to each HAP connectionmsg.hap.session.username
: A unique identifier for each user, essentially a random string which will be different for each Apple ID your home is shared withmsg.hap.session.remoteAddress
: the IP address where the message came from (iPhone, iPad, computer, Apple TV, HomePod, etc)- ‘msg.hap.session.localAddress` : the IP where your HomeKit bridge lives, will match wherever you host NodeRED
The msg.hap.session
object can therefore be used to determine who or which device is initiating changes to your setup.
Additionally, it is recommended to use a rule checking whether msg.hap.session
exists to determine whether a message originated in Home.app or was a pass-through message from your HomeKit node. This is useful to prevent loops when “allow message pass through” is enabled on your bridge or accessory.