Picture Element Tap Action Not Working

I’m trying to use a tap_action to set an input number to a specific value… it’s working for increment/decrement but not for the specific value. Code is:

    tap_action:
      action: call-service
      service: input_number.set_value
      target:
        entity_id: input_number.lounge_set_temp
      data:
        value: '18'

Error is:

Failed to call service input_number/set_value. required key not provided @ data['value']

I’ve tried without quote and with all styles of quotes on the value. What am I missing?

I think but I cannot be 100% on this, that it’s service_data and not data, from lovelace, for reasons unknown.

    tap_action:
      action: call-service
      service: input_number.set_value
      service_data:
        value: '18'
        entity_id: input_number.lounge_set_temp

Untested, but I think that’s correct.

Thanks for the idea, sadly no luck. Same error:

Failed to call service input_number/set_value. required key not provided @ data['value']

From browser dev mode console:

Uncaught (in promise) 
Object { code: "invalid_format", message: "required key not provided @ data['value']" }
​
code: "invalid_format"
​
message: "required key not provided @ data['value']"

Hmmm creating a test button in my Lovelace and using the GUI to fill in the required details spits out this:

tap_action:
  action: call-service
  service: input_number.set_value
  service_data:
    value: 18
  target:
    entity_id: input_number.bedroom_brightness

So that is definitely the required format, though I don’t know if it matters, but note the numerical value does not have quotes around it.

1 Like

Ok… I don’t know what happened there… maybe there was a hidden character/tab/space or something weird in my code, but I tried editing it to match yours, didn’t work. Then copied and pasted your code in and changed the entity names… now it works.

Either way, you got me to the successful conslusion! Thank you!

1 Like

No I’m really suspecting that it was because you had 18 (a number) as ‘18’ (a string). If I try in the editor to make it ‘18’ it automatically removes the quotes even before I can save it.

My editor allows me to keep the quotes in - and it also works with the quotes! Mysterious.

Very weird. I have just tested whether it matters if entity_id is inside service_data, or if it has to have target. And both ways work, so it’s not anything to do with that either.