Is it possible to have a chart or table used for an action?

I’m not sure if this is possible but I have an automation I’m trying to build.

I could give it several choices to choose from but it would be an extensive list.

I’m trying make limit amps out of a device based on battery state.

100%: 45
99%: 44
98%: 43
97%:42
96%:41
95%: 40
94%: 40
93%: 40
92%: 40
91%: 40
90%: 40
89%:39
88%:39
87%: 38
86%: 37
85%: 36
84%: 35
83%: 34
82%: 33
81%: 32
80%: 31
79%: 30
78%: 29
77%: 28
76%: 27
75%: 25
74%: 24
73%: 20
72%: 16
71%: 16
70%: 16
69%: 16
68%: 15
67%: 15
66%: 14
<65%: 6 Amps
<50%: OFF

Is there a better way to make an automation to pull from a database or table rather than a very long choice list in an automation?

Trying to plan ahead if i need to make several changes in the future.

You can set a variable to a map. If you’re using the UI, you can select “define variables” in the actions.

Here is an example automation which will take an input number and set the value of a second input number based on your map:

alias: Test Mapping 2
description: ""
trigger:
  - platform: state
    entity_id: input_number.test
condition: []
action:
  - variables:
      mapping: |
        {{
          {
            100:45,
            99:44,
            98:43,
            97:42,
            96:41,
            95:40,
            94:40,
            93:40,
            92:40,
            91:40,
            90:40,
            89:39,
            88:39,
            87:38,
            86:37,
            85:36,
            84:35,
            83:34,
            82:33,
            81:32,
            80:31,
            79:30,
            78:29,
            77:28,
            76:27,
            75:25,
            74:24,
            73:20,
            72:16,
            71:16,
            70:16,
            69:16,
            68:15,
            67:15,
            66:14,
            65:6,
            50:0
          }
        }}
      lookup: "{{ trigger.to_state.state | float(0) }}"
      limit: "{{ mapping[mapping | select('ge', lookup)| sort | first] }}"
  - service: input_number.set_value
    data:
      value: "{{ limit }}"
    target:
      entity_id: input_number.test_2
  - variables: {}
mode: single

edit: made the code a bit more readable by putting each item into its own variable

I don’t know why you have selected the limits as you have. It would be easier to use 0.9 amps per %. Then you subtract 50% from the remaining life and if the result is positive you multiply by 0.9 and this is your limit. You could easily create a template sensor that had the amperage maximum based on the current charge of the battery.

I hope this helps.

Thanks for your help everyone

One more options to use the compensation integration that will do all the math for you.