eaton 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +6 -0
- data/lib/eaton/cli.rb +15 -0
- data/lib/eaton/power.rb +30 -0
- data/lib/eaton/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e09c47fc8e0509b3adff53932210f89702e91b3e8f77ec2b1b0f79ee5deb70d8
|
|
4
|
+
data.tar.gz: 8c68b870e4ba397080d67ed90f54b3124e488386fb629e7488c71b713fa98302
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3c8c23fbf1933e03b9a02a3d402b2322d46d1a04c9cf2590eeebe32d8e758f44674b4a8d648e7ba0c0419721da69509caa2dbc2497d4df64e8c50da58a431718
|
|
7
|
+
data.tar.gz: 8bb0eaffd65c78bb367b575e096ebba9e0b755f4aafa859380f53dbd2392ac4b99a8240dbe475a954aa3657792fcd9d006f248f4e81c71d9cb6ac94b9472e701
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.4.0] - 2026-12-06
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Per-outlet switching in `Eaton::Power`:
|
|
12
|
+
- `#outlet_state(id)` reports `switched_on`, `switchable` and `reboot_period`
|
|
13
|
+
- `#outlet_switch_on(id)`, `#outlet_switch_off(id)` and `#outlet_reboot(id)`
|
|
14
|
+
post the outlet action. Each refuses (`ArgumentError`) unless the outlet
|
|
15
|
+
reports `switchable: true`.
|
|
16
|
+
- `eaton outlet ID [on|off|reboot]` shows or switches one outlet
|
|
17
|
+
|
|
8
18
|
## [0.3.0] - 2026-09-10
|
|
9
19
|
|
|
10
20
|
### Added
|
data/README.md
CHANGED
|
@@ -77,6 +77,7 @@ All commands support these options:
|
|
|
77
77
|
| `eaton outlets` | Get per-outlet power consumption |
|
|
78
78
|
| `eaton branches` | Get per-branch power distribution |
|
|
79
79
|
| `eaton detailed` | Get detailed power metrics |
|
|
80
|
+
| `eaton outlet ID [on\|off\|reboot]` | Show one outlet's switch state, or switch it |
|
|
80
81
|
|
|
81
82
|
### Output Filtering
|
|
82
83
|
|
|
@@ -201,6 +202,10 @@ detailed = client.detailed
|
|
|
201
202
|
puts "Power Factor: #{detailed[:overall][:power_factor]}"
|
|
202
203
|
puts "Frequency: #{detailed[:overall][:frequency]} Hz"
|
|
203
204
|
|
|
205
|
+
# Switch one outlet (refused unless the outlet reports switchable: true)
|
|
206
|
+
client.outlet_state(3) # => { id: "3", switched_on: true, switchable: true, reboot_period: 10 }
|
|
207
|
+
client.outlet_reboot(3) # off, then on again after reboot_period seconds
|
|
208
|
+
|
|
204
209
|
# Clean up
|
|
205
210
|
client.logout
|
|
206
211
|
```
|
|
@@ -212,6 +217,7 @@ The gem interfaces with these REST API endpoints:
|
|
|
212
217
|
- `/powerDistributions/1` - PDU device information
|
|
213
218
|
- `/powerDistributions/1/inputs/1` - Overall power input
|
|
214
219
|
- `/powerDistributions/1/outlets/{id}` - Individual outlet data
|
|
220
|
+
- `/powerDistributions/1/outlets/{id}/actions/{switchOn,switchOff,reboot}` - Outlet switching (POST)
|
|
215
221
|
- `/powerDistributions/1/branches/{id}` - Branch distribution data
|
|
216
222
|
|
|
217
223
|
## Supported Devices
|
data/lib/eaton/cli.rb
CHANGED
|
@@ -65,6 +65,21 @@ module Eaton
|
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
+
OUTLET_ACTIONS = { "on" => :outlet_switch_on, "off" => :outlet_switch_off, "reboot" => :outlet_reboot }.freeze
|
|
69
|
+
|
|
70
|
+
desc "outlet ID [on|off|reboot]", "Show one outlet's switch state, or switch it"
|
|
71
|
+
def outlet(id, action = nil)
|
|
72
|
+
error("Unknown action: #{action} (use on, off or reboot)") if action && !OUTLET_ACTIONS.key?(action)
|
|
73
|
+
|
|
74
|
+
with_client do |client|
|
|
75
|
+
next output_result("Outlet #{id}", client.outlet_state(id)) unless action
|
|
76
|
+
|
|
77
|
+
# The PDU switches after a delay, so a state read now can still show the old state.
|
|
78
|
+
client.public_send(OUTLET_ACTIONS[action], id)
|
|
79
|
+
output_result("Outlet #{id}", { action: action, status: "requested" })
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
68
83
|
desc "auth", "Test authentication with the PDU"
|
|
69
84
|
def auth
|
|
70
85
|
with_client do |client|
|
data/lib/eaton/power.rb
CHANGED
|
@@ -105,5 +105,35 @@ module Eaton
|
|
|
105
105
|
nominal_voltage: data.dig("specifications", "voltage", "nominal")
|
|
106
106
|
}
|
|
107
107
|
end
|
|
108
|
+
|
|
109
|
+
# Switch state of one outlet. reboot_period is how many seconds #outlet_reboot
|
|
110
|
+
# holds the outlet off; it is a PDU setting, not a request parameter.
|
|
111
|
+
def outlet_state(id)
|
|
112
|
+
data = get(outlet_path(id))
|
|
113
|
+
|
|
114
|
+
{
|
|
115
|
+
id: data["id"],
|
|
116
|
+
switched_on: data.dig("status", "switchedOn"),
|
|
117
|
+
switchable: data.dig("specifications", "switchable"),
|
|
118
|
+
reboot_period: data.dig("settings", "rebootPeriod")
|
|
119
|
+
}
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def outlet_switch_on(id) = outlet_action(id, "switchOn")
|
|
123
|
+
|
|
124
|
+
def outlet_switch_off(id) = outlet_action(id, "switchOff")
|
|
125
|
+
|
|
126
|
+
def outlet_reboot(id) = outlet_action(id, "reboot")
|
|
127
|
+
|
|
128
|
+
private
|
|
129
|
+
|
|
130
|
+
def outlet_path(id) = "/powerDistributions/1/outlets/#{Integer(id)}"
|
|
131
|
+
|
|
132
|
+
# Refuses unless the outlet itself reports switchable: true.
|
|
133
|
+
def outlet_action(id, action)
|
|
134
|
+
raise ArgumentError, "outlet #{id} is not switchable" unless outlet_state(id)[:switchable] == true
|
|
135
|
+
|
|
136
|
+
post("#{outlet_path(id)}/actions/#{action}")
|
|
137
|
+
end
|
|
108
138
|
end
|
|
109
139
|
end
|
data/lib/eaton/version.rb
CHANGED