- Platform information:
- Hardware: VM
- OS: Ubuntu 18.04
- Java Runtime Environment: 8
- openHAB version: 2.4
Trying to write a rule that gives an audio alarm via tts when my basement floods. I hooked it up to the office light for now, but the “say” action is not working. How do I generate any action other than logging?
scriptExtension.importPreset("RuleSupport")
scriptExtension.importPreset("RuleSimple")
from org.slf4j import LoggerFactory
log = LoggerFactory.getLogger("org.eclipse.smarthome.automation.flood_sensors");
class FloodSensorRule(SimpleRule):
def __init__(self, name):
self.name = name
self.triggers = [
TriggerBuilder.create()
.withId("FloodSensorTrigger")
.withTypeUID("core.ItemStateUpdateTrigger")
.withConfiguration(
Configuration({
"itemName": self.name
})).build()
]
def execute(self, module, input):
log.info("Got event!")
# say('THIS LINE CROAKS!')
When I uncomment the last line and trigger the rule I get something like this:
13:34:05.968 [INFO ] [se.smarthome.automation.flood_sensors] - Got event!
13:34:05.969 [ERROR] [tomation.core.internal.RuleEngineImpl] - Failed to execute rule '2a4b0be6-3cd0-4384-b57d-b02903bd0e69': Fail to execute action: 1
13:34:05.971 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - 2a4b0be6-3cd0-4384-b57d-b02903bd0e69 updated: RUNNING
13:34:05.971 [DEBUG] [tomation.core.internal.RuleEngineImpl] -
java.lang.RuntimeException: Fail to execute action: 1
at org.eclipse.smarthome.automation.core.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1207) ~[216:org.eclipse.smarthome.automation.core:0.10.0.oh240]
at org.eclipse.smarthome.automation.core.internal.RuleEngineImpl.runRule(RuleEngineImpl.java:1004) [216:org.eclipse.smarthome.automation.core:0.10.0.oh240]
There are many example scripts out there that have import statements like this:
from openhab import triggers
Alas, they all fail for me with import error of this kind:
13:37:04.612 [ERROR] [ript.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/flood_sensors.py': ImportError: No module named openhab in <script> at line number 4
I think I have everything installed correctly. Any suggestions what to do?
Thanks!