Once your sensors are setup in Apple HomeKit, you can use Shortcuts to send the data to Adafruit IO. The two sensors that will be used to demo this are the Eve Temperature and Humidity Sensor and the Eve Light and Occupancy Sensor. Both of these sensors are Matter sensors so they are easy to setup. You should be able to adapt these Shortcuts for whatever sensors you are using though.
To send data from a HomeKit sensor to itsaSNAP, you'll start with the Get the state of My Home action. You'll select your sensor to pass to the action. You'll use the itsaSNAP Send Value action to send the data to your feed.
Format the Data
Some sensor values include extraneous labels, like °C. As a result, the data sent to your Adafruit IO feed would be, for example, 23.57°C. You probably don't want those labels included if your goal is to log the value of a sensor. You can edit the value in the Shortcut to remove the label.
Start with a Get the state of My Home action and select your sensor. Next, use a Replace Text action. In the replace area, type in the text that you want to remove from the data. In this case, it was °C from the temperature reading. Don't include any text in the second part of the action and pass the result from the Get the state of My Home action as the text to modify. In the itsaSNAP Send Value action, you'll send the Updated Text to your feed.
Here is another example of removing a value label. In this Shortcut, the light level from a light sensor has the lx label removed to only send the numerical value to Adafruit IO.
Match and Replace Data
Another scenario may be that you want to send a specific value to a feed if a sensor returns a certain value. You can do this by using the Match Text action.
Start with the Get the state of My Home action and select your sensor. Next, use a Match Text action. Insert the value that you want to match from the returned value from the sensor. Then, you can use an If action to check if there was a match. The syntax for this in actions is if the result has any value. If you wanted to check that a match wasn't made, you would select does not have any value. Inside the If action, you'll use the itsaSNAP Send Value action to send your manual value to your feed.
In this example, the occupancy sensor being used returns Yes or No as a value. This response does not work well with an Adafruit IO dashboard for monitoring a true/false state. To change this value to a numerical value, a 2 is sent if a No is found, otherwise a 1 is sent for Yes. This allows an Indicator block to be used on a Dashboard for the feed from the sensor.
Adafruit IO Dashboard
Speaking of Dashboards, you can take all of this data and create a Dashboard to view the sensor values over time. You can use Automations to automate running the Shortcuts to log the data to Adafruit IO. If you want to log the data consistently throughout the day, you can follow the directions in this Playground Note to create a looping Shortcut with alarms.
Page last edited October 02, 2024
Text editor powered by tinymce.