Toon app: ToonBot

Forum about forum-provided applications on Toon

Moderators: marcelr, TerrorSource, Toonz, TheHogNL

Toon app: ToonBot

Postby glsf91 » Sat Mar 21, 2020 5:17 pm

I have made an app to remote control the Toon with Telegram. It has the following functionality:

This app is a Telegram Bot. With this app you are able to get the following information from the Toon on Telegram:
- current measured temperature
- current thermostat temperature
- current active program
- program state (on/off/temporary)
- next program
- energy usage

With some commands you can also change the following:
- thermostat temperature
- program
- program state (on/off)

If you have a smokedetector you can enable an alarm which will be send to a specified Telegram ChatId. This can also be a Telegram group.
You can get the ChatId by sending a unknown command (example /blabla) to your Bot from the Telegram chat or group.

When a random character is sent from Telegram, it returns a message with the possible commands. The app will poll Telegram with a configurable interval. So a respons from Toon will arrive after this interval.
On the Tile it shows:
- name and username of the bot
- last received command
- status

When clicking on the Tile you get a screen with the last received commands. But when a token is not defined you get a popup about this token.
There is also a refresh button to trigger a manual update from Telegram. Use this also when the status is showing an error on the Tile. It will trigger getting the updates again.

You can change the following settings:
- token of Telgram bot (it won't work without; instructions are on the page)
- refresh interval (interval in seconds to get new message from Telegram)
- alarm ChatId (ChatId where the smokedetector alarm will be send)
- refresh of messages on/off (switch off receiving messages from Telegram)
- icon in systray
- enable or disable security
- enable or disable smokedetector alarm


(if you don't like adding the token by the keyboard you can save the configuration one time and add the token by login on the Toon and add the token in /mnt/data/tsc/toonbot.userSettings.json)

Before you can use this app, you have to create a Telegram Bot first. It is very easy to create a bot. See instructions on the configuration screen (or here https://core.telegram.org/bots#6-botfather ).
You can also control the Toon with more people from a Telegram group. Just add the Bot to a group.

If you change the display name of your bot (with BotFarther) it will be visible after restart of Toon GUI (TSC menu).
If you choose a long username and display name when creating a bot, it will probably not fit on the Tile. Is is also visible on the screen after clicking in the Tile (or use the systray icon).
You can not change the username after creating the Bot (just create a new bot). You can only change the display name.

It is also possible to define the commands in your bot. Go to BotFather and give the command /setcommands.
Paste the following (and change it if needed) and Enter:
Code: Select all
info - Vraag Toon gegevens op
energie - Vraag energie verbruik op
prog_c - Activeer programma Comfort
prog_t - Activeer programma Thuis
prog_w - Activeer programma Weg
prog_s - Activeer programma Slapen
auto_a - Zet auto programma aan
auto_u - Zet auto programma uit
therm_20 - Thermostaat op 20 graden


By type a "/" in Telegram you see the above commands and you can just click on them.

Example of Telegram messages:
telegram.PNG
telegram.PNG (195.57 KiB) Viewed 2339 times


Normaly everybody who can find your Bot can communicate with it. This means they can control your Toon.
With V1.2.0 security is added. This means you can choose that only messages from configured users or groups are processed. Messages from other users are displayed but ignored.
You can add at most 24 users or groups. This can be done on the messages screen. Users which are not in the list will show a +-sign. Click on this to add the user. If the user is not on the screen you can ask the user to sent a message (which is denied) to the ToonBot first. On the Instellingen screen (Beheer toegang) you can remove users or groups.
Even if you see the name of the user or group, access is based on chat id. So if a user or group change name makes no differences.

You or others can also use groups (for the family for example) and see the commands other group members are using. But you can also deny (I recommend) your bot to join groups.
First make your own group(s) if needed and add your bot to the group. Then:
- Open a session with BotFather.
- Enter /setjoingroups.
- Enter the name of the bot. @example_bot.
- Enter Disable

V1.0.0
Initial release

V1.0.1
- fixed last update time sometimes wrong
- fixed refresh after Telegram request failure

V1.0.2
- debug logging switched off by default

V1.1.0
- changed bot commands to make it possible to use the commands in /setcommands in BotFather

V1.2.0
- improved security so processing of messages can be restricted

V1.3.0
- added command for energy usage

V1.4.0
- added smokedetector alarm

Known issues
Empty thumbnail icon when adding to Tile. Has no influence on app functionality. Is fixed when using firmware 5.25.8 or later.
Last edited by glsf91 on Sun Jan 31, 2021 9:33 pm, edited 10 times in total.
glsf91
Member
Member
 
Posts: 168
Joined: September 2017

Re: Toon app: ToonBot

Postby Toonz » Sat Mar 21, 2020 8:03 pm

App has been added to the ToonStore. Thanks glsf91 :-)
member of the Toon Software Collective
User avatar
Toonz
Forum Moderator
Forum Moderator
 
Posts: 1634
Joined: December 2016

Re: Toon app: ToonBot

Postby glsf91 » Sat Mar 21, 2020 8:13 pm

That is quick. Thank you.
glsf91
Member
Member
 
Posts: 168
Joined: September 2017

Re: Toon app: ToonBot

Postby Toonz » Sat Mar 21, 2020 10:30 pm

hee, it's not Quby here :-)
member of the Toon Software Collective
User avatar
Toonz
Forum Moderator
Forum Moderator
 
Posts: 1634
Joined: December 2016

Re: Toon app: ToonBot

Postby michel30 » Sat Mar 21, 2020 11:26 pm

Nice app good job.
michel30
Member
Member
 
Posts: 257
Joined: August 2017

Re: Toon app: ToonBot

Postby glsf91 » Sun Mar 22, 2020 2:30 pm

Added a new version 1.0.1.
- fixed last update time sometimes wrong
- fixed refresh after Telegram request failure
glsf91
Member
Member
 
Posts: 168
Joined: September 2017

Re: Toon app: ToonBot

Postby TheHogNL » Mon Mar 23, 2020 9:42 am

glsf91 wrote:Added a new version 1.0.1.
- fixed last update time sometimes wrong
- fixed refresh after Telegram request failure


Updated toonstore to have 1.0.1 in the repo. And published a new resource file (only) for the latest firmware so the toonbot icon is in the resource file
Member of the Toon Software Collective
User avatar
TheHogNL
Forum Moderator
Forum Moderator
 
Posts: 1867
Joined: August 2017

Re: Toon app: ToonBot

Postby TerrorSource » Thu Mar 26, 2020 11:42 pm

@glsf91, could you comment out the console.log lines in the next release?
found 82x in App.qml and 4x in Screen.qml, all active. So when someone (like me) had edited the inittab to collect logs a lot of logs are writen and the Toon doesn't like these amount of lines writen :)
TerrorSource
Administrator
Administrator
 
Posts: 494
Joined: May 2017

Re: Toon app: ToonBot

Postby RNdX » Fri Mar 27, 2020 11:05 am

Is it possible to create your own commands?
I try to edit my bot, for example:

/command1 - programma:thuis
/command2 - programma:weg

the benefits of it ones you type '/' u can choose your command by one simple click instead of typing commands.
RNdX
Starting Member
Starting Member
 
Posts: 7
Joined: December 2019

Re: Toon app: ToonBot

Postby glsf91 » Fri Mar 27, 2020 11:40 am

TerrorSource wrote:@glsf91, could you comment out the console.log lines in the next release?
found 82x in App.qml and 4x in Screen.qml, all active. So when someone (like me) had edited the inittab to collect logs a lot of logs are writen and the Toon doesn't like these amount of lines writen :)


I made a new version V1.0.2 where logging is switched off by default.
Last edited by glsf91 on Fri Mar 27, 2020 10:54 pm, edited 3 times in total.
glsf91
Member
Member
 
Posts: 168
Joined: September 2017

Re: Toon app: ToonBot

Postby glsf91 » Fri Mar 27, 2020 1:41 pm

RNdX wrote:Is it possible to create your own commands?
I try to edit my bot, for example:

/command1 - programma:thuis
/command2 - programma:weg

the benefits of it ones you type '/' u can choose your command by one simple click instead of typing commands.


It is not possible to use your own commands. In your example, "programma:thuis" is just a description. The bot does not receive the description. Only "/command1".

What I can do is make shorter commands and use '_' as a separator and then you can create your this command with your own description.

Example: If I make a shortcut "/prog_t" for programma:thuis then you can define the command "/prog_t - Change to program Thuis" and you can click the command.

For /thermostat I could shorten this to /therm_18 and /therm_185. Not sure if this will be clear enough for everyone.

edit:
I have made a new release v1.1.0 where the bot commands are changed.
Now it is possible to use /setcommands in BotFather to add the following for example:
Code: Select all
info - Vraag Toon gegevens op
prog_c - Activeer programma Comfort
prog_t - Activeer programma Thuis
prog_w - Activeer programma Weg
prog_s - Activeer programma Slapen
auto_a - Zet auto programma aan
auto_u - Zet auto programma uit
therm_20 - Thermostaat op 20 graden


By type a "/" in Telegram you see the above commands and just click on them.
Thanks to RNdX for the idea.
glsf91
Member
Member
 
Posts: 168
Joined: September 2017

Re: Toon app: ToonBot

Postby Toonz » Sat Mar 28, 2020 3:18 pm

Version 1.1.0 is available in ToonStore now.
member of the Toon Software Collective
User avatar
Toonz
Forum Moderator
Forum Moderator
 
Posts: 1634
Joined: December 2016

Re: Toon app: ToonBot

Postby RNdX » Fri Apr 03, 2020 10:16 pm

This is just fantastic!
You rock!

Thank you glsf91!
RNdX
Starting Member
Starting Member
 
Posts: 7
Joined: December 2019

Re: Toon app: ToonBot

Postby sjolmers » Mon May 11, 2020 8:45 pm

Vandaag mijn geroote Toon2 ontvangen en nu eea aan het instellen. Ik heb zojuist ToonBot geinstalleerd, dit werkt top!
sjolmers
Starting Member
Starting Member
 
Posts: 1
Joined: May 2020
Location: Friesland

Re: Toon app: ToonBot

Postby ronsmith » Thu Aug 27, 2020 10:45 am

EDIT admin: No need to quote the startpost.

Looks promising. I will check this app right now!
ronsmith
Starting Member
Starting Member
 
Posts: 1
Joined: August 2020

Next

Return to Toon Apps

Who is online

Users browsing this forum: No registered users and 1 guest