Thanks for all of the suggestions. I have it working as desired.
The problem to solve was "Notify me once a day if you don't see any data for more than an hour" This is designed to keep bugging me if there is a long term outage if my IOT device stops sending data.
I use a time control to run the code once an hour.
Here is my code:
NotifyInterval = minutes(1440) %Interval in minutes to send a notification, set to once a day
%get the current date time
CurrentTime = datetime('now','TimeZone','America/New_York') % use your TimeZone What time is it "right now" (local) when running this
%tinterval - calculated desired outage time interval
DataLossInterval = CurrentTime - hours(1) % here 1 hour without data
%Read the last data from channel
[Data,LastTimeData] = thingSpeakRead(124xxxx , 'fields', [1]);
LastTimeData % to see the time of your last recorded point
nodata = LastTimeData < DataLossInterval
if nodata
% Its past when we expected data so we need to notify but only want to notify every x hours
'no data'
%Read the last time we notified from a private channel
[Data,LastNotify] = thingSpeakRead(145xxxx ,'ReadKey','xxxxxxx', 'fields', [1]);
LastNotify % to see the time of your last recorded point you can erase this line
notify = CurrentTime - LastNotify
if notify > NotifyInterval
' time to notify'
thingSpeakWrite(145xxx ,1,'WriteKey','xxxxxxxx'); % write a new entry to the last notified channel
%Do what ever you want here to notify here, I post to a slack channel that notifies my phone
dd = ['No Data Received since: ' datestr(LastTimeData)]
response = webwrite('https://xxxxxgroup.slack.com/services/hooks/slackbot?token=xxxxxxxxxxxxxxxxxxx&channel=%23channeame',dd)
end
end