Commande curl dans automation

Bonjour,

Je souhaite savoir comment intégrer une commande curl dans une automation.
J’ai bien trouvé une information qu’il faut utiliser une command-shell mais lors de la création de mon automation je ne trouve pas de command-shell dans les appel de service.

Voici la commande que je souhaite intégrer :

curl -H « Content-Type: application/json » --data ‹ { « ThPercentage »: 35.0,
« Out1_mode »: 3 } › -X POST http://192.168.1.111/rest/api

Pouvez vous m"orienter svp
merci
Sébastien

Bonjour,
il faut que que cré ton entité qui est le résultat de ta commande voir documentation
ensuite tu utilise cet entité dans ton automatisme.

bon courage avec ça et je suis curieux de savoir si tu arrives à quelque chose de probant car par le passé tous mes essais d’utilisation ont été infructueux (cela ressemble beaucoup à la commande Telnet intégré dans HA d’une telle façon que c’est à peu près inutilisable :frowning:

Salut @Zibasedom_Seblang ,

Dans configuration.yaml tu définies ta « shell_command » comme ça :

shell_command:
  my_curl: curl -H « Content-Type: application/json » --data ‹ { « ThPercentage »: 35.0,« Out1_mode »: 3 } › -X POST http://192.168.1.111/rest/api

Et dans ton automation dans la partie « action » tu l’appelles comme ça :

action:
  - service: shell_command.my_curl

Vu la syntax du curl lui même faudra peut-être l’entourer de " , en tout cas dans le principe j’utilise un truc dans ce genre dans une de mes automations et ça fonctionne correctement :wink:

Chez moi ça donne ça :

shell_command:
  notifoff: python3 /config/custom_things/surv-api-cmd.py OFF
  notifon: python3 /config/custom_things/surv-api-cmd.py ON

Et pour l’automation :

- id: '9682690821083'
  alias: 'Surveillance Station'
  description: 'Gestion notif surveillance station'
  trigger:
  - entity_id: group.people
    platform: state
    to: 'home'
  - entity_id: group.people
    platform: state
    to: 'not_home'
  action:
    - service: shell_command.notif{{ 'on' if is_state('group.people', 'not_home') else 'off' }}
1 « J'aime »

@Herbs

cool merci de ton retour, nicket ça marche
merci et bonne soirée
sebastien

1 « J'aime »