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

from Soti.Connect.SemanticEngine.Conversions import Converter

print("Loading GenToSatoBluetoothDarkness Converter")

class GenToSatoBluetoothDarkness(Converter):
    def Execute(self, args):
        if not args or len(args) == 0:
            return None
        
        try:
            val = int(args[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)