Automation Action to Set Value of Input Helper Based on Device Attribute

Long-time automation guy (but HA noob) stumped with the automation front-end for setting the value of an entity based on a device attribute. Is this even possible?Specifics:

I’m trying to set the value of either (preferably both, but I’ll take either):
(1) an input helper (number 0-100)
(2) a dimmer device

I’m using the automation front-end to define the action. But the trick is that I want to reference the value in a device attribute, not an entity. Is this possible? TIA…

What is the entity id and attribute name?

There are a few examples. But one of them is:

  • Entity ID for the dimmer device: [light.alice_tank_level] (that I want to assign the value to)
  • Device attribute: Tank Level (attribute I want to get the value from)
  • Device: Alice (it’s a Braava M6 mop)

Is there an ID for a device and/or device attribute? I realized I’ve given you the labels above.

Thanks for your reply.

Look in Developer Tools → States. Find the entity id of your mop.

OK I see the entity ID for the mop, but coming back to the original question, I still can’t figure out how to use an Action in the Automation front-end to set the value of an entity to the value of a device attribute. Assume I’m missing something.

EDIT: to be more clear, I can see how to set the value of a dimmer or a helper to a number (73, 42, 9, 57), but not to the value of a device attribute. Seems like such a basic action. Is it possible?

Yes - if you tell me the entity ids I can show you how.

The entityID for the mop is Vacuum.Alice. I don’t see an entity ID for the device attribute in question.

EDIT: But the attribute, as shown in States, is called tank_level

I doubt that. Entity ids do not contain capital letters.

Try this:

- service: light.turn_on
  target:
    entity_id: light.alice_tank_level
  data:
    brightness_pct: "{{ state_attr('vacuum.alice',tank_level')|int(0) }}"

This will not work correctly unless the tank level only has values from 0 to 100.

1 Like

I did something using Z-Wave Devices and an input helper. Anytime I change the value of the input helper it triggers the automation and uses that value as input for the Z-Wave Set Value Service.

alias: GE Dimmer
description: ""
trigger:
  - platform: state
    entity_id:
      - input_number.dimmer
condition: []
action:
  - service: zwave_js.set_value
    target:
      device_id: fe45284459b650c9aa876a28c27021b2
    data:
      property: targetValue
      value: "{{ states('input_number.dimmer') }}"
      command_class: "38"
mode: single

Think it was just autocorrect at work, combined with my sloppiness — yes it’s vacuum.alice

Thank you. Will try. And yes valid values are 0-100 so I think I’m safe.

Can I correctly infer, by its absence, that there is no way to assign a value to an entity based on another entity just using an action in the automation front end (not YAML)? I’m not averse to YAML, just seeking to understand.

@tom_l Im guessing there’s a simple typo with the single quotes since there’s an odd number of them in the snippet you shared, but whatever I do (e.g., one pair or two pairs of single quotes), I get an error message. “expected dictionary @ data [‘action’][0]”

Pretty sure I’m doing something noobish.

Yeah there should be quotes both sides of the attribute ‘tank_level’, sorry.

brightness_pct: "{{ state_attr('vacuum.alice','tank_level')|int(0) }}"

2 Likes

Ok got it thx. Works now TYVM!

Can I correctly infer, by its absence, that there is no way to assign a value to an entity based on another entity just using an action in the automation front end (not YAML)? I’m not averse to YAML, just seeking to understand.

@tom_l, I assume there’s an analogue to this syntax for text strings, rather than dimmers. Is there documentation somewhere I can consult, rather than asking for you each individual scenario?

2 Likes