I'm just starting with lua and need some (= a lot) assistance with this. So, please be patient to me!
Because the best way to learn is to have a goal. So, this is my first goal:
When a variable is changed, send a Telegram message with the content from that variable.
Variable name = HC2_Bewonersstatus (English: Residents status)
The contents will be updated by my Fibaro HC2 Gateway as has got 5 statuses:
Thuis (English: Home)
Slaap (English: Sleeping)
Bewaakt (English: Watched, intended to watch the house if it is uninhibited for some period of time, will be implemented later on)
Weg (English: Away)
Vakantie (English: On Vacation)
So, first I made a new event name:
Telegram (Send), Lua, UserVariable
Code: Select all
commandArray = {}
-- ------------------------------------------------------------------------------------------
-- ℹ Initialisation of user settings (change if necessary)
-- ------------------------------------------------------------------------------------------
local bot = 'xxxxxxxxx'; -- Telegram Bot ID
local token = 'yyyyyyyyyyyyyy'; -- Telegram Bot Token
local chatId = 'zzzzzzzzzz'; -- Telegram Chat ID
local message = 'This is a test!'; -- Test messages
-- ------------------------------------------------------------------------------------------
-- Code (do not change)
-- ------------------------------------------------------------------------------------------
print ('Telegram message will be send..');
os.execute('curl --data chat_id='..chatId..' --data-urlencode "text='..message..'" "https://api.telegram.org/bot'..bot..':'..token..'/sendMessage" ')
print ('Telegram message is send!)';
return commandArray
Please help, it will be highly appreciated!