Access the messageRawEvent data from Telegram binding?

running openHAB 4.1.1 on a raspberry pi 4 using jython scripting

Is there a way to access the Telegram messageRawEvent? I see the "ChannelTriggeredEvent ", but I want to be able to trigger on it and access the data.

2024-12-11 15:37:16.746 [INFO ] [openhab.event.ChannelTriggeredEvent ] - telegram:telegramBot:Telegram:messageRawEvent triggered {"message_id":242780,"from":{"id":206431234,"is_bot":false,"first_name":"xxx","last_name":"xxx","username":"xxx","language_code":"en"},"date":1733960230,"chat":{"id":206431234,"type":"private","first_name":"xxx","last_name":"xxx","username":"xxx"},"location":{"longitude":-111.990425,"latitude":27.287766}}

Specifically, I am interested in getting the location data.

hi,
just link it to an item :wink:
Thing - Channels - show advanced - Raw Message Received - and link it to a string item with trigger event string profile. then you get this as string item and you could get your information with json…

Greets.

That would be great … but I dont have “Advanced” on my Channels for the Telegram Binding. :slight_smile:


This?

Thats weird … I dont have it … im on 4.1.1

Oh hmmm.
:man_shrugging:t3:
That’s weird…

I’ve done a hack for now … when I want the location data (very rare), I wrote a system function that extracts it from the events.log with something like:

tail -n 10 /var/log/openhab/events.log | grep location

It works but its far from eligant :slight_smile:

Do you have this channels in your code tab?

  - id: messageEvent
    channelTypeUID: telegram:messageEvent
    label: Message Received
    description: "Message encoded as JSON.<br /> Event payload could contain the
      following, but `null` values will not be present: <ul> <li>Long
      `message_id` - Unique message ID in this chat</li> <li>String `from` -
      First and/or last name of sender</li> <li>Long `chat_id` - Unique chat
      ID</li> <li>String `text` - Message text</li> <li>String `animation_url` -
      URL to download animation from</li> <li>String `audio_url` - URL to
      download audio from</li> <li>String `document_url` - URL to download file
      from</li> <li>Array `photo_url` - Array of URLs to download photos
      from</li> <li>String `sticker_url` - URL to download sticker from</li>
      <li>String `video_url` - URL to download video from</li> <li>String
      `video_note_url` - URL to download video note from</li> <li>String
      `voice_url` - URL to download voice clip from</li> </ul>"
    configuration: {}
  - id: messageRawEvent
    channelTypeUID: telegram:messageRawEvent
    label: Raw Message Received
    description: Raw Message from the Telegram library as JSON.
    configuration: {}
  - id: callbackEvent
    channelTypeUID: telegram:callbackEvent
    label: Query Callback Received
    description: "Callback Query response encoded as JSON.<br /> Event payload could
      contain the following, but `null` values will not be present: <ul>
      <li>Long `message_id` - Unique message ID of the original Query
      message</li> <li>String `from` - First and/or last name of sender</li>
      <li>Long `chat_id` - Unique chat ID</li> <li>String `callback_id` - Unique
      callback ID to send receipt confirmation to</li> <li>String `reply_id` -
      Plain text name of original Query</li> <li>String `text` - Selected
      response text from options give in original Query</li> </ul>"
    configuration: {}
  - id: callbackRawEvent
    channelTypeUID: telegram:callbackRawEvent
    label: Raw Callback Query Received
    description: Raw Callback Query response from the Telegram library encoded as JSON.
    configuration: {}
 

Or maybe re-add your telegram bot with the same thingID.
the channels get re-created and maybe then the advanced are there…

I’ll try re-adding it … my code tab has:

UID: telegram:telegramBot:Telegram
label: Telegram Standard Bot
thingTypeUID: telegram:telegramBot
configuration:
  proxyType: SOCKS5
  longPollingTime: 25
  parseMode: HTML
  chatIds:
    - "206xxxx49"
    - "19xxxx99"
    - ""
  botToken: 18xxxxx903:xxxx5DzPn64bk
channels:
  - id: lastMessageText
    channelTypeUID: telegram:lastMessageText
    label: Last Message Text
    description: Contains the latest message text as a string
    configuration: {}
  - id: lastMessageURL
    channelTypeUID: telegram:lastMessageURL
    label: Last Message URL
    description: Contains the URL of the latest message
    configuration: {}
  - id: lastMessageDate
    channelTypeUID: telegram:lastMessageDate
    label: Last Message Date
    description: Contains the latest message date as a DateTime
    configuration: {}
  - id: lastMessageName
    channelTypeUID: telegram:lastMessageName
    label: Last Message Name
    description: Contains the latest message senders name as a string
    configuration: {}
  - id: lastMessageUsername
    channelTypeUID: telegram:lastMessageUsername
    label: Last Message Username
    description: Contains the latest message senders username as a string
    configuration: {}
  - id: chatId
    channelTypeUID: telegram:chatId
    label: Chat Id
    description: Contains the id of chat from where the message was received.
    configuration: {}
  - id: replyId
    channelTypeUID: telegram:replyId
    label: Reply Id
    description: Contains the id of the reply which was passed to sendTelegram() as
      replyId. This id can be used to have an unambiguous assignment of the user
      reply to the message which was sent by the bot.
    configuration: {}

Well, well, well … I added a new telegram Thing and viola! now I see the advanced …

Can someone explain this behavior to me? Perhaps I am missing other features for other Things!

Thanks Baschtlwaschtl !!

In think your thing is very old maybe…
So if there are added channels in the binding they get visible only after re-adding the thing.
I know this from camera and Shelly binding.
Greets

1 Like