import clr
clr.AddReference('Soti.IoT.SemanticEngine.Conversions')

from Soti.IoT.SemanticEngine.Conversions import Converter

print("Loading ZebraDarknessToPercentSupportingBothRanges Converter")

class ZebraDarknessToPercentSupportingBothRanges(Converter):

	def Execute(self, myList = [], *args):
		val = 0
		if(myList[1] == "zpl"):
			val = round((int((float(myList[0])) * 100) / 30))
		elif (myList[1] == "cpcl"):
			val = round(((int(myList[0])+100) * 100) / 300) 
		return val




plugin = ZebraDarknessToPercentSupportingBothRanges("ZebraDarknessToPercentSupportingBothRanges")

store.AddConverter(plugin)