Skip to content

Commit

Permalink
Fix: use consistent parameter name for devices' name
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNerma committed Dec 1, 2024
1 parent f98cbdf commit 08209d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ Some routes (such as `get-hourly-usage`) require timestamps. These must be provi

Once connected to a Tapo device, a session is maintained between the server and the device. But Tapo devices set an expiration time, which means the session will eventually expire.

If this happens, you can hit the `/refresh-session?device_name=...` route to refresh the session.
If this happens, you can hit the `/refresh-session?device=...` route to refresh the session.
8 changes: 4 additions & 4 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,21 @@ pub async fn serve(

#[derive(Deserialize)]
struct RefreshDeviceSessionParams {
device_name: String,
device: String,
}

async fn refresh_session(
State(state): State<SharedState>,
Query(params): Query<RefreshDeviceSessionParams>,
) -> ApiResult<()> {
let RefreshDeviceSessionParams { device_name } = params;
let RefreshDeviceSessionParams { device } = params;

let mut state = state.write().await;

let device = state
.devices
.get_mut(&device_name)
.with_context(|| format!("Unkown device: {device_name}"))?;
.get_mut(&device)
.with_context(|| format!("Unkown device: {device}"))?;

device
.refresh_session()
Expand Down

0 comments on commit 08209d1

Please sign in to comment.