@@ -133,26 +133,20 @@ async def _async_wifi_entities_list(
133133 ]
134134 )
135135 _LOGGER .debug ("WiFi networks count: %s" , wifi_count )
136- networks : dict = {}
136+ networks : dict [ int , dict [ str , Any ]] = {}
137137 for i in range (1 , wifi_count + 1 ):
138138 network_info = await avm_wrapper .async_get_wlan_configuration (i )
139139 # Devices with 4 WLAN services, use the 2nd for internal communications
140140 if not (wifi_count == 4 and i == 2 ):
141- networks [i ] = {
142- "ssid" : network_info ["NewSSID" ],
143- "bssid" : network_info ["NewBSSID" ],
144- "standard" : network_info ["NewStandard" ],
145- "enabled" : network_info ["NewEnable" ],
146- "status" : network_info ["NewStatus" ],
147- }
141+ networks [i ] = network_info
148142 for i , network in networks .copy ().items ():
149- networks [i ]["switch_name" ] = network ["ssid " ]
143+ networks [i ]["switch_name" ] = network ["NewSSID " ]
150144 if (
151145 len (
152146 [
153147 j
154148 for j , n in networks .items ()
155- if slugify (n ["ssid " ]) == slugify (network ["ssid " ])
149+ if slugify (n ["NewSSID " ]) == slugify (network ["NewSSID " ])
156150 ]
157151 )
158152 > 1
@@ -434,13 +428,11 @@ async def _async_fetch_update(self) -> None:
434428 for key , attr in attributes_dict .items ():
435429 self ._attributes [attr ] = self .port_mapping [key ]
436430
437- async def _async_switch_on_off_executor (self , turn_on : bool ) -> bool :
431+ async def _async_switch_on_off_executor (self , turn_on : bool ) -> None :
438432 self .port_mapping ["NewEnabled" ] = "1" if turn_on else "0"
439-
440- resp = await self ._avm_wrapper .async_add_port_mapping (
433+ await self ._avm_wrapper .async_add_port_mapping (
441434 self .connection_type , self .port_mapping
442435 )
443- return bool (resp is not None )
444436
445437
446438class FritzBoxDeflectionSwitch (FritzBoxBaseCoordinatorSwitch ):
@@ -525,12 +517,11 @@ async def async_turn_off(self, **kwargs: Any) -> None:
525517 """Turn off switch."""
526518 await self ._async_handle_turn_on_off (turn_on = False )
527519
528- async def _async_handle_turn_on_off (self , turn_on : bool ) -> bool :
520+ async def _async_handle_turn_on_off (self , turn_on : bool ) -> None :
529521 """Handle switch state change request."""
530522 await self ._avm_wrapper .async_set_allow_wan_access (self .ip_address , turn_on )
531523 self ._avm_wrapper .devices [self ._mac ].wan_access = turn_on
532524 self .async_write_ha_state ()
533- return True
534525
535526
536527class FritzBoxWifiSwitch (FritzBoxBaseSwitch ):
@@ -541,10 +532,11 @@ def __init__(
541532 avm_wrapper : AvmWrapper ,
542533 device_friendly_name : str ,
543534 network_num : int ,
544- network_data : dict ,
535+ network_data : dict [ str , Any ] ,
545536 ) -> None :
546537 """Init Fritz Wifi switch."""
547538 self ._avm_wrapper = avm_wrapper
539+ self ._wifi_info = network_data
548540
549541 self ._attributes = {}
550542 self ._attr_entity_category = EntityCategory .CONFIG
@@ -560,7 +552,7 @@ def __init__(
560552 type = SWITCH_TYPE_WIFINETWORK ,
561553 callback_update = self ._async_fetch_update ,
562554 callback_switch = self ._async_switch_on_off_executor ,
563- init_state = network_data ["enabled " ],
555+ init_state = network_data ["NewEnable " ],
564556 )
565557 super ().__init__ (self ._avm_wrapper , device_friendly_name , switch_info )
566558
@@ -587,7 +579,9 @@ async def _async_fetch_update(self) -> None:
587579 self ._attributes ["mac_address_control" ] = wifi_info [
588580 "NewMACAddressControlEnabled"
589581 ]
582+ self ._wifi_info = wifi_info
590583
591584 async def _async_switch_on_off_executor (self , turn_on : bool ) -> None :
592585 """Handle wifi switch."""
586+ self ._wifi_info ["NewEnable" ] = turn_on
593587 await self ._avm_wrapper .async_set_wlan_configuration (self ._network_num , turn_on )
0 commit comments