Not to derail the conversation, but as a quick update I am able to control turning on a light above my kitchen sink (as an added bonus my wife in the same group chat can use the same keyword and it also runs the script).
So with telegram-cli you run the following command on a system (still trying to figure out how to run it as a service)
~/tg$ ./bin/telegram-cli -s ./action.lua
Within in the action.lua I have the following:
function on_msg_receive (msg)
if msg.out then
return
end
if (msg.text == ‘sink’) then
os.execute(‘/opt/OSscripts/kitchen_sink.sh’)
end
end
function on_binlog_replay_end ()
started = 1
postpone (cron, false, 1.0)
end
And for the kitchen_sink.sh it has the following:
curl --header “Content-Type: text/plain” --request POST --data “ON” http://xxx.xxx.xxx.xxx:8080/rest/items/kitchen_sink_light
What I also had the most trouble with is that this does not appear to work on a Channel in telegram vs a chat with yourself or a group chat.
I also believe that with the action.lua file you can also limit who can issue what commands by only allowing them to come from you or some other ID; I’m thinking of things like smart locks you don’t want to let kids have the ability to unlock the house for their friends, so limit it to your own ID.
I’m going to be adding some more if conditions into my action file and see how well it works for me.