Shelly flood binding isn't generating an alarm in telegram

  • Platform information:
    • Hardware: J4125/RAM 8gb /128gb ssd
    • OS: Linux Openhab123 5.19.0-46-generic #47-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 16 13:30:11 UTC 2023 x86_64 GNU/Linux
    • Java Runtime Environment: openjdk version “11.0.17” 2022-10-18
      OpenJDK Runtime Environment Temurin-11.0.17+8 (build 11.0.17+8)
      OpenJDK 64-Bit Server VM Temurin-11.0.17+8 (build 11.0.17+8, mixed mode)
    • openHAB version: 3.4.1
  • Issue of the topic: please be detailed explaining your issue
    Hi,
    I have a Shelly Flood (firmware: 20230913-112632/v1.14.0-gcb84623) connected via binding to Openhab 3.4.1. After some time the Shelly status changes to ERROR:COMM, device isn’t available or not responding. When I simulate a water alarm I don’t get an error message to my telegram.
    This is the script I’m using:
    var ScriptExecution = Java.type(“org.openhab.core.model.script.actions.ScriptExecution”);
    var telegramAction = actions.get(“telegram”, “telegram:telegramBot:xxxxxxxxxxxxxxxx”)

if (itemRegistry.getItem(‘Shelly_Flood_Feuchtigkeitsalarm’).getState() == ‘ON’)
{
telegramAction.sendTelegram(“Shelly Flood: Water!”)
}

When I change ON against OFF and execute the script manually an alarm is send to telegram.

Do you have any idea what I’m doing wrong?
Thanks in advance.

Please use code fences when posting code to the forum. Also mention which language you are using. This looks like Nashorn JS.

I would guess the problem is that getState() returns a State Object, not a String. You either need to call toString() on the state or compare it to OnOffType.ON instead of "ON".

Thanks for the fast reaction. The script type is ECMAScript (ECMA - 262 Edition 5.1). I’ll test your recommended changes.