2019-12-11 16:45:04.766 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'test': An error occurred during the script execution: null
No, this is just an example.
2019-12-11 16:45:04.766 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'test': An error occurred during the script execution: null
No, this is just an example.
This wonāt work right now. Changes needed in the bindings code.
Sorry for asking as Iām late to the party it might be written here but I couldnāt find it.
First, is it really an updated Action as the thread title says ?
openhab> bundle:list|grep -i teleg
217 x Active x 80 x 1.14.0 x openHAB Telegram Action
265 x Active x 80 x 2.5.0 x openHAB Add-ons :: Bundles :: Telegram Bi
I have added telegram to the list of bindings during my upgrade to 2.5 and already had it configured as an action before (action = telegram
in services/addons.cfg
).
Shouldnāt that have been a v2 action when starting OH now ?
BTW docs on telegram action are also still marked as v1.
Second, do I still need to install a .jar as the latest post in this thread say ? As you see itās contained in 2.5 (release).
Third, Iām having trouble with the binding docs. They seem to be a copy of the v1 action docs ?
They say
Open a browser and invoke
https://api.telegram.org/bot/getUpdates(where
is the authentication token previously obtained)
I can retrieve the token from BotFather, it is something like nnnnnnnnn:ZZZZZZZZZZZZZZZZZZZZZZ
Entering that string instead of <token>
does not result in anything useful.
Moving on, docs also say in the next line
Look at the JSON result to find the value of
id . That is the chatId. Note that if using a Telegram group chat, the group chatIds are prefixed with a dash that must be included in the config file. (e.g. bot1.chatId: -22334455)
What config file ?? Thereās telegram.cfg
which is still there for me for the v1 action.
But v2 bindings do not have config files so ?
FWIW I had been using the v1 action to successfully work so I think I can use that existing chat and donāt need to do this again.
But this is inconsistent. What if someone starts with v2 ?
Fourth and finally, Iām struggling getting telegram action to work under Python:
The code
telegram = actions.get("telegram", "telegram:telegramBot:nnnnnnnnn")
telegram.sendTelegram("Hello *World* " + u"\U0001F44D")
for now results in
2019-12-16 15:35:40.462 [ERROR] [jsr223.jython.battery monitor ] - Traceback (most recent call last):
File "/etc/openhab2/automation/lib/python/core/log.py", line 51, in wrapper
return fn(*args, **kwargs)
File "<script>", line 46, in battery_check
AttributeError: 'NoneType' object has no attribute 'sendTelegram'
BTW, as nnnnnnnnn I would need to use the ChatID, correct ? Docs say āuidā which is confusing.
It has an action, but not similar to the old one. You can get the action by calling getActions("telegram", "telegram:telegramBot:nnnnnnnnn")
. You can then execute the actions (there are more actions available now, compared to the old v1).
I think you need to remove the action, as of now it is included in the binding, there is no seperate Action.
No, just install from PaperUI or specify it in the addons.cfg. The included one in 2.5 is the latest version.
I donāt really get this. The returned token from BotFather is exactly what you will need to enter as your token.
The docs says:
Open a browser and invoke
https://api.telegram.org/bot<token>/getUpdates
(where<token>
is the authentication token previously obtained)
This is for obtaining the chatId
. However it is not always working (for groups it never worked for me).
The best I found is this bot:
Add this bot temporarly to your group or to your conversation to get the chatId.
Yes this is just a copy and paste error from v1. No cfg file, since this is a v2 addon.
You donāt need that. However if you have your old telegram.cfg you can just copy and paste everything from it.
Sorry I canāt help with this. I have just started to rewrite everything in Python, and I struggle with easier problems :). But it seems like it canāt get the Thing from the API? NoneType surely donāt have sendTelegram attribute, and usually this happens in Python when your reference is null (None in Python).
No. The token is always in that format. nnnnnnnnn:ZZZZZZZZZZZZZZZZZZZZZZ
. That is what you have to set as token in the binding configuration.
You need to get the chatId seperately, and set it as a chatId in the binding configuration.
I can see now what you mean by uid
No this is not your chatId. This is your Thing UID given by openHAB. This is how it works for all v2 actions.
Your points for the README are right. Not the best because it was copy-pasted from the old one. I will try to update it when I have some time.
Ok, thanks upfront for your answers on binding status.
Ok, @ZzetT, @rkrisi please do.
But anyone easily can. So some other kind benefitting soul from this thread, would you please update the docs for action and binding ?
Just go to the official page, at the bottom thereās a link to Github, edit, boom. Docs maintainers will review your input before itās published.
Ok, but I think you mean to create the Thing, donāt ? telegram binding shows up in PaperUI with no editable fields. I created the Thing via the bindingās autoconfig now.
Thatās the step I have been missing so far. Donāt forget to put that into the docs.
Possibly yes. Your response made me aware that I hadnāt created that yet.
But even now that Iāve added it, same error. Hesitating to restart OH.
Yes you need to config the Telegram Thing first (if preferably you use PaperUI). I might be wrong in terms of used names here, but there is no binding configuration which some binding has, you can specify all parameters and settings at Thing level (when you create your Telegram Thing Bot).
Even the RulesDSL has this kind of problem. It wonāt work until you restart. And if you restart just that bundle it wonāt work also (at least for me).
I will try. But what is wrong with the action page? It is clearly a v1 Action and has nothing to do with this v2 binding.
Restarted now but it didnāt help.
Youāre right, the action doc page is fine as-is. But we should stop speaking of a Telegram action and from now refer to the binding to avoid misunderstandings (yes, itās still telegram āactionsā to use inside the code, but no OH(1) action any more).
Yes you are right. Maybe this thread should be edited with a new, simpler name. The confusion is caused by, because earlier you really needed to install an updated Action to use these features. But now everything is merged into the binding.
I somehow assumed, that the old Telegram action will be finally removed by the maintainers. On Github there is a table what actions will be replaced: https://github.com/openhab/openhab2-addons/issues/6179
Maybe we should raise an issue or maybe there was a reason to keep it?
But yes, the action and the binding shouldnāt be used in parallel!
I would also vote for closing this thread and create a new one in case there are issues. There is too much old information in here.
Agreed and done.
On my first steps I did both, creating a new Binding and editing the action.
Agreed
Well, thatās a long term plan to retire all OH1 bindings (and all actions) at some point around OH3, but this is not meant to be handled per binding but in one go. The issue you linked was merely to collect information as first we need to determine whatās in use, where do v2 bindings exist as a replacement etc. Now with this binding to fully replace the v1 action thereās no need left for you to take action now.
I can close it if you like but thatāll not stop its posts from appearing in search results.
Still having trouble, the following python code should work
telegram = actions.get("telegram", "telegram:telegramBot:nnnnnnnnn")
telegram.sendTelegram("Hello *World* " + u"\U0001F44D")
What would need to be the 2nd argument to actions.get?
just the name of that Thing? Is that arbitrary, i.e. whatever I call the Thing to be named ?
Or does it have to be some specially coded string with special tags like telegram:telegramBot:
?
The 2nd line fails because the first does not return an object so I have a āNoneTypeā object, i.e. NULL.
Probably because I can see the Thing is offline. I gave token and chatID in PaperUI.
Any idea how to debug that ?
Yes it is the name of the Thing. If you use Thing files, then what you declared there. If you use PaperUI, you will see it in the Things tab.
I have this in PaperUI. So it must be:
telegram = actions.get("telegram", "telegram:telegramBot:d7544ea3")
for me
Thanks. The Thing got online for a while but after I changed the formatting type it went offline again ??
And
2019-12-16 23:36:22.776 [WARN ] [binding.telegram.bot.TelegramActions] - Failed to send telegram message: Unauthorized
Hmm, that still seems like for me that it has some problems with the tokenā¦ But I donāt know what can be wrong there.
Or maybe chatId. But that is not a validated value if Iām right. Only token.
Ah, it was a typo in the token. Not sure why it temporarily went ONLINE with the wrong one but ok.
now it works, thanks for your patience!
No problem
However I have seen this behaviour in multiple bindings. I donāt know how these are handled, but maybe some default behaviour is to go ONLINE after saving? And clearly validating these values takes some timeā¦
Iām trying to work out the new Tgram binding, however when I enter the ChatID, it show somekind of empty drop down, simce like its looking for something.
And most important, I canāt save the thing
Same API/ChatID from working Telegram action configuration
Enter the chatID and press RETURN
Afterwards you can save the Thing
The problem here is that there is no acknowledgment whether the connection to the Telegram server was successfully established. So what the binding does is, it creates a connection, sets the thing to ONLINE and in case there is an error, a callback is called by the underlying Telegram library. In that callback we check for the 401 error code (āUnauthorizedā) which usually means that the token is wrong and sets the thing back to OFFLINE.
However, if everything went fine, there is no callback called, so itās also not possible to set the status to ONLINE later. In addition, we have to distinguish somehow between a āconfiguration errorā meaning that e.g. the login data is wrong and a āper message errorā meaning that there was only a problem with a particular message, but not with the general configuration (which should not set the status to OFFLINE).