Yup, easily use a rule for this.
You can create a group gThermostats
and add all those items as members. Then trigger on member-of-group. It’s more efficient than filtering by tags.
Then rule could look like this (done in JRuby)
ORDER = %w[none cool heat]
rule "Update global thermostat summary" do
changed gThermostats.members
run do |event|
summary = event.group.members
.map(&:state)
.compact
.map(&:to_s)
.max { |a, b| ORDER.index(a) <=> ORDER.index(b) }
event.group.update(summary)
end
end