Set input_boolean by trigger.json in automation

Hey all!
I am trying to integrate my wifi rain sensor to my home assistant installation.
My rain sensor is sending the state by json as boolean:

{
"rainState":true
}

or

{
"rainState":false
}

To archive my task i made an input_boolean helper called

input_boolean.weatherstation_rain_state_from_webhook

Now i want so set the state in an automation. I am doing this by UI.
So i added a Trigger “When a Webhook payload has been received” (the webhook is setup in my weather station and is triggered)

As Action i set up "Call a service ‘Input boolean: Toggel’ on
and use the following yaml code:

service: input_boolean.toggle
data_template:
  entity_id: input_boolean.weatherstation_rain_state_from_webhook
  value: "{{trigger.json.rainState | bool}}"

But my input_boolean is not set. Am i doing something wrong here? Maybe i am using the wrong service?

The service input_boolean.toggle toggles the entity’s state, it does not set a specific state.

service: input_boolean.turn_{{ 'on' if trigger.json.rainState | bool else 'off' }}
target:
  entity_id: input_boolean.weatherstation_rain_state_from_webhook
1 Like

Great, works like a charm! Thank you for very much for your help.