Necessary to create sensor to use Input_number as trigger?

I have created the following input_number :

input_number:
  slider1:
    name: Slider
    min: 25
    max: 100
    step: 25

And the following automations :

- id: '1587227266094'
  alias: Adjust brightness eetkamer 100%
  description: ''
  trigger:
  - entity_id: input_number.slider1
    platform: state
    to: '100'
  condition: []
  action:
  - data:
      payload: '{"Protocol":"NEC","Bits":32,"Data":"0x44BBD827","DataLSB":"0x22DD1BE4","Repeat":0}'
      topic: IR_bridge/cmd/IrSend
    service: mqtt.publish
- id: '1587227266095'
  alias: Adjust brightness eetkamer 75%
  description: ''
  trigger:
  - entity_id: input_number.slider1
    platform: state
    to: '75'
  condition: []
  action:
  - data:
      payload: '{"Protocol":"NEC","Bits":32,"Data":"0x44BB34CB","DataLSB":"0x22DD2CD3","Repeat":0}'
      topic: IR_bridge/cmd/IrSend
    service: mqtt.publish
- id: '1587227266096'
  alias: Adjust brightness eetkamer 50%
  description: ''
  trigger:
  - entity_id: input_number.slider1
    platform: state
    to: '50'
  condition: []
  action:
  - data:
      payload: '{"Protocol":"NEC","Bits":32,"Data":"0x44BBFA05","DataLSB":"0x22DD5FA0","Repeat":0}'
      topic: IR_bridge/cmd/IrSend
    service: mqtt.publish
- id: '1587227266097'
  alias: Adjust brightness eetkamer 25%
  description: ''
  trigger:
  - entity_id: input_number.slider1
    platform: state
    to: '25'
  condition: []
  action:
  - data:
      payload: '{"Protocol":"NEC","Bits":32,"Data":"0x44BB728D","DataLSB":"0x22DD4EB1","Repeat":0}'
      topic: IR_bridge/cmd/IrSend
    service: mqtt.publish

But the automations never fire.

If I try something like this :

- id: '1587227266094'
  alias: Adjust brightness eetkamer 100%
  description: ''
  trigger:
  - entity_id: input_number.slider1
    platform: state
    to: 100
  condition: []
  action:
  - data:
      payload: '{"Protocol":"NEC","Bits":32,"Data":"0x44BBD827","DataLSB":"0x22DD1BE4","Repeat":0}'
      topic: IR_bridge/cmd/IrSend
    service: mqtt.publish

I get this error :

2020-04-18 18:52:25 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: expected str for dictionary value @ data['trigger'][0]['to']. Got None. (See ?, line ?). 

What is the correct syntax ?

I think you need to use
platform: numeric_state
instead of
platform: state
in your trigger.

With this input_number :

input_number:
  slider1:
    name: Slider
    min: 25
    max: 100
    step: 25


I created this sensor :

  - platform: template
    sensors:
      brightness:
        friendly_name: "Brightness"
        entity_id:
          - input_number.slider1
        value_template: >
          {{ states('input_number.slider1') }}

And now these automations work :

- id: '1587227266094'
  alias: Adjust brightness eetkamer 100%
  description: ''
  trigger:
  - entity_id: sensor.brightness
    platform: state
    to: '100.0'
  condition: []
  action:
  - data:
      payload: '{"Protocol":"NEC","Bits":32,"Data":"0x44BBD827","DataLSB":"0x22DD1BE4","Repeat":0}'
      topic: IR_bridge/cmnd/IRsend
    service: mqtt.publish
- id: '1587227266095'
  alias: Adjust brightness eetkamer 75%
  description: ''
  trigger:
  - entity_id: sensor.brightness
    platform: state
    to: '75.0'
  condition: []
  action:
  - data:
      payload: '{"Protocol":"NEC","Bits":32,"Data":"0x44BB34CB","DataLSB":"0x22DD2CD3","Repeat":0}'
      topic: IR_bridge/cmd/IRsend
    service: mqtt.publish
- id: '1587227266096'
  alias: Adjust brightness eetkamer 50%
  description: ''
  trigger:
  - entity_id: sensor.brightness
    platform: state
    to: '50.0'
  condition: []
  action:
  - data:
      payload: '{"Protocol":"NEC","Bits":32,"Data":"0x44BBFA05","DataLSB":"0x22DD5FA0","Repeat":0}'
      topic: IR_bridge/cmnd/IRsend
    service: mqtt.publish
- id: '1587227266097'
  alias: Adjust brightness eetkamer 25%
  description: ''
  trigger:
  - entity_id: sensor.brightness
    platform: state
    to: '25.0'
  condition: []
  action:
  - data:
      payload: '{"Protocol":"NEC","Bits":32,"Data":"0x44BB728D","DataLSB":"0x22DD4EB1","Repeat":0}'
      topic: IR_bridge/cmnd/IRsend
    service: mqtt.publish

It seems a work-around that is not needed, but at least it works now.

1 Like

Check the state of the input number at developer tools > states. It needs to match what you use in the automation exactly. All states are stored as strings, so if the input number state is 25.0 you need to use to: '25.0' in the automation trigger, not to: '25'.