Not sure what msg.topic is, as htbset is a count.
something like below should work to increment/deincrement the count
if (typeof(msg.payload)==="boolean"){ // payload has to be true or false
var hbtset = flow.get("hbtset") || 0; //fetch count or default 0
if (msg.payload === true) {
hbtset++; // if true plus 1
}else{
hbtset--; //if false minus 1
}
flow.set("hbtset", hbtset) // save count
}
return msg;