Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95925

How to change the format of an input.number prior to using it in an action?

$
0
0

@wills106 wrote:

I want to remove the decimal point in an input.number and the send the complete number including the fraction in the result of an action value.

By this I mean I have an input.number configured like:

input_number:
  solax_battery_charge:
    name: SolaX Battery Charge A
    initial: 20
    min: 0
    max: 20
    step: 0.1

I have it like this for easy visual reference to what the charge amps are.

So for example I want to set the charge rate at 16.5 on the slider.
But to send the value I need to reformat it as 165 before sending.
I know I could change the slider to 0 - 200

But is there any easy way to change the format prior to sending the value?
I also need to ensure 20 on the slider gets sent as 200

automation:
  - alias: House Battery Charge Rate
    trigger:
      platform: state
      entity_id: input_number.solax_battery_charge
    action:
    - service: modbus.write_register # Enter User Password
      data_template:
        hub: SolaX
        unit: '255'
        address: '0'
        value: '2014'
    - service: modbus.write_register # Battery Charge Amps
      data_template:
        hub: SolaX
        unit: '255'
        address: '36'
        value: "{{ trigger.to_state.state | int }}"

That’s the basic automation. It does work but when the slider is at 20 it’s only setting 2 Amps

If I manually set the value as 200 it sets it to 20 Amp
value: '200'

Posts: 13

Participants: 5

Read full topic


Viewing all articles
Browse latest Browse all 95925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>