Automation with input number

Hi!

I cannot get the below automation with input number to work out!
Comments are very welcome!

in configuration.yaml

input_number:
  lg_max_volume:
    name: LGmaxvolume
    initial: 0.1
    min: 0
    max: 1
    step: 0.01
    mode: box

in automations.yaml

- id: '1587888014390'
  alias: LG TV Max volume
  description: ''
  trigger:
  - entity_id: media_player.lg_tv
    platform: state
  condition: []
  action:
  - data_template:
      entity_id: media_player.lg_tv
      volume_level: '{{ states(input_number.lg_max_volume) | float}}'
    service: media_player.volume_set

Btw. below simpler automation (without input number) works just fine

in automations.yaml

- id: '1585669213638'
  alias: TV low volume
  description: ''
  trigger:
  - above: '0.1'
    entity_id: media_player.lg_tv
    platform: numeric_state
    value_template: '{{ state.attributes.volume_level }}'
  condition: []
  action:
  - data:
      volume_level: 0.1
    entity_id: media_player.lg_tv
    service: media_player.volume_set

What do you think?

It would be a lot easier to help you if you format your code properly.

You need three back ticks before and three after the code block.

eggman, thanks :slight_smile:

Your quotes are mixed up

It should be

"{{ states('input_number.lg_max_volume') | float }}"

Hi Mutt,
Thanks, great it is working fine now!

Cheers

Okay, that’s good.
It’s customary and helpful to others to post your final configuration as an example, and to mark a thread that you have a solution to as ‘solved’ by ticking the post that most helped you on the way.
It’s pointless to tick your own posting (unless no-one else contributed) as then EVERY thread would be solved by the OP
Cheers
:beers:

Hi Mutt,

Sure, here you go :slight_smile:

In automations.yaml

- id: '1587888014390'
  alias: LG TV Max volume
  description: ''
  trigger:
  - entity_id: media_player.lg_tv
    platform: state
  condition: []
  action:
  - data_template:
      entity_id: media_player.lg_tv
      volume_level: '{{ 0.01 * states(''input_number.lg_max_volume'') | float}}'
    service: media_player.volume_set

I actually inserted " and ’ excactly where you put them…but HA reordered them …however it is working …anyway.
I have also inserted a 0.01 multiplier to get a integer (0-30) slider.

input_number:
  lg_max_volume:
    name: LGmaxvolume
    initial: 10
    min: 0
    max: 30
    step: 1
#    mode: box
2 Likes