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

from Soti.IoT.SemanticEngine.Conversions import Converter

print("Loading GenToSatoBluetoothDarkness Converter")

class GenToSatoBluetoothDarkness(Converter):
    def Execute(self, myList = [], *args):
        if not myList or len(myList) == 0:
            return None
        
        try:
            val = int(myList[0])
        except ValueError:
            return None

        max_val = 100
        min_val = 1
        result = val if val <= max_val else max_val
        result = result if result >= min_val else min_val

        rounded_result = int(result / 10.0 + 0.5)
        rounded_result = max(1, rounded_result)

        return rounded_result


plugin = GenToSatoBluetoothDarkness("GenToSatoBluetoothDarkness")

store.AddConverter(plugin)