thx @dan!
sure, time is short these days don’t worry !!
maybe another @developer might join in and will have some ideas / codework for your plugin.
-
[Implemented] Receives messages (Telegram)
pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
Hi @Andi,
This feature is up next for implementation, but may take some time however. Without having investigated feasibility, I would like to pitch the following as a starting point for discussion with the current users of the plugin.
When pitching in, remember the functionality we are discussing here is: “Allow Pimatic to receive commands from the Telegram app”- Expose a device “TelegramReceiver” with user configurable attributes:
Allowed commands (Array / list)
- “name” - friendly name of command
- “command” - would be a / command sent to the bot via the telegram interface
- “variable” - the variable to set upon receiving the command
- “value” - the value to set the variable to when receiving the command - optional / would default to yes/no
- “enabled” - boolean allowing to disable certain commands temporarily or permanently
- Extend the Plugin attributes:
- Add boolean attribute to the recipient list “Allow control”
This would allow the following hypothetical scenario:
- TelegramReceiver polls at scheduled interval
- User sends bot command e.g. /AllOff
- TelegramReceiver checks if user is allowed and command is defined
- TelegramReceiver sets variable $bot_command to value “yes”
- User defined rule executes on state change / value of the variable
Dan
"Screw the captain. It's the engineer running the ship!"
pimatic-telegram, pimatic-tts, pimatic-woox, pimatic-lg-smart-tv, pimatic-spotify, pimatic-wakeuplight and some not-announced plugins - Expose a device “TelegramReceiver” with user configurable attributes:
-
This would be great,
maybe you could also able to use a code for authentication.
So- user sends a command
- bot ask for authentication-code
- user authenticates
- pimatic set the allowed-value to true
Mit freundlichen Grüßen
Chris -
Hi @chris, good suggestion to consider. Would this already be covered by the “Allow control” setting? My thoughts are the ChatID is issued by Telegram and is not user configurable, preventing spoofing the ID. In a way this would be an implicit authentication. If we add your suggestion it would become Two-Factor-Authentication (“something you have + something you know”). It would be a higher level of security of course !
Dan
"Screw the captain. It's the engineer running the ship!"
pimatic-telegram, pimatic-tts, pimatic-woox, pimatic-lg-smart-tv, pimatic-spotify, pimatic-wakeuplight and some not-announced plugins -
the chatID would be the first step i think.
a code authentication could be the next level.
and another could be the command authentication
(set different levels for commands)
–> e.g. so that not everybody could shutdown the device
–> e.g. so the shutdown command is code-lockedbut lets begin in small steps…
Mit freundlichen Grüßen
Chris -
All, below a first cut of the device interface, giving you some more insight into intended user functionality…
"Screw the captain. It's the engineer running the ship!"
pimatic-telegram, pimatic-tts, pimatic-woox, pimatic-lg-smart-tv, pimatic-spotify, pimatic-wakeuplight and some not-announced plugins -
Hi @Dan . Very Nice Plugin. As a suggestion you should look on the rule action parser from the API. It is quite simple to use it and all commands are out of the box accessible like in a rule.
Also an predicate provider would prevent the detour over an variable.
For security reasons, an additional attribute on any devices for access control would be good.
I have written the plugin-xmpp to send messages to pimatic. Have a look on it for inspiration. I will switch immediately to telegram if it can receive messages.
And I will support you if needed.The telegram bot has a lot of interest functions.
But not all commands should be passed to pimatic. Shell executes and pimatic with root privileges is still a problem.
-
@kosta said in Receives messages (Telegram):
Hi @Dan . Very Nice Plugin. As a suggestion you should look on the rule action parser from the API. It is quite simple to use it and all commands are out of the box accessible like in a rule.
Also an predicate provider would prevent the detour over an variable.
For security reasons, an additional attribute on any devices for access control would be good.
I have written the plugin-xmpp to send messages to pimatic. Have a look on it for inspiration. I will switch immediately to telegram if it can receive messages.
And I will support you if needed.Hi @kosta thanks for your valuable input, and offer for support! I will certainly have a peek at the pimatic-xmpp code to see if similar design can be done (better stolen well than created poorly . The reason the variable - > value design came to mind was to allow for maximum user configurability by allowing the user to define rules in the backend.
However, I am open to suggestions of course"Screw the captain. It's the engineer running the ship!"
pimatic-telegram, pimatic-tts, pimatic-woox, pimatic-lg-smart-tv, pimatic-spotify, pimatic-wakeuplight and some not-announced plugins -
Hi All,
Just a quick update as there has been some radio silence: An early version with message receiving capability is now completed.
I will not implement setting variables and then using these as rule conditions. Instead the logic will be very similar to plugin-xmpp - @kosta thanks for letting me borrow from your code.
Implementation of additional security still needs to be done (asking for a secret before executing rules or actions). Hopefully there will be something to test around the weekend !Dan
"Screw the captain. It's the engineer running the ship!"
pimatic-telegram, pimatic-tts, pimatic-woox, pimatic-lg-smart-tv, pimatic-spotify, pimatic-wakeuplight and some not-announced plugins -
All,
I have just uploaded a version with the Message Receive feature implemented.
You can now send commands to Pimatic from Telegram, executing rules and actions on devices.
Please read the updated plugin documentation, or on npmjs.org (If the Pimatic site has not picked up the new readme yet) carefully before upgrading.
Old style rules are no longer supported and need to be upgraded to the new syntax if you have not already done so.(I will not discuss questions relating to security on the forum for obvious reasons, but hey, its open source so…)
Enjoy,
Dan
"Screw the captain. It's the engineer running the ship!"
pimatic-telegram, pimatic-tts, pimatic-woox, pimatic-lg-smart-tv, pimatic-spotify, pimatic-wakeuplight and some not-announced plugins -
Please hold off on upgrading, seems something went wrong with the NPM upload !
"Screw the captain. It's the engineer running the ship!"
pimatic-telegram, pimatic-tts, pimatic-woox, pimatic-lg-smart-tv, pimatic-spotify, pimatic-wakeuplight and some not-announced plugins -
Too late and now there is a error with “token (”
Did you change something within plugin settings also?
-
@developer Murphy just paid me a visit, and my dev box is trashed.
The issue is as follows:19:02:14.837 [pimatic] Starting pimatic version 0.9.37
19:02:17.492 [pimatic, ppm] 2.15.11
19:02:17.565 [pimatic] Loading plugin: “pimatic-telegram” (1.1.0)
19:02:17.601 [pimatic] Unexpected token {
19:02:17.645 [pimatic] Loading plugin: “pimatic-phone” (0.4.6)This seems to occur during compilation of telegram.coffee. If anyone can take a peek to find the issue, it would be appreciated to not lose too much time.
I could reproduce on my prod (raspi), but the error was absent on my dev box. When copying the files from dev to prod (without NPM) the issue could be reproduced as well…
Thanks,
Dan
"Screw the captain. It's the engineer running the ship!"
pimatic-telegram, pimatic-tts, pimatic-woox, pimatic-lg-smart-tv, pimatic-spotify, pimatic-wakeuplight and some not-announced plugins -
@Dan I think it is due to the
telebot
package which requires node v6. In version 1.08 you hadtelegram-bot-client
instead."It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
@mwittig you are corrrect. I have found the issue, javascript in two .js files is incompatible. I have created a workaround, but will do additional testing on my production box first before releasing a fix.
Meanwhile a manual removal of the package can be done as follows:
Reverting to the previous version for those who already upgraded:-remove the TelegramReceiverDevice from config.json
-remove the admin attribute from any defined recipients in config.json
-rm -rf pimatic-telegram in your node_modules folder (<pimatic-app>/node_modules)
-npm install pimatic-telegram@1.0.8 in node_modules folder"Screw the captain. It's the engineer running the ship!"
pimatic-telegram, pimatic-tts, pimatic-woox, pimatic-lg-smart-tv, pimatic-spotify, pimatic-wakeuplight and some not-announced plugins -
`/pimatic-app/node_modules $ npm install pimatic-telegram@1.0.8
npm ERR! Linux 4.4.38-v7+
npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” “install” "pimatic-telegram@1.0.8"
npm ERR! node v4.4.5
npm ERR! npm v2.15.5
npm ERR! code EPEERINVALIDnpm ERR! peerinvalid The package pimatic@0.9.37 does not satisfy its siblings’ peerDependencies requirements!
npm ERR! peerinvalid Peer pimatic-amazing-dash-button@0.9.11 wants pimatic@>=0.8.0 <1.0.0
npm ERR! peerinvalid Peer pimatic-cron@0.8.8 wants pimatic@>=0.8.0 <1.0.0
npm ERR! peerinvalid Peer pimatic-denon-avr@0.9.3 wants pimatic@>=0.8.0 <1.0.0
npm ERR! peerinvalid Peer pimatic-fritz@0.5.3 wants pimatic@>0.8.91 <1.0.0
npm ERR! peerinvalid Peer pimatic-iframe@0.2.0 wants pimatic@>=0.8.0 <1.0.0
npm ERR! peerinvalid Peer pimatic-ifttt@0.1.1 wants pimatic@0.8.*
npm ERR! peerinvalid Peer pimatic-mail@0.8.6 wants pimatic@>=0.8.0 <1.0.0
npm ERR! peerinvalid Peer pimatic-metar-weather@0.9.1 wants pimatic@>=0.9.0 <1.0.0
npm ERR! peerinvalid Peer pimatic-mobile-frontend@0.9.11 wants pimatic@0.9.*
npm ERR! peerinvalid Peer pimatic-netatmo@0.0.8 wants pimatic@>=0.8.0 <1.0.0
npm ERR! peerinvalid Peer pimatic-openweather@0.9.3 wants pimatic@>=0.8.0 <1.0.0
npm ERR! peerinvalid Peer pimatic-ping@0.9.5 wants pimatic@>=0.8.0 <1.0.0
npm ERR! peerinvalid Peer pimatic-shell-execute@0.9.8 wants pimatic@0.9.*
npm ERR! peerinvalid Peer pimatic-sunrise@0.8.7 wants pimatic@>=0.8.0 <1.0.0
npm ERR! peerinvalid Peer pimatic-sysinfo@0.9.4 wants pimatic@0.9.*
npm ERR! peerinvalid Peer pimatic-telegram@1.0.8 wants pimatic@>=0.9.*
npm ERR! peerinvalid Peer pimatic-z-way@1.4.2 wants pimatic@>=0.8.0 <1.0.0npm ERR! Please include the following file with any support request:
npm ERR! /home/pi/pimatic-app/node_modules/npm-debug.log
`And now???
-
@Swen said in Receives messages (Telegram):
npm ERR! peerinvalid Peer pimatic-ifttt@0.1.1 wants pimatic@0.8.*
It should work though. The error messages are caused by pimatic-ifttt which is not officially support with pimatic 0.9
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
@Dan said in Receives messages (Telegram):
you are corrrect. I have found the issue, javascript in two .js files is incompatible. I have created a workaround, but will do additional testing on my production box first before releasing a fix.
Perhaps you can run your own for of telebot for now until pimatic support node v6. You can use the fork for without publishing your own release of it as follows:
"telebot": "git+htts://github.com/SenTzu01/telebot.git"
You can also refer to a specific commit or branch of your fork. See https://docs.npmjs.com/files/package.json#git-urls-as-dependencies
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
@Dan Rather than modifying the telebot source code another approach is to transform the code using babel. This way, your fork will be easier to maintain.
- add a build procedure (using gulp / grunt) to cross-complile the stuff using babel to plain old javascript
- place the resulting files in a build directory
- set “main” entry to the build directory
https://github.com/babel/babel
For gulp there is a plugin which make it very easy to do this: https://www.npmjs.com/package/gulp-babel
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
@mwittig As always, thanks for your wisdom I’ll have a look tomorrow, this seems to be a better solution indeed. I may need a few extra pointers, but will contact you in chat for that.
Bit stupid I failed to load node v4 on my dev box, else I would have found the issue in testing…Thanks,
Dan
"Screw the captain. It's the engineer running the ship!"
pimatic-telegram, pimatic-tts, pimatic-woox, pimatic-lg-smart-tv, pimatic-spotify, pimatic-wakeuplight and some not-announced plugins