So when the motion detector triggers, or when the door sensor state is changed, I’d like to display this under a “Motion Last Detected …” or “Door Last Opened…” sitemap frame.
I have tried adapting other’s rules to my situation, with no luck so far. Here’s the current nonworking rule:
rule "Multisensor 6 Motion"
Item MultiSensor_Motion changed
var epoch = new DateTime((MultiSensor_Motion.state as Number).longValue)
val DateTime datetime = new DateTime(epoch)
val String time = datetime.toLocalTime().toString("HH:mm")
val String date = datetime.toLocalDate().toString("dd-MM-yyyy")
logInfo("motion.detection.rules", "Trial Part 1" + time.toString + " op " + date.toString)
MultiSensor_Motion.sendCommand(datetime , new DateTimeType() )
Any help with this would be greatly appreciated. In addition, this is my first post, so I apologize if I broke any community rules.
The root of your problem here is that MultiSensor_Motion is a Switch type Item. You can’t send a Switch a datetime for a command. You especially cannot send it two datetimes for one command.
As you’ll find in design note @hafniumzinc suggested, you really need to use a separate Item.
The limitation with a profile method is that it always updates the timestamp. If you instead choose to use a rules based method, you get more control so that for example you can truly record when the door opens (and not when it closes).
Thank you both for this! The profile method worked flawlessly; I am now working to display the date and time in a more user-friendly format. Currently it’s “2020-07-19 20:11”, and I’d like it to be a bit more ‘friendly.’
@rossko57, what would a rule like that look like? Do you have a template or another forum post you could link me to?