Input Number problem!

  - id: luminosita_piantana
    alias: Luminosita Piantana
    trigger:
      platform: state
      entity_id: input_number.piantana_lum
    action:
      - service_template: >
          {% if trigger.to_state.state < '8' %}
            light.turn_off
          {% else %}
            light.turn_on
          {% endif %}
        data_template:
          entity_id: light.piantana
          brightness: >
            {% if trigger.to_state.state < '8' %}
              none
            {% else %}
              '{{ trigger.to_state.state | int }}'
            {% endif %}

no error when I check, but the automation does not work

Try this:

  - id: luminosita_piantana_off
    alias: Luminosita Piantana Off
    trigger:
      platform: state
      entity_id: input_number.piantana_lum
    condition:
      condition: template
      value_template: "{{ trigger.to_state.state|int < 8 }}"
    action:
      service: light.turn_off
      entity_id: light.piantana
  - id: luminosita_piantana_on
    alias: Luminosita Piantana On
    trigger:
      platform: state
      entity_id: input_number.piantana_lum
    condition:
      condition: template
      value_template: "{{ trigger.to_state.state|int >= 8 }}"
    action:
      service: light.turn_on
      entity_id: light.piantana
      data_template:
        brightness: "{{ trigger.to_state.state|int }}"

EDIT: Per discussion below, added int filter to brightness template.

No, this error:

Dec 06 17:35:39 raspberrypi hass[779]: 2018-12-06 17:35:39 ERROR (MainThread) [homeassistant.core] Invalid service data for light.turn_on: expected int for dictionary value @ data[‘brightness’]. Got ‘130.0’

but i try:

  • id: hue_piantana_on
    alias: Hue - Piantana
    trigger:
    platform: state
    entity_id: input_number.piantana_lum
    action:
    service: light.turn_on
    data_template:
    entity_id: light.piantana
    brightness: ‘{{ trigger.to_state.state | int }}’

  • id: hue_piantana_off
    alias: hue_piantana_off
    trigger:
    platform: numeric_state
    entity_id: input_number.piantana_lum
    below: ‘3’
    action:

    • service: homeassistant.turn_off
      entity_id: light.piantana

and it works, thank you very much for your help.

Yep. I keep forgetting that a string representation of a floating point number won’t convert to an int directly, so the int filter is needed. I’ll go back and edit my suggestion accordingly in case someone comes across this in the future. Glad you got it working.