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.
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.