# Executar serviço através de linhas de comando function

**URL:** <https://discourse.nodered.org/t/executar-servico-atraves-de-linhas-de-comando-function/73124>\
**Category:** General\
**Tags:** function-node, home-assistant\
**Created:** [3 January 2023 19:42 UTC](https://discourse.nodered.org/t/executar-servico-atraves-de-linhas-de-comando-function/73124 "2023-01-03T19:42:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![EduardoRCB](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@EduardoRCB](https://discourse.nodered.org/u/EduardoRCB)\
**Post date:** [3 January 2023 19:42 UTC](https://discourse.nodered.org/t/executar-servico-atraves-de-linhas-de-comando-function/73124/1 "2023-01-03T19:42:49Z")

</div>

Boa tarde !  
Alguém saberia como executar um serviço através de linhas de comando dentro de um nó function?  
Encontrei o códigoe exemplo abaixo, mas não funciona:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/b/bbd318a4180985459e9c61fcab4f88bfbc3646ce.png)

---

<div class="post-metadata">

**Author:** ![EduardoRCB](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@EduardoRCB](https://discourse.nodered.org/u/EduardoRCB)\
**Post date:** [5 January 2023 12:28 UTC](https://discourse.nodered.org/t/executar-servico-atraves-de-linhas-de-comando-function/73124/2 "2023-01-05T12:28:35Z")

</div>

Continuo no aguardo desse item, sem solução.

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [5 January 2023 12:42 UTC](https://discourse.nodered.org/t/executar-servico-atraves-de-linhas-de-comando-function/73124/3 "2023-01-05T12:42:28Z")

</div>

Hi @EduardoRCB  
Welcome to this forum.

Despite my language knowledge regarding Spanish (?) is ~~near to~~ zero: There're some contributed nodes available that support HomeAssistant - thus there should be no need to use a function node for a standard task.  
If you open the Node-RED menu (top right corner), select "Manage palette", select the "Install" tab & then enter `assistant` as search text, you'll get a number (34 - when I did this) of options:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/1/f1c3b6959ee31742f8c65679ddb3998f29ea969c.png)

Be sure to extensively wire `Debug` nodes initially - to understand the message format as it is processed...

---

<div class="post-metadata">

**Author:** ![EduardoRCB](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@EduardoRCB](https://discourse.nodered.org/u/EduardoRCB)\
**Post date:** [1 March 2023 19:33 UTC](https://discourse.nodered.org/t/executar-servico-atraves-de-linhas-de-comando-function/73124/4 "2023-03-01T19:33:00Z")

</div>

Thanks for the tip, but this node I already know. To make it clearer why I want to execute a service through "Function" command, is that I have a Skill of interaction with Alexa and during this interaction any service can be executed through received commands or words. Within the same "function" node, I would be able to insert thousands of words and phrases linked to the execution of services. If I use service nodes for each command, I would go insane!

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [1 March 2023 20:12 UTC](https://discourse.nodered.org/t/executar-servico-atraves-de-linhas-de-comando-function/73124/5 "2023-03-01T20:12:02Z")

</div>

OK then...  
It looks like you need to load the `homeassistant` module first.

Make sure, you installed it via `npm install homeassistant`, then make it available in Node-RED.  
The [documentation](https://nodered.org/docs/user-guide/writing-functions#loading-additional-modules) can show you how to achieve this.

Additionally, make sure to use javascript code as reference. `call_service` looks like coming from the Python HASS module.

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [1 March 2023 20:15 UTC](https://discourse.nodered.org/t/executar-servico-atraves-de-linhas-de-comando-function/73124/6 "2023-03-01T20:15:08Z")

</div>

> [@EduardoRCB](#):
>
> Continuo no aguardo desse item, sem solução.

By the way: Você obteria muito mais feedback ao fazer suas perguntas usando o idioma inglês!

---

<div class="post-metadata">

**Author:** ![EduardoRCB](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@EduardoRCB](https://discourse.nodered.org/u/EduardoRCB)\
**Post date:** [1 March 2023 20:28 UTC](https://discourse.nodered.org/t/executar-servico-atraves-de-linhas-de-comando-function/73124/7 "2023-03-01T20:28:55Z")

</div>

Thank you for the tips. In my case, I use nodered within HomeAssistant. I'll do a code review for "java". tks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [30 April 2023 20:29 UTC](https://discourse.nodered.org/t/executar-servico-atraves-de-linhas-de-comando-function/73124/8 "2023-04-30T20:29:45Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
