JSONata

There are three functions added for JSONata expressions within the Home Assistant nodes.

  • $entity() returns the entity that triggered the node
  • $prevEntity() returns the previous state entity if the node is an event node
  • $areaDevices(areaId) returns all devices associated with a specific area ID.
  • $areaEntities(areaId) returns all entities associated with a specific area ID.
  • $area(lookup) returns an area based on a provided lookup value, or all areas if no lookup value is provided. The lookup value can be an area ID, an entity ID, or a device ID.
  • $deviceEntities(device_id) returns all entities associated with a specific device.
  • $device(lookup) returns a device based on a provided lookup value. The lookup value can be an entity ID or a device name.
  • $entities() returns all entities in the cache
  • $entities(entity_id) returns a single entity from cache matching passed in entity_id

Expose Lodashopen in new window functions

  • $sampleSize(collection, [n=1]) https://lodash.com/docs/#sampleSizeopen in new window

    Gets n random elements at unique keys from collection up to the size of collection.

  • $randomNumber([lower=0], [upper=1], [floating]) https://lodash.com/docs/#randomopen in new window

    Produces a random number between the inclusive lower and upper bounds. If only one argument is provided a number between 0 and the given number is returned. If floating is true, or either lower or upper are floats, a floating-point number is returned instead of an integer.

When JSONata appears in the conditional dropdown it expects the expression to return a boolean, true or false.

screenshot

When it is chosen with a conditional, not JSONata it will return a value of the evaluated expression that will be checked against the conditional chosen.

screenshot

Also see: