Is there any way to trigger in node-red on the change of the “date” attribute on what is a multi-dimensional attribute for a sensor?
A normal Event State node should trigger on it, if the Ignore state change section is not used.
You then just need a function node to check if the date has changed.
Something like this.
var lastDate=flow.get("lastDate") || 0;
flow.set("lastDate",msg.attributes.date);
if (msg.attributes.date!=lastDate)
{
return msg;
}
Thanks for this, here’s where I landed on the function:
const ha = global.get('homeassistant').homeAssistant.states;
const today = new Date();
today.setDate(today.getDate());
const lastWorkoutDate = ha["sensor.oura_ring_activity"].attributes.workout_1.date;
const workoutDate = new Date(lastWorkoutDate);
if (lastWorkoutDate == today) {
var newmsg = {}
newmsg.payload = workoutDate
return newmsg
}