hass-variables icon indicating copy to clipboard operation
hass-variables copied to clipboard

Hass-variables and node red

Open Denrozh opened this issue 5 years ago • 3 comments

Hello. I've tried to update/change a variables value and/or its attributes in node red with call service nod, but it doesn't work. Node configuration: Server: Home Assistant Domain: variable Service: set_variable Entity Id: variable.example_123 Data: { "value" : "{{Buterbrod}}"} And... Debug: "Call-service API error. Error Message: extra keys not allowed @ data['entity_id']" What should I do to make it work?

Denrozh avatar Apr 30 '20 08:04 Denrozh

You should leave the entity_id field empty. I had the same issue.

mvereecken avatar Jun 12 '20 17:06 mvereecken

You should leave the entity_id field empty. I had the same issue.

(Hoping that you might still get a notification for this!)

So where is the variable actually specified then if you remove it from entity_id ? Can you give an actual example please?

Thanks!

ianfretwell avatar Dec 05 '21 23:12 ianfretwell

In my opinion this is a breaking bug!

It works if you call the service with the following data payload and an empty entity_id:

{    "variable" : <entity_id>
      "value": <value to set>
}

If you are able to set this yourself in your call (for example in a node-red flow), there is not much of a problem.

In my case I'm using the lovelace "custom:banner-card". This extension of lovelance allows you to define a tap action like follows:

- entity: variable.night_mode_active
    name: Night Mode
    value: mdi:weather-night
    color: black
    map_state:
      '0':
        action:
          service: variable.set_variable
          value: 1
        color: black
      '1':
        action:
          service: variable.set_variable
          value: 0
        color: yellow

In this case, the call is made with entity_id, with no way I could change that. Maybe that will also be a problem in other extension that use the action call with the entity_id supplied.

Ex0danify avatar Jan 14 '22 12:01 Ex0danify