Home Assistant: "light kitchen on" Telegram command

Telegram command that will match "light room on" to do actions on light in Home Assistant.

More info here : https://community.home-assistant.io/t/how-to-improve-telegram-bot-commands-by-using-args/66786/3?u=a1ex4

[{"id":"c2953ddd.4f9ec8","type":"telegrambot-command","z":"6a96be4f.47abc","bot":"1b263db3.6cb4d2","command":"light (.*)","commandType":"re","commandCase":false,"x":150,"y":420,"wires":[["697b96ca.bfd318"]]},{"id":"697b96ca.bfd318","type":"function","z":"6a96be4f.47abc","name":"build service","func":"var text = msg.payload.text;\nvar splitted = text.split(' ')\nvar payload = {\n    'domain': 'light',\n    'service': 'turn_' + splitted[2],\n    'data': {\n        'entity_id': 'light.' + splitted[1]\n    }\n}\nreturn {'payload': payload};","outputs":1,"noerr":0,"x":330,"y":420,"wires":[["d05793a9.d4f538"]]},{"id":"d05793a9.d4f538","type":"api-call-service","z":"6a96be4f.47abc","name":"send service","server":"c1fe2bfb.85caa8","service_domain":"","service":"","data":"","mergecontext":"","x":495.00001525878906,"y":421.199951171875,"wires":[["7d015a76.8495ac"]]},{"id":"7d015a76.8495ac","type":"function","z":"6a96be4f.47abc","name":"Build msg","func":"var state = msg.payload.service.split('_')[1]\nvar light = msg.payload.data.entity_id.split('.')[1]\nvar text = 'Got it, turned '+ state + ' the '+ light + ' light.';\n\nreturn {'payload': {'text':text}};","outputs":1,"noerr":0,"x":656.25,"y":422.4499206542969,"wires":[["a25fc85a.358f58"]]},{"id":"a25fc85a.358f58","type":"telegrambot-payload","z":"6a96be4f.47abc","name":"Send msg","bot":"1b263db3.6cb4d2","chatId":"691388830","sendMethod":"sendMessage","payload":"","x":803.4999389648438,"y":423.24993896484375,"wires":[[]]},{"id":"1b263db3.6cb4d2","type":"telegrambot-config","z":"","botname":"TelegramBot","usernames":"","chatIds":"","pollInterval":"300"},{"id":"c1fe2bfb.85caa8","type":"server","z":"","name":"Home Assistant","url":"","pass":""}]

Flow Info

Created 7 years, 2 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • function (x2)
Other
  • api-call-service (x1)
  • server (x1)
  • telegrambot-command (x1)
  • telegrambot-config (x1)
  • telegrambot-payload (x1)

Tags

  • home
  • assistant
  • homeassistant
  • telegram
  • bot
  • command
  • light
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option