Is this possible?
Announcement
Collapse
No announcement yet.
Post Messages from HomeSeer To a Telagram Group
Collapse
X
-
Start here and read all about it : https://haefelfinger.ch/posts/2019/2...mqtt-telegram/ then : https://www.iotwithus.com/send-messa...-and-node-red/
For integration with HomeSeer : https://shop.homeseer.com/products/mcsmqtt-software-plug-in-for-hs3 or https://shop.homeseer.com/products/mqtt-software-plug-in-for-hs3
It is possible if you're willing to do the mileage.
Eman.
TinkerLand : Life's Choices,"No One Size Fits All"
-
There is an easier way, without MQTT. We use our Telegram bot in a group to get event messages immediately (doorbell, washer done, dryer done, car charged, smoke alarm, CO alarm, water leaks).
- (Set up a Telegram account and the group).
- Talk to BotFather and follow the steps to setup your bot (with the /newbot command, naming it, giving it a username and if wanted a description via /setdescription).
- Invite your bot to the group.
- During the process you've gotten your bot's token, which looks something like 123456789:AbC1DeF2gHIJkLm34NOPqrsTuV5WxYZ
- In a browser go to https://api.telegram.org/bot<YourToken>/getUpdates (so in this example, https://api.telegram.org/bot12345678...xYZ/getUpdates) and lookup the chat ID for your bot with the group, which could look like -987654321
- To send your message from an event, choose Run Another Program or Process, edit to /Windows/System32/curl.exe and set the parameters to "https://api.telegram.org/bot<YourToken>/sendMessage?chat_id=<YourChatID>&text=<YourText>" (so in this example, "https://api.telegram.org/bot123456789:AbC1DeF2gHIJkLm34NOPqrsTuV5WxYZ/sendMessage?chat_id=-987654321&text=Hello world!")
(This used to be possible with the urlaction command, but stopped working about 2 months ago due to Telegram updating to TLS1.3).
That's it.
More info: https://core.telegram.org/bots/apiPlugins I developed for HS4: Somfy Local, MiLight (LimitlessLED), Updates, Volvo (VoC), OpenTherm Gateway (OTGW)
Running HS4 Pro on Windows 10 Pro on a Synology VM, with Node-RED running as a container.
- Likes 1
Comment
-
That worked perfectly Bernold Thank you. Does the parameters allow for device variables ($$DTR:3688 (strings)
Comment
-
Not that way (works only for email and speech, I think). You can however use hs.DeviceValue(3688).
To use this, rewrite the event to Run a Script or Script Command, Immediate script command (instead of Run Another Program or Process):
- hs.launch("curl.exe","https://api.telegram.org/bot123456789:AbC1DeF2gHIJkLm34NOPqrsTuV5WxYZ/sendMessage?chat_id=-987654321&text=Device value="&hs.DeviceValue(3688),"/Windows/System32/",0)Plugins I developed for HS4: Somfy Local, MiLight (LimitlessLED), Updates, Volvo (VoC), OpenTherm Gateway (OTGW)
Running HS4 Pro on Windows 10 Pro on a Synology VM, with Node-RED running as a container.
Comment
-
Originally posted by Bernold View PostNot that way (works only for email and speech, I think). You can however use hs.DeviceValue(3688).
To use this, rewrite the event to Run a Script or Script Command, Immediate script command (instead of Run Another Program or Process):
- hs.launch("curl.exe","https://api.telegram.org/bot123456789:AbC1DeF2gHIJkLm34NOPqrsTuV5WxYZ/sendMessage?chat_id=-987654321&text=Device value="&hs.DeviceValue(3688),"/Windows/System32/",0)
Comment
-
Originally posted by ServiceXp View Post
Thank you for all your help. It posts the word "Device" instead of the string.HS 4.2.8.0: 2134 Devices 1252 Events
Z-Wave 3.0.10.0: 133 Nodes on one Z-Net
Comment
-
Originally posted by ServiceXp View Post
Thank you for all your help. It posts the word "Device" instead of the string.
Also, it's probably better to use hs.DeviceValueEx, otherwise decimal values are truncated.
So, this should work:
hs.launch("curl.exe","https://api.telegram.org/bot123456789:AbC1DeF2gHIJkLm34NOPqrsTuV5WxYZ/sendMessage?chat_id=-987654321&text=Device%20value="&hs.DeviceValueEx(3688),"/Windows/System32/",0)
Edit:
Just thought of another way. The key is to get the quotes parsed to curl.exe, which you can do with Chr(34):
hs.launch("curl.exe",Chr(34)&"https://api.telegram.org/bot123456789:AbC1DeF2gHIJkLm34NOPqrsTuV5WxYZ/sendMessage?chat_id=-987654321&text=Device value = "&hs.DeviceValueEx(3688)&" (More spaced text here if wanted :-)"& Chr(34),"/Windows/System32/",0)Plugins I developed for HS4: Somfy Local, MiLight (LimitlessLED), Updates, Volvo (VoC), OpenTherm Gateway (OTGW)
Running HS4 Pro on Windows 10 Pro on a Synology VM, with Node-RED running as a container.
- Likes 1
Comment
-
How would I create a script using it?
I tried this: But it generated a log Error (Below)
Code:Sub SendTelagramNewMedia(Optional ByVal Parms As String = "") hs.WriteLog("Telagram", "(Telagrram.vb script) Sending New Media Notice" & Parms) hs.launch("curl.exe",Chr(34)&"https://api.telegram.org/bot123456789:AbC1DeF2gHIJkLm34NOPqrsTuV5WxYZ/sendMessage?chat_id=-987654321&text=Device value = "&hs.DeviceValueEx(3688)&"(TEST"& Chr(34),"/Windows/System32/",0) End Sub
Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Telagram.vb: Syntax error. Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Telagram.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
If I use the Immediate method. This is what is published.
"Device value = 0 (TEST"
Comment
-
Ok so I have it correctly posting using the Immediate method. This is what it ended up looking like. (thank you so much @Bernold)
hs.launch("curl.exe",Chr(34)&"https://api.telegram.org/bot123456789:AbC1DeF2gHIJkLm34NOPqrsTuV5WxYZ/sendMessage?chat_id=-987654321&text="&hs.DeviceString(3688)&" THIS IS A TEST "& Chr(34),"/Windows/System32/",0)
HOWEVER..
I would like to take everyone's suggestion and make use of this as a script, but no matter what I try, I continue to get the same errors as above.
Any idea's on what I should be looking for?
Comment
-
Originally posted by ServiceXp View PostOk so I have it correctly posting using the Immediate method. This is what it ended up looking like. (thank you so much @Bernold)
hs.launch("curl.exe",Chr(34)&"https://api.telegram.org/bot123456789:AbC1DeF2gHIJkLm34NOPqrsTuV5WxYZ/sendMessage?chat_id=-987654321&text="&hs.DeviceString(3688)&" THIS IS A TEST "& Chr(34),"/Windows/System32/",0)
HOWEVER..
I would like to take everyone's suggestion and make use of this as a script, but no matter what I try, I continue to get the same errors as above.
Any idea's on what I should be looking for?Plugins I developed for HS4: Somfy Local, MiLight (LimitlessLED), Updates, Volvo (VoC), OpenTherm Gateway (OTGW)
Running HS4 Pro on Windows 10 Pro on a Synology VM, with Node-RED running as a container.
Comment
-
Originally posted by ServiceXp View Post
I would like to take everyone's suggestion and make use of this as a script, but no matter what I try, I continue to get the same errors as above.
Any idea's on what I should be looking for?HS 4.2.8.0: 2134 Devices 1252 Events
Z-Wave 3.0.10.0: 133 Nodes on one Z-Net
Comment
-
Originally posted by sparkman View Post
How are you calling the script? A screenshot of your event's script action parameters would be useful. The other thing to think about (once you have it running) is that you may be able to use the HS url functions, rather than using curl.Plugins I developed for HS4: Somfy Local, MiLight (LimitlessLED), Updates, Volvo (VoC), OpenTherm Gateway (OTGW)
Running HS4 Pro on Windows 10 Pro on a Synology VM, with Node-RED running as a container.
Comment
-
Originally posted by Bernold View Post
I was using urlaction until 2 months ago when Telegram upgraded to TLS1.3
Code:System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls13
HS 4.2.8.0: 2134 Devices 1252 Events
Z-Wave 3.0.10.0: 133 Nodes on one Z-Net
Comment
Comment