Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index out of range #1

Open
unmanagedtn opened this issue Jan 23, 2021 · 1 comment
Open

Index out of range #1

unmanagedtn opened this issue Jan 23, 2021 · 1 comment

Comments

@unmanagedtn
Copy link

unmanagedtn commented Jan 23, 2021

.\check_iei_ups.ps1 192.168.88.196
Exception calling "ToInt32" with "2" argument(s): "Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: startIndex"
At check_iei_ups.ps1:107 char:1
+ [int]$capacity = [convert]::ToInt32($ups_status.Capacity, 10)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentOutOfRangeException
 
Battery status:  | status=3 capacity=0%;40;10 voltage= Current= Temperature=;50;60 'Remaining time'=

the XML returned is as follows...
 The document tree is shown below.
<response>
<led0>1</led0>
<led1>1</led1>
<led2>1</led2>
<led3>1</led3>
<led4>1</led4>
<led5>1</led5>
<led6>1</led6>
<led7>1</led7>
<btn0>up</btn0>
<btn1>up</btn1>
<btn2>up</btn2>
<btn3>up</btn3>
<pot0>92</pot0>
<pot1_1>Standby</pot1_1>
<pot1_2>100</pot1_2>
<pot1_3>8386</pot1_3>
<pot1_4>9</pot1_4>
<pot1_5>31</pot1_5>
<pot1_6>3</pot1_6>
<pot2_1>N/A</pot2_1>
<pot2_2>N/A</pot2_2>
<pot2_3>N/A</pot2_3>
<pot2_4>N/A</pot2_4>
<pot2_5>N/A</pot2_5>
<pot2_6>N/A</pot2_6>
<pot3_1>N/A</pot3_1>
<pot3_2>N/A</pot3_2>
<pot3_3>N/A</pot3_3>
<pot3_4>N/A</pot3_4>
<pot3_5>N/A</pot3_5>
<pot3_6>N/A</pot3_6>
<pot4_1>N/A</pot4_1>
<pot4_2>N/A</pot4_2>
<pot4_3>N/A</pot4_3>
<pot4_4>N/A</pot4_4>
<pot4_5>N/A</pot4_5>
<pot4_6>N/A</pot4_6>
</response>

in reference to the script here...
https://github.com/joubbi/check_iei_ups

@unmanagedtn
Copy link
Author

Ok.
Changed the XML to match at :

$ups_status = @{
    Status = $result.response.pot1_1
    Capacity = $result.response.pot1_2
    Voltage = $result.response.pot1_3
    Current = $result.response.pot1_4
    Temperature = $result.response.pot1_5
    Time = $result.response.pot1_6
}

$status_string = "status={0} capacity={1}% voltage={4} Current={5} Temperature={6} 'Remaining time'={9}" -f

Needs further testing but it is working as far as display and I mainly need the shutdown feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant