In order to have the dashboard icons react to the PIR sensor, and change between two chosen images, there needs to be some code running each time a feed is updated.
Adafruit IO has you covered here, there is a no-code option called Actions which allow scheduled or reactive reactions when a feed gets a new value. (Soon there will also be Blockly integration, see a sneak-peek on the blog.)
You can easily setup an action to change the indicator icon to a thumbs-up if the PIR sensor value is 1, and similarly to thumbs down if the feed gets set to zero. Why not get creative and choose some more appropriate images. (I used the Edit Component option to show me the searchable images list and then copied the names down to use later in the actions.)
I've also setup an action to change the on-board NeoPixel to Red or Green depending on if the Metro-S2 can "see" anyone. This helps massively with debugging, and could be left enabled for the end-user to also see, but as it takes up some of the rate limit it makes sense to remove those two once testing is completed.
Before we create our actions we need somewhere to send the image name when the PIR sensor detects movement.
To achieve this you can create a new feed on the Adafruit IO Feeds page. Name it something clearly recognisable like icon-name.
To setup an action you need to visit the Adafruit IO Actions page, and then use the New Action button.
Select Reactive Action from the dialog of Action types.
Configure the first action to check with the following settings:
If: "Currently in Office?" [PIR feed]
Is: "Greater than or equal to"
Comparison Value: 1
Then: "publish a message to:"
Feed: "icon-name" [Feed for icons]
With: "thumbs-o-up" [Person is here icon]
Limit Every: "Ten Seconds"
Now repeat for the opposite condition, e.g. the "Is:" comparison should be "less than", and the "With:" value should be thumbs-o-down or your chosen icon to mean no movement.
I've also created two more nearly identical actions, but these publish a message to the NeoPixel feed, by sending red-green-blue hexadecimal values (like those used in HTML webpages that start with a hash[#]). The maximum value for each color pair is FF, so for full red I used #ff0000, and for fully green the value is #00ff00. The hexadecimal colours are case insensitive (ff = FF).
Text editor powered by tinymce.