 |
Subscribe to this site |
|
log_filter_tgs
def result = true;
def on_tag_result = false;
def off_tag_result = false;
def values = [
"17": "on",
// "18": "on",
"18": "off",
];
def msg = [
'tags': [
17,
// 18,
],
];
def has_on_tags = values.findAll {tagId, status -> status == 'on' }.each {tagId, status ->
def tags_found = msg.tags.find { it.toInteger() == tagId.toInteger(); } ? true : false;
on_tag_result = on_tag_result || tags_found;
}.size() > 0 ? true : false;
def has_off_tags = values.findAll {tagId, status -> status == 'off' }.each {tagId, status ->
def tags_found = msg.tags.find { it.toInteger() == tagId.toInteger(); } ? true : false;
off_tag_result = off_tag_result || tags_found;
}.size() > 0 ? true : false;
println 'has_on_tags: ' + has_on_tags;
println 'on_tag_result: ' + on_tag_result;
println 'has_off_tags: ' + has_off_tags;
println 'off_tag_result: ' + !off_tag_result;
println '';
result = result && (has_on_tags || has_off_tags) && (!has_on_tags || on_tag_result) && (!has_off_tags || !off_tag_result);
println 'result: ' + result;