npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pimatic-telegram

v1.1.14

Published

Plugin to send notifications and execute commands using the Telegram messaging platform

Downloads

36

Readme

pimatic-Telegram

Pimatic plugin to provide bi-directional integration with Telegram, the free messaging system for mobile and desktop devices

Features

  • Send messages from Pimatic to your (mobile) device equipped with the Telegram messaging client
  • Limited HTML markup in messages supported such as <b> <i> and <a href=...> tags as per Telegram API
  • Send device and rule requests to Pimatic from your Telegram client
  • Rule requests may contain variables to be used in rule actions
  • Support for Text / Video / Audio / Image / GPS Location Message types (gps location shows up as a map in the client)
  • Support for sending messages to all enabled or multiple individual recipients
  • Enable / disable recipients for receiving messages and / or sending requests from a messaging client
  • Messages and file paths may contain Pimatic variables
  • Two factor authentication (Trusted sender list maintained in Pimatic, with session password)
  • User-configurable authentication timeout
  • Polling mechanism prevents exposing your Pimatic environment
  • Allowed file formats depend on Telegram supported formats, .mp3 (audio), .mp4, .avi (video), .jpg and .png (photo) have been validated (Max. allowed file size for media and doc types is 50MB, set by Telegram.org)

Rule syntax and examples:

Action syntax: send < text | video | audio | photo | doc | gps > telegram to [sender* | recipient1 ... recipientn ] < "text with $variables" | "/local/path/with/$variables/to/file" | "$latitude;$longitude" >

Predicate syntax: telegram received "user-defined-keyword" [with arguments]

  • send text telegram to sender "reply only to user having send request" -- *Can only be used in combination with "telegram received... rule predicate"

  • send text telegram to "<b>ALERT!</b> Pimatic detected movement in room: <i>$room</i> while nobody is home! Is someone unexpectedly making you a cup of tea?"

  • send video telegram to Owner1 Owner2 "/home/pi/front_door_camera.mp4"

  • when it is 08:00 and $phone-child.location is not "School" then send gps telegram to Parent1 Parent2 "$phone-child.latitude;$phone-child.longitude"

  • when telegram received "turn off heating" then set temp of Thermostat to 15

  • when telegram received "myscript" with arguments then execute "myscript \$var1 \$var2"

  • when it is 23:00 then reload <TelegramReceiverDevice>

If you do not provide recipients, a message will be sent to all enabled recipients

Requests sent from messaging client to Pimatic:

help - lists available built-in commands and user-defined predicates list devices - Summary list of all devices get device device_name | device_id - get details on a device set temp of Thermostat to 15 - execute a device action using rule action syntax user defined keyword - Triggers a defined rule with the "telegram received 'user-defined-keyword'" predicate user defined keyword <var1> ... <varN> - Triggers a defined rule with the "telegram received 'user-defined-keyword' with arguments" predicate

Preinstallation Requirements

  • A Telegram client (www.telegram.org)
  • A Telegram bot
  • Obtain chatID's for all Telegram recipiets you would like to receive messages

Installation and Configuration:

Obtain a Telegram client

  • Go to the Apple store or Android Play store to install the client on your mobile and follow instructions

Create a Telegram Bot

  • With your Telegram client start a conversation with @BotFather
  • Send a message: /newbot
  • Follow the on-screen instructions
  • When choosing a name for your bot, ensure the name ends in "bot", e.g. MyAwesomePimaticBot
  • After completing the required steps, BotFather will provide a token (similar to this: 784324329:EETRNJU3jQEGWQdjNv3llb4bnDSDREGuuuL)
  • Make sure you copy this token, and keep it secret !

Obtain your chatID

  • With your Telegram client start a conversation with the ID bot (@myidbot)
  • send /getid
  • The bot will respond with your ChatID, e.g. 315123987
  • Take note of this number
  • Repeat for each recipient you want to register in Pimatic

Install the Plugin (required for using the send telegram functions)

  • Install Pimatic-Telegram via the frontend (preferred) and check if it has been activated.
  • Add the API token in the designated field, and add recipients as required (Friendly name, chat ID, enabled flag)

Alternatively add it to the Plugin section of your config.json:

{
  "plugin": "telegram",
  "apiToken": "<bot api_token from previous step>",
  "active": true,
  "recipients": [
    {
      "name": "FriendlyName",
      "userChatId": "<user_id from previous step>",
      "enabled": true,
      "admin": false 
    }]
}

You can specify multiple recipients. Enabled should be set to true for a recipient to receive messages

  • Check if the plugin has been activated. If not activate it
  • Restart Pimatic

Install a Telegram Receiver device (required to send client requests to Pimatic, and enable the telegram received rule predicate)

  • Define a new TelegramReceiverDevice via the frontend (preferred)
    • Make sure to change the default secret !
  • To allow users to send requests to Pimatic, set their Admin flag to enabled in the frontend or in config.json
"recipients": [
  {
    "name": "FriendlyName",
    "userChatId": "<user_id from previous step>",
    "enabled": true,
    "admin": true 
  }
  • Restart Pimatic
  • Send commands from Telegram to Pimatic, a good start is sending "help"

Alternatively add the device directly to the Devices section your config.json:

{
  "secret": "change_me_now!",
  "auth_timeout": 5,
  "id": "telegram-receiver",
  "name": "Telegram Receiver",
  "class": "TelegramReceiverDevice"
}

Known issues:

  • "execute" cannot be used as a keyword, to prevent vulnerability exploitation. This is a security concern and will not likely be changed in the near future

FAQ

Please check the following first, as all similar issues have been solved so far by taking the below steps:

I have installed Pimatic-Telegram, but no messages are sent, and no errors are logged. Whats wrong?

  • Has the plugin been activated? Check in the section "Install the Plugin"
  • Have you activated the intended recipient? Or has the enabled check box accidentally not been checked?
  • Restart Pimatic, this is often forgotten after the installation and or configuration.

I have installed Pimatic-Telegram, but I cannot send instructions to Pimatic

  • Have you defined a TelegramReceiverDevice and configured appropriately?
  • Have you set the admin flag for the recipient sending commands and is the recipient enabled?
  • Have you restarted Pimatic after making these configuration changes?

If you took these troubleshooting steps, you have probably rebooted Pimatic twice, once after installation, and once after configuration changes