Upgrade to 2.5.5 and having issues with JSR223

From something in the helper libraries or something of yours?

just having
from org.openhab.core.library.types import PercentType
caused the playsound to error

Sure… and I understand why it would! So, this must have been a personal module?

No it was an openhab module. I haven’t created any personal modules in openhab

None of the Jython helper library modules have that import. Which module are you seeing with…

run the code below and it will fail. comment out from org.openhab.core.library.types and it runs
sorry I don’t know what it was for anymore my testswitch has grown pretty long over time

scriptExtension.importPreset(“RuleSupport”)

scriptExtension.importPreset(“RuleSimple”)

from core.triggers import ItemCommandTrigger, ItemStateChangeTrigger, ItemStateUpdateTrigger, CronTrigger

from org.openhab.core.library.types import PercentType

from core.actions import Audio

class Update_Power_CheckRuleon(SimpleRule):

def __init__(self):

    self.triggers = [

        TriggerBuilder.create()

                .withId("MyTrigger")

                .withTypeUID("core.ItemStateChangeTrigger")

                .withConfiguration(

                    Configuration({

                        "itemName": "My_TestSwitch_1",

                        #"state":"ON"

                    })).build()

    ]

def execute(self, module, input):

    Audio.playSound ("doorbell.mp3",PercentType(100));

automationManager.addRule(Update_Power_CheckRuleon())

do you know what help library i’d need to import a config file like below

import config as _cfg

Thanks for any help you have on this…Greg

Thanks for all the help I’ve got this one working now.
The playsound is just if anyone else has the problem coming for 2.4 it could be the issue

OK… so it was a personal module after all, so it all makes sense! Just shout if you need anything else!

It’s an openahb module not mine see below.
image

org.openhab.core.library.types.PercentType is an OH package, but you are importing it in a personal module…

Instead, use…

from core.jsr223.scope import PercentType

… rather than going after it directly. If this is in a script, then no import is needed, since PercentType is included in the default script scope. Either way, it is MUCH easier to use the decorators for creating rules.