Self-update of background paint isn't working well

With this code we compare the number of the bed with the last one we use, then we paint the background of this last one and the other values will return at his own colors, but when use the code as we can see in the image below it don't get updated and still got painted the last and the new but the new is only half paint, the border is another code we use and it is functional and it is basically the same code so the background paint cells need to be in there and not where are both of them, we need to stop or save the program and then the green background cells get where it need to be, so the code is barely functionally. We use the tag you see and linked, the other color working with "no usar", "no sensa", "" work perfectly.

camnum = self.view.params.CamNum
	last = int(system.tag.read("[Paint]ASRS/Last_A").value)
	
	if camnum == last:
		return "#46FF64"
         else
            if value == "":
		     return '#C1C7C9'
	        if value == "no usar":
		     return '#C1C7C9'
	        if value == "no sensa":
		      return '#C1C7C9'
	        else:
	        	return '#83B1CF'

I don't know if this a result of your formatting but the spacing/indentation of this looks wrong.
Edit: If I copy and paste the code into an editor it seems that 'actual' indentation is present.

You are also missing a : behind the else statement, which likely means your script is not running at all and erroring, I would check your client logs.

You can probably rewrite the entire script as

camnum = self.view.params.CamNum
last = int(system.tag.read("[Paint]ASRS/Last_A").value)

if camnum == last:
	return "#46FF64"
elif value == "":
	return '#C1C7C9'
elif value == "no usar":
	return '#C1C7C9'
elif value == "no sensa":
	return '#C1C7C9'
else:
	return '#83B1CF'

When/where is this script being called? I would recommend instead of a tag read, create a custom property on the component that binds to "[Paint]ASRS/Last_A", then you can just reference that property instead of making a call to system.tag.read*

2 Likes