When I upgraded to OH4 a few telegram actions stopped working. I installed the Nashorn add-on, selected the type of script (ECMAScript (ECMA - 262 Edition 5.1)) and have the scripts working now.
Got some telegram messages tied into sunrise and sunset rules that change some exterior lights and then notifies me that the rule has run.
var telegramAction = actions.get("telegram", "telegram:telegramBot:botname")
telegramAction.sendTelegram("Astro binding says, 'sunrise'.")
Another script sends a message that one of the garage doors is open or closed along with a snapshot from the surveillance camera:
var telegramActionMe = actions.get("telegram", "telegram:telegramBot:botname")
telegramActionMe.sendTelegram("Garage door West is open.")
2023-09-03 09:42:30.204 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'Doorbell' failed: TypeError: Can not invoke method [jdk.dynalink.beans.OverloadedDynamicMethod
] with the passed arguments; they do not match any of its method signatures. in <eval> at line number 3
Makes me think it’s a syntax problem like I need to escape certain characters in the URL but I’ve tried that a few different ways and couldn’t figure out what was causing the issue. Both URLs work from a browser so I know the images are viewable with the URLs I’ve given.
When you upgrade to the JSScripting add-on, you automatically get the extensive helper library. This comes with it’s own documentation (which is, admittedly long, but that’s because there are so many different things that it helps with):
So, for the two simple cases you’ve posted, the good news there are no changes required to upgrade to the newer JS version at the moment. Just install the JSScripting add-on, go to the rule script and click on the arrow icon on the bottom right. That will expand the panel and let you select which rule engine should run that rule.
If you reduce your function call to just types, what you’ve done is
The error is telling you that one string parameter is not one of the viable options for sendTelegramPhoto and that at the very least you need a second parameter. You can’t just send the photo URL, you also need to include a caption string (although it’s possible that if you really don’t want a caption you can just use "" as the caption string, I don’t know).