@@ -2274,19 +2274,13 @@ mod tests {
22742274 struct RecordingHomeProvider {
22752275 executed : Arc < std:: sync:: Mutex < Vec < HomeActionKind > > > ,
22762276 light : Arc < std:: sync:: Mutex < StubLightState > > ,
2277- climate : Arc < std:: sync:: Mutex < StubClimateState > > ,
22782277 }
22792278
22802279 struct StubLightState {
22812280 power : String ,
22822281 brightness : Option < u64 > ,
22832282 }
22842283
2285- struct StubClimateState {
2286- power : String ,
2287- temperature : Option < f64 > ,
2288- }
2289-
22902284 impl StubLightState {
22912285 fn new ( ) -> Self {
22922286 Self {
@@ -2296,21 +2290,11 @@ mod tests {
22962290 }
22972291 }
22982292
2299- impl StubClimateState {
2300- fn new ( ) -> Self {
2301- Self {
2302- power : "off" . into ( ) ,
2303- temperature : None ,
2304- }
2305- }
2306- }
2307-
23082293 impl RecordingHomeProvider {
23092294 fn new ( executed : Arc < std:: sync:: Mutex < Vec < HomeActionKind > > > ) -> Self {
23102295 Self {
23112296 executed,
23122297 light : Arc :: new ( std:: sync:: Mutex :: new ( StubLightState :: new ( ) ) ) ,
2313- climate : Arc :: new ( std:: sync:: Mutex :: new ( StubClimateState :: new ( ) ) ) ,
23142298 }
23152299 }
23162300
@@ -2321,14 +2305,6 @@ mod tests {
23212305 fn power ( & self ) -> String {
23222306 self . light . lock ( ) . unwrap ( ) . power . clone ( )
23232307 }
2324-
2325- fn climate_power ( & self ) -> String {
2326- self . climate . lock ( ) . unwrap ( ) . power . clone ( )
2327- }
2328-
2329- fn climate_temperature ( & self ) -> Option < f64 > {
2330- self . climate . lock ( ) . unwrap ( ) . temperature
2331- }
23322308 }
23332309
23342310 fn workspace_root ( ) -> PathBuf {
@@ -2458,19 +2434,6 @@ mod tests {
24582434 query : & str ,
24592435 _action_hint : Option < HomeActionKind > ,
24602436 ) -> Result < HomeTarget > {
2461- let lower = query. to_lowercase ( ) ;
2462- if lower. contains ( "thermostat" ) || lower. contains ( "climate" ) {
2463- return Ok ( HomeTarget {
2464- kind : HomeTargetKind :: Entity ,
2465- query : query. into ( ) ,
2466- display_name : query. into ( ) ,
2467- entity_ids : vec ! [ "climate.test" . into( ) ] ,
2468- domain : Some ( "climate" . into ( ) ) ,
2469- area : Some ( "Hall" . into ( ) ) ,
2470- confidence : 0.96 ,
2471- voice_safe : true ,
2472- } ) ;
2473- }
24742437 Ok ( HomeTarget {
24752438 kind : HomeTargetKind :: Entity ,
24762439 query : query. into ( ) ,
@@ -2484,25 +2447,6 @@ mod tests {
24842447 }
24852448
24862449 async fn get_state ( & self , target : & HomeTarget ) -> Result < HomeState > {
2487- if target. domain . as_deref ( ) == Some ( "climate" ) {
2488- let climate = self . climate . lock ( ) . unwrap ( ) ;
2489- let mut attributes = serde_json:: Map :: new ( ) ;
2490- if let Some ( temperature) = climate. temperature {
2491- attributes. insert ( "temperature" . into ( ) , serde_json:: json!( temperature) ) ;
2492- }
2493- return Ok ( HomeState {
2494- target_name : target. display_name . clone ( ) ,
2495- domain : target. domain . clone ( ) ,
2496- area : target. area . clone ( ) ,
2497- entities : vec ! [ Entity {
2498- entity_id: target. entity_ids[ 0 ] . clone( ) ,
2499- state: climate. power. clone( ) ,
2500- attributes: serde_json:: Value :: Object ( attributes) ,
2501- } ] ,
2502- available : true ,
2503- spoken_summary : format ! ( "{} is {}" , target. display_name, climate. power) ,
2504- } ) ;
2505- }
25062450 let light = self . light . lock ( ) . unwrap ( ) ;
25072451 let mut attributes = serde_json:: Map :: new ( ) ;
25082452 if let Some ( brightness) = light. brightness {
@@ -2523,30 +2467,6 @@ mod tests {
25232467 }
25242468
25252469 async fn execute ( & self , action : HomeAction ) -> Result < ActionResult > {
2526- if action. target . domain . as_deref ( ) == Some ( "climate" ) {
2527- {
2528- let mut climate = self . climate . lock ( ) . unwrap ( ) ;
2529- match action. kind {
2530- HomeActionKind :: TurnOff => {
2531- climate. power = "off" . into ( ) ;
2532- climate. temperature = None ;
2533- }
2534- HomeActionKind :: SetTemperature => {
2535- climate. power = "heat" . into ( ) ;
2536- climate. temperature = action. value ;
2537- }
2538- other => anyhow:: bail!( "unsupported climate stub action: {other:?}" ) ,
2539- }
2540- }
2541- self . executed . lock ( ) . unwrap ( ) . push ( action. kind ) ;
2542- return Ok ( ActionResult {
2543- success : true ,
2544- spoken_summary : format ! ( "Executed {:?}" , action. kind) ,
2545- affected_targets : vec ! [ action. target. display_name] ,
2546- state_snapshot : None ,
2547- confidence : Some ( action. target . confidence ) ,
2548- } ) ;
2549- }
25502470 {
25512471 let mut light = self . light . lock ( ) . unwrap ( ) ;
25522472 match action. kind {
@@ -3414,57 +3334,6 @@ mod tests {
34143334 assert_eq ! ( provider. power( ) , "on" ) ;
34153335 }
34163336
3417- #[ tokio:: test]
3418- async fn home_undo_restores_off_state_after_set_temperature ( ) {
3419- let executed = Arc :: new ( std:: sync:: Mutex :: new ( Vec :: new ( ) ) ) ;
3420- let provider = Arc :: new ( RecordingHomeProvider :: new ( executed. clone ( ) ) ) ;
3421- let dispatcher = ToolDispatcher :: new ( Some ( provider. clone ( ) ) ) ;
3422- let ctx = || ToolExecutionContext {
3423- request_origin : RequestOrigin :: Dashboard ,
3424- ..ToolExecutionContext :: default ( )
3425- } ;
3426-
3427- assert_eq ! ( provider. climate_power( ) , "off" ) ;
3428-
3429- assert ! (
3430- dispatcher
3431- . execute_with_context(
3432- & ToolCall {
3433- name: "home_control" . into( ) ,
3434- arguments: serde_json:: json!( {
3435- "entity" : "thermostat" ,
3436- "action" : "set_temperature" ,
3437- "value" : 72
3438- } ) ,
3439- } ,
3440- ctx( ) ,
3441- )
3442- . await
3443- . success
3444- ) ;
3445- assert_eq ! ( provider. climate_power( ) , "heat" ) ;
3446- assert_eq ! ( provider. climate_temperature( ) , Some ( 72.0 ) ) ;
3447-
3448- let undo = dispatcher
3449- . execute_with_context (
3450- & ToolCall {
3451- name : "home_undo" . into ( ) ,
3452- arguments : serde_json:: json!( { } ) ,
3453- } ,
3454- ctx ( ) ,
3455- )
3456- . await ;
3457-
3458- assert ! ( undo. success) ;
3459- assert ! ( undo. output. contains( "Undid the last home action" ) ) ;
3460- assert_eq ! (
3461- * executed. lock( ) . unwrap( ) ,
3462- vec![ HomeActionKind :: SetTemperature , HomeActionKind :: TurnOff , ]
3463- ) ;
3464- assert_eq ! ( provider. climate_power( ) , "off" ) ;
3465- assert_eq ! ( provider. climate_temperature( ) , None ) ;
3466- }
3467-
34683337 #[ tokio:: test]
34693338 async fn action_history_hydrates_from_audit_log ( ) {
34703339 let path = std:: env:: temp_dir ( ) . join ( format ! (
0 commit comments