piconut Posted February 16, 2023 Posted February 16, 2023 Is there a substitution variable for the "last changed" date and time info for any particular variable? I have a program to look for sensors that have had no activity for a long time (like 2 weeks for a hidden door sensor). I have a variable for every time the sensor is activated and I have a program that alerts me when more than 2 weeks has gone by since the sensor had any activity, but I want to put the time and date of last activity into the notification that goes out and can't figure out how to do that. I searched a number of times in the forum and came up with nothing. I also looked at the wiki and it doesn't appear there. I was hoping that I just missed it somehow but I'm afraid that it isn't available. Thanks, Scott
Solution MrBill Posted February 16, 2023 Solution Posted February 16, 2023 I don't think there is a substitution for the strings your looking for. You can crudely get what you want by using 2 integer variables (in addition the one your already using). Integer variables in an ISY can have a decimal value these days (when they were originally named they couldn't), and the decimal should be set to 2 for these. One for date and one for time. These don't need to be state variables. In your program that increments the activity counter add lines to set those variables such as: $iDoorLastOpen.date = [Current Day of Month] $iDoorLastOpen.date /= 100 $iDoorLastOpen.date += [Current Month (Jan=1, Feb=2, etc.)] $iDoorLastOpen.date Init To $iDoorLastOpen.date which will yield and integer variable value such as 2.16 (today). likewise build similar for time using [Current Minute] + [Current Hour] $iDoorLastOpen.time = [Current Minute] $iDoorLastOpen.time /= 100 $iDoorLastOpen.time += [Current Hour] $iDoorLastOpen.time Init To $iDoorLastOpen.time this will yield a time in the same format 16.38 (I assume the hours will be 24-hour format, but I've never used [Current Hour] for anything before. Unfortunately the separator is . instead of / or : however this is one method to achieve being able to read the date/time in the notification. 1
piconut Posted February 17, 2023 Author Posted February 17, 2023 Wow, thank you very much! That's worked for me except the minutes don't seem to be working. I ran my test program at 5:50 PM and the time showed 17.00, and I would have expected 17.55. Here is the program: OCS02 activity - [ID 009B][Parent 0272] If 'Garage / OSC02 Up-Down Sensor / OCS02-Opened' is switched On Then $OCS02_activity += 1 Wait 1 second $OCS02_DoorLastOpen.date = [Current Day of Month] $OCS02_DoorLastOpen.date /= 100 $OCS02_DoorLastOpen.date += [Current Month (Jan=1, Feb=2, etc.)] $OCS02_DoorLastOpen.date Init To $OCS02_DoorLastOpen.date Wait 1 second $OCS02_DoorLastOpen.time = [Current Minute ] $OCS02_DoorLastOpen.time /= 100 $OCS02_DoorLastOpen.time = [Current Hour] $OCS02_DoorLastOpen.time Init To $OCS02_DoorLastOpen.time Else - No Actions - (To add one, press 'Action')
piconut Posted February 17, 2023 Author Posted February 17, 2023 ...and I just re-ran that program again (at 6:11 PM) and the time shows 18:00. So for some reason the minutes aren't showing up properly. The Date (2.16) is working fine.
tmorse305 Posted February 17, 2023 Posted February 17, 2023 10 minutes ago, piconut said: $OCS02_DoorLastOpen.time = [Current Hour] You forgot the '+' sign. 2
piconut Posted February 17, 2023 Author Posted February 17, 2023 5 minutes ago, tmorse305 said: You forgot the '+' sign. D'oh! Thank you. Now it works. 1
Recommended Posts