Converting milliamps to amps

I’ve got some gosund smart plugs that i’ve managed to pull current, power and voltage. But the plug displays current in milliamps (mA), and i’d like to convert this to amps so it’s uniform with my other smart plugs.

This is the template sensor i use to pull the current (mA) data from the plug:

  - platform: template
    sensors:
      smartplug4_current:
        value_template: >-
          {{ states.switch.smartplug4.attributes.current }}
        unit_of_measurement: 'mA'

I’ve tried a few things, but they either fail the configuration validation, or return unavailable.

Any ideas what i can try?

I was hoping i could just use another template to take the current value and then multiply it by 1000.

  - platform: template
    sensors:
      smartplug4_current:
        value_template: "{{ state_attr('switch.smartplug4', 'current')|int * 1000 }}" 
        unit_of_measurement: 'A'
1 Like

template is your friend

 {{ states.switch.smartplug4.attributes.current }}

1 Like

Thanks both!

That template editor is very handy!

I did realise i should be diving by 1000 instead of multiplying by 1000.

2 Likes

im always playing in there

first place i go when building a template

love the way it saves its else now