Toon app: ToonBot

Forum about forum-provided applications on Toon

Moderators: marcelr, TheHogNL, Toonz

glsf91
Member
Member
Posts: 184
Joined: Fri Sep 15, 2017 9:25 pm

Toon app: ToonBot

Post by glsf91 »

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 9570 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

So again, DON'T forget to add the security !

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 Tue Oct 24, 2023 6:50 pm, edited 11 times in total.
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Toon app: ToonBot

Post by Toonz »

App has been added to the ToonStore. Thanks glsf91 :-)
member of the Toon Software Collective
glsf91
Member
Member
Posts: 184
Joined: Fri Sep 15, 2017 9:25 pm

Re: Toon app: ToonBot

Post by glsf91 »

That is quick. Thank you.
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Toon app: ToonBot

Post by Toonz »

hee, it's not Quby here :-)
member of the Toon Software Collective
michel30
Member
Member
Posts: 286
Joined: Fri Aug 25, 2017 4:42 pm

Re: Toon app: ToonBot

Post by michel30 »

Nice app good job.
glsf91
Member
Member
Posts: 184
Joined: Fri Sep 15, 2017 9:25 pm

Re: Toon app: ToonBot

Post by glsf91 »

Added a new version 1.0.1.
- fixed last update time sometimes wrong
- fixed refresh after Telegram request failure
TheHogNL
Forum Moderator
Forum Moderator
Posts: 2125
Joined: Sun Aug 20, 2017 8:53 pm

Re: Toon app: ToonBot

Post by TheHogNL »

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
TerrorSource
Administrator
Administrator
Posts: 494
Joined: Thu May 04, 2017 9:28 pm

Re: Toon app: ToonBot

Post by TerrorSource »

@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 :)
RNdX
Starting Member
Starting Member
Posts: 7
Joined: Wed Dec 04, 2019 8:42 pm

Re: Toon app: ToonBot

Post by RNdX »

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.
glsf91
Member
Member
Posts: 184
Joined: Fri Sep 15, 2017 9:25 pm

Re: Toon app: ToonBot

Post by glsf91 »

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: 184
Joined: Fri Sep 15, 2017 9:25 pm

Re: Toon app: ToonBot

Post by glsf91 »

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.
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Toon app: ToonBot

Post by Toonz »

Version 1.1.0 is available in ToonStore now.
member of the Toon Software Collective
RNdX
Starting Member
Starting Member
Posts: 7
Joined: Wed Dec 04, 2019 8:42 pm

Re: Toon app: ToonBot

Post by RNdX »

This is just fantastic!
You rock!

Thank you glsf91!
sjolmers
Starting Member
Starting Member
Posts: 1
Joined: Mon May 04, 2020 9:05 pm
Location: Friesland
Contact:

Re: Toon app: ToonBot

Post by sjolmers »

Vandaag mijn geroote Toon2 ontvangen en nu eea aan het instellen. Ik heb zojuist ToonBot geinstalleerd, dit werkt top!
ronsmith
Starting Member
Starting Member
Posts: 1
Joined: Thu Aug 27, 2020 10:43 am

Re: Toon app: ToonBot

Post by ronsmith »

EDIT admin: No need to quote the startpost.

Looks promising. I will check this app right now!
Post Reply

Return to “Toon Apps”