I have many battery powered devices to monitor and I like to update a “LastSeen” Item once the Thing has sent some data to see that the device is still alive.
I tried to do this by using the “Thing received update” but it somehow does not trigger.
rule "Badezimmer Ventilator last update"
when
Thing "mqtt:topic:brokerhome:mysensors_badezimmer_ventilator" received update
then
BadezimmerFan_LastSeen.sendCommand(new DateTimeType())
end
The thing “mqtt:topic:brokerhome:mysensors_badezimmer_ventilator” has 4 channels but not each channel is updated in each transmission from the device. So can’t I use the “mqtt:topic:brokerhome:mysensors_badezimmer_ventilator” base to update the BadezimmerFan_LastSeen if any of the 4 channels is receiving any data.
That’s because there is no such trigger. Things and Channels don’t receive updates, Items do. There is a specially type of Thing Channel that does generate events, but those can’t be linked to Items and they are used to trigger rules directly and do not usually carry a state (e.g. “Sunset just happened!” from the Astro biding). But these represent events, not states.
You either need to write the rule to trigger when one of the Items updated. Or, use the timestamp Profile.
but I would need to link the “BadezimmerFan_LastSeen” item to all 4 channels of the mqtt Thing so that each channel can trigger the timestamp update or am I wrong?
In theory, you may link a DateTime type Item to multiple channels using timestamp profile on each channel, in order to update the one Item as and when any of the channels update.
(The same channels can also be linked to other Items in the ordinary way, of course.)
In practice there is a bug which will ruin this -
So I think your best option is a rule triggered from any of your Items receiving update, which directly updates your timestamp Item.
The alternative, if your channels all have the same topic, or a similar enough topic to use wildcards, is to create a new string channel listening for that topic and link that with a timestamp profile to your timestamp Item. (The payload doesn’t matter at all)
Did the aggregation functions for DateTime Group Items ever get fixed? That could be another way perhaps. Create one DateTime Item per Channel with the timestamp profile and then put them all in a Group:DateTime:MAX.