How to send entity value via webhook

Hi all,
beside HA I run an other system (pimatic) to which I like send an entity value via webhook. Unfortunately I am not able to get it to work.

Following works. I put in just an simple number 19.

alias: Kia eSoul - Klima+ Temperatur
description: ''
trigger:
  - platform: state
    entity_id: input_number.kia_klima_plus_temperatur
condition: []
action:
  - service: shell_command.curl_expanded
    data:
      method: PATCH
      header: 'Content-Type:application/json'
      auth: 'abc:123'
      data: '{"type": "value", "valueOrExpression": "19"}'
      url: 'http://192.168.0.100/api/variables/kia-klima-plus-temp'
mode: single

I like to send the current state of input_number.kia_klima_plus_temperatur with every change of the slider to the RestAPI of pimatic.

alias: Kia eSoul - Klima+ Temperatur 
description: ''
trigger:
  - platform: state
    entity_id: input_number.kia_klima_plus_temperatur
condition: []
action:
  - service: shell_command.curl_expanded
    data:
      method: PATCH
      header: 'Content-Type:application/json'
      auth: 'abc:123'
      data: '{"type": "value", "valueOrExpression": "{{ states('input_number.kia_klima_plus_temperatur') | round(0) }}"}'
      url: 'http://192.168.0.100/api/variables/kia-klima-plus-temp'
mode: single

But it does not work. Any idea?

Your problem is quote nesting. It would be easier if you used multiline YAML for that parameter. Also you need to convert the state to a number before rounding. Try this:

alias: Kia eSoul - Klima+ Temperatur 
description: ''
trigger:
  - platform: state
    entity_id: input_number.kia_klima_plus_temperatur
condition: []
action:
  - service: shell_command.curl_expanded
    data:
      method: PATCH
      header: 'Content-Type:application/json'
      auth: 'abc:123'
      data: >
        {"type": "value", "valueOrExpression": "{{ states('input_number.kia_klima_plus_temperatur') | float | round(0) }}"}
      url: 'http://192.168.0.100/api/variables/kia-klima-plus-temp'
mode: single

EDIT: Also, FWIW, I think you could do this more simply using a RESTful Command.

1 Like

Oh man, thanks this does the trick, I hadn’t this in mind. Thanks for your help!

Will try out RESTful Command. Seems to be much easier. I am new in HA so I need to learn much :smile: