Number to input_number

how do i get this to work in home assistant as input nr.

number:
  - platform: modbus_controller
    modbus_controller_id: brink
    name: "Preset Vakantie"
    address: 6000
    value_type: U_WORD
    min_value: 0
    max_value: 300
    step: 5
    icon: mdi:fan
    unit_of_measurement: "m³/h"

You can’t? Input number is an integration that creates number-like entities who’s state is are manually set by users in the UI rather then by the integration. Number entities are created by many integrations for numeric type entities where the user should be able to change it’s state using either a script or in the ui in addition to the integration.

They are two separate things. Although in practice they are nearly identical in functionality. Why would you want to do this? Is there something an input_number can do that a number can’t I’m unaware of?

i try to use in home assitant to use the service input_number.decrement and input_number.increment but works only on input_number and not on numbers

I’m not sure I understand what you are trying to do.
Is the mod is supposed to send the value from an input number?

The number in ESP-Home only reads values I believe

No, it writes:

Screenshot 2022-06-12 at 19-52-35 Modbus Controller Number

@supershadow you can do an increment/decrement with the set value service and a template:

Decrement:

- service: number.set_value
  target: 
    entity_id: number.preset_vakanti
  data:
    value: "{{ states('number.preset_vakanti')|int(0) - 1 }}"

Increment:

- service: number.set_value
  target: 
    entity_id: number.preset_vakanti
  data:
    value: "{{ states('number.preset_vakanti')|int(0) + 1 }}"

You could even write a couple of scripts that you pass the entity_id and inc/decrement step size to if you use this in more than one place.

how do i get it to work with this

                action: "call-service"
                service: |
                      [[[
                        if( entity.entity_id.startsWith("input_number.") )
                          return "input_number.decrement";
                        if( entity.entity_id.startsWith("counter.") )
                          return "counter.decrement";
                        return "";
                      ]]]
                service_data:
                  entity_id: "[[[ return entity.entity_id ]]]"
              icon: "mdi:arrow-down"

You could try this:

Write a script

script:
  number_decrement:
    sequence:
      - service: number.set_value
        target: 
          entity_id: "{{ entity_id }}"
        data:
          value: "{{ states(entity_id)|int(0) - 1 }}"

Change your card JavaScript to:

                action: "call-service"
                service: |
                      [[[
                        if( entity.entity_id.startsWith("number.") )
                          return "script.number_decrement";
                        if( entity.entity_id.startsWith("counter.") )
                          return "counter.decrement";
                        return "";
                      ]]]
                service_data:
                  entity_id: "[[[ return entity.entity_id ]]]"
              icon: "mdi:arrow-down"

Your JavaScript will generate errors if the entity is not a number or counter. You cant call a null service.

Also note that there is no data sanitisation in the script. So if you need the number to stay within certain bounds you will have to add that logic.

thnx that works :grinning: