Having trouble with JSONata expression in switch node

The error is: Invalid JSONata expression: Invalid context key
Here is my node:
image

[{"id":"1e0a4c9d9b44c848","type":"switch","z":"3a2942f23b8df6dc","name":"Bedroom?","property":"payload.cover","propertyType":"msg","rules":[{"t":"jsonata_exp","v":"payload.cover != \"cover.bedroom_blind\" or\t    (payload.cover = \"cover.bedroom_blind\" and \t    $globalContext(homeassistant.homeAssistant.states[\"person.daniel_brunt\"].state) = \"home\" and \t    $globalContext(homeassistant.homeAssistant.states[\"input_boolean.sleep_mode\"].state) = \"off\")\t","vt":"jsonata"}],"checkall":"false","repair":false,"outputs":1,"x":619,"y":1120,"wires":[["3aabdce8ca72cedb","dad60146b95672f9"]]}]

Is homeassistant.homeAssistant.states["person.daniel_brunt"].state a message property or a string.
What happens if you use a debug set to JSONata and set it to

$globalContext(homeassistant.homeAssistant.states["person.daniel_brunt"].state)

, is it undefined or thdoes it throw an error

Thanks for opening my eyes to another use of the Debug node!
It should be a string! This works:
$globalContext('homeassistant.homeAssistant.states["person.daniel_brunt"].state')

Thanks!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.