When trying to send to a group chat where ID starts with a minus, the message is not delivered right now. Error message is:
2019-11-15 22:44:29.680 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Send telegram with Fixed Message': An error occurred during the script execution: Could not invoke method: org.openhab.binding.telegram.bot.TelegramActions.sendTelegram(org.eclipse.smarthome.core.thing.binding.ThingActions,java.lang.Long,java.lang.String,java.lang.Object[]) on instance: null
My bot is admin of the group.
Then I tried get_id bot to confirm the group chat ID and received a different ID, but also starting with minus. But this time the group chat ID was not 9 numbers, but 13.
2019-11-15 22:52:03.052 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Send telegram with Fixed Message': An error occurred during the script execution: Integer literal is out of range: 1001315583123
Dont know if this can be done easily… but wouldn’t it be better to let the binding convert from chat ID to the long value… maybe easier for most of the users? wdyt?
This is something related to the OH environment/rule engine which is based on Java.
Having a method which takes an Integer (where no “L” is required) and converts to a Long doesn’t work, because then the number is already casted to 32 bit and the information is lost. Having a method that takes the chat Id as a String is also not so easy because 1. everbody would need to adapt their existing rules 2. some APIs would become ambiguous, because currently you can call sendTelegram() with two Strings (message + format) but if it is also chat id (as String) + message, then we would need to give the API another suffix to make it unambiguous again.
Running openhab 2.5~M5 on Proxmox VE 5.4 Debian 9 container. All the files are there and permissions are fine. I’ve restarted a few times and cleared the cache to be sure but nothing.
Edit: Downloaded latest bundle from jfrog and dropped into addons folder and everything seems to work. Must be something with karaf.
Hi @Olymp, did you notice my earlier post? I thought I was only one with the problem. As a short term workaround you can also try downloading the bundle from here,
Yes, thanks again! it works.
I just could not send the image. Who could do this, tell me how, please!
telegramAction.sendTelegramPhoto("file://192.168.215.3/oh-cfg/html/network.jpg", "sent from openHAB")
log:
2019-11-22 17:00:19.903 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Send telegram with Image Item image and caption': java.net.ConnectException: Failed to connect to api.telegram.org/2001:67c:4e8:f004:0:0:0:9:443
After Switching from Telegram action to the new Telegram binding I get a lot of messages in openhab.log: 2019-11-23 09:55:04.697 [WARN ] [ng.telegram.internal.TelegramHandler] - Telegram exception: GetUpdates failed with error_code 409 Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
Sending telegram messages works though.
Anyone with the same issue?
Thanks for the great binding and all the work. In general it is working for me but does somebody has any hint how an jsr223 jython rule would look like which is using the action of this binding to send telegram messages? I have some trouble with getting the right thinks imported. Something like telegram = actions.get(“telegram”, “telegrambot:uid”) seems to be not working within some of the python files.
I did have problems finding out as well.
My item:
String TelegrMess “Telegram Message” (G_jdbc) {channel=“telegram:telegramBot:MYBOT:lastMessageText”}
My rule:
val action = getActions("telegram","telegram:telegramBot:MYBOT")
rule "Lights Off"
when
Item G_Lights changed to OFF
then
action.sendTelegram("Das Licht wurde ausgeschaltet!")
end
Thanks for the example. Unfortunately this dosen’t solve the issue.
For the standard rule engine it is working for me somehow. Also for a jython rule which is located in the openhab2/automation/jsr223/personal folder. So the below code is working fine:
from org.slf4j import LoggerFactory
from core.rules import rule
from core.triggers import when
@rule("Test rule for new telegram binding")
@when("Item presence changed")
def someFunction(event):
telegram = actions.get("telegram","telegram:telegramBot:xxxxxxx")
telegram.sendTelegram("Hello *World* " + u"\U0001F44D")
But if I will use some functions from openhab2/automation/lib/python/personal were I have stored my common code - it is not working anymore with the same code like above (same imports). During runtime i will get a “module actions has no attribute get” error which is not the case with the previous file location.
Any ideas?
EDIT:
I’ve solved the problem. For guys with the same problem. You have to add
from core.jsr223 import scope
from core.jsr223.scope import actions
to the imports if you move the file to the lib subfolder. This was missing somehow.
br, christian
@mhilbush, @waitz_sebastian and @Olymp
I re-added the functionality to send pictures via http(s) that are only reachable from your local network.
Use the “file://” protocol only for files on your local hard drive.
That usually means that you are alraedy running a bot for the same token. That can for example happen if you created two things with the same bot token or you have two different OH instances running in parallel. This is not allowed by the Telegram API. If you think you have only instance running, then please try to restart OH.