Command line as an action but sending the output as a notify message

Hi,
I want to do something like this:
When I send a Telegram Command (like /runCmd), I want that HomeAssistant run a predefined shell command (like ‘ls -l’) and return the output as a Telegram message.
How can I do that?
Sorry about my english, I hope you can understand my question.

Thanks in advance.
Andrés.

Use AppDaemon so you can enjoy the full power of Python :wink:

See an example at the end of https://www.home-assistant.io/components/telegram_bot/
(though you should note that the example is a bit outdated - the import statement for AppDaemon 3.x differs, see http://appdaemon.readthedocs.io/en/latest/ )

Alternatively, take the unix approach and break this down into it’s parts.

  1. Create a command line sensor that outputs ls -l

  2. Create a telegram command that takes the content of the command line sensor.

EDIT: corrected wine induced typos.

Yeah, this was my first idea,
but how can i create a command line sensor that not refresh automatically, only when I call them?

Thanks!
I don’t know AppDaemon, I’ll see it later!