Use input_select in Automation

Hi all, after some help. I’m sure this really simple but I can’t work it out (although I think I have been close on a few occasions).

On my Victron inverter (already integrated into HA), I can set the grid setpoint to control how much energy I want to export (i.e. 0, -1000, -2000 watts etc). On my dashboard I have some ‘hard coded’ button values which calls an automation which sets the value, this works fine but I will have loads of buttons for each negative setpoint, and want I really want is a drop-down box (input_select) to choose a value and then click a‘Set’ button. I’ve created a selection helper (NegSetpoint) with my values but I can can’t figure out how to use the selected value in my automation?

This is my yaml, essentially I’m trying to get the value in my iPhone notification message “{{ states(‘input_select.negsetpoint’) }}” into the value of the action?

alias: Victron_Grid_Setpoint_0
description: ""
triggers: []
conditions: []
actions:
  - device_id: 3c585aac0331c3386bc22f0abeb16cce
    domain: number
    entity_id: 8c8cbe44291627021e759b4f475697e7
    type: set_value
    value: 0
    enabled: true
  - action: notify.mobile_app_chriss_iphone
    metadata: {}
    data:
      message: Victron grid setpoint set to 0 {{ states('input_select.negsetpoint') }}
mode: single

Any help would be appreciated.
Chris

Then you will have loads of values in the input select. How is that better?

Anyway here’s one way:

configuration.yaml (or UI helper)

input_select:
  export_setting:
    name: Export Setting
    icon: mdi:gauge
    options:
      - '1000'
      - '2000'
      - '3000'
      - '4000'

automation:

triggers:
  - trigger: state
    entity_id: input_select.export_setting
    not_to:
      - unknown
      - unavailable
actions:
  - action: notify.mobile_app_chriss_iphone
    metadata: {}
    data:
      message: "Victron grid setpoint set to {{ states('input_select.export_setting') }}"

If you need to use the value as a number you must use either the |int or |float fliters to convert it from a string to a number.

Hi tom, thanks for you reply. My thinking is rather than having a separate button for each individual setpoint, I instead choose from the drop-down help and then hit ‘Set’ button. This way I only have 2 controls on my dashboard to set the setpoint.

Looking at your yaml above, I can’t see how that runs the action to set the negative setpoint on the inverter. The iPhone notification is just in my yaml as a test to see if I could get the value my input_select help.

You have not told us which service does that. Which service are you using with your buttons?

Is it this?

actions:
  - device_id: 3c585aac0331c3386bc22f0abeb16cce
    domain: number
    entity_id: 8c8cbe44291627021e759b4f475697e7
    type: set_value
    value: 0
    enabled: true

Tell me what the number entity id is. You cant use device automations for this.

Basically it would be:

triggers:
  - trigger: state
    entity_id: input_select.export_setting
    not_to:
      - unknown
      - unavailable
actions:
  - action: number.set_value
    target:
      entity_id: number.foobar # change this
    data:
      value: "{{ states('input_select.export_setting') }}"
  - action: notify.mobile_app_chriss_iphone
    metadata: {}
    data:
      message: "Victron grid setpoint set to {{ states('input_select.export_setting') }}"

You don’t need a button to set the value. As soon as you change the input select the automation triggers and set’s the value.

1 Like

Thanks Tom, sorted :+1: