@@ -241,13 +241,15 @@ async def async_step_init(
241
241
"""Manage the options."""
242
242
243
243
if self .config_entry .entry_id in self .hass .data [DOMAIN ]:
244
- self .coordinator : UniledUpdateCoordinator = self .hass .data [DOMAIN ][self .config_entry .entry_id ]
244
+ self .coordinator : UniledUpdateCoordinator = self .hass .data [DOMAIN ][
245
+ self .config_entry .entry_id
246
+ ]
245
247
else :
246
248
return self .async_abort (reason = "unknown" )
247
249
248
- #self.coordinator: UniledUpdateCoordinator = self.hass.data[DOMAIN][
250
+ # self.coordinator: UniledUpdateCoordinator = self.hass.data[DOMAIN][
249
251
# self.config_entry.entry_id
250
- #]
252
+ # ]
251
253
252
254
if self .config_entry .data .get (CONF_TRANSPORT ) == UNILED_TRANSPORT_ZNG :
253
255
self ._mesh_set_context ()
@@ -714,14 +716,14 @@ async def _async_set_discovered_mac(
714
716
discovery since the dhcp mac can be one digit off from
715
717
the udp discovery mac for devices with multiple network interfaces
716
718
"""
717
- mac_address = device [ATTR_UL_MAC_ADDRESS ]
719
+ mac_address = device . mac_address # [ATTR_UL_MAC_ADDRESS]
718
720
assert mac_address is not None
719
721
# mac = UniledNetDevice.format_mac(mac_address)
720
722
mac = dr .format_mac (mac_address )
721
723
await self .async_set_unique_id (mac )
722
724
for entry in self ._async_current_entries (include_ignore = True ):
723
725
if not (
724
- entry .data .get (CONF_HOST ) == device [ATTR_UL_IP_ADDRESS ]
726
+ entry .data .get (CONF_HOST ) == device . ip_address # [ATTR_UL_IP_ADDRESS]
725
727
or (
726
728
entry .unique_id
727
729
and ":" in entry .unique_id
@@ -754,33 +756,34 @@ async def _async_set_discovered_mac(
754
756
_LOGGER .debug (
755
757
"Discovered '%s' (id=%d, model=%s) from '%s' @ %s" ,
756
758
async_name_from_discovery (device ),
757
- device [ATTR_UL_MODEL_CODE ],
758
- device [ATTR_UL_MODEL_NAME ],
759
- device [ATTR_UL_SOURCE ],
760
- device [ATTR_UL_IP_ADDRESS ],
759
+ device . model_code , # [ATTR_UL_MODEL_CODE],
760
+ device . model_name , # [ATTR_UL_MODEL_NAME],
761
+ device . source , # [ATTR_UL_SOURCE],
762
+ device . ip_address , # [ATTR_UL_IP_ADDRESS],
761
763
)
762
764
763
765
async def _async_network_discovery (self ) -> FlowResult :
764
766
"""Handle network discovery."""
765
767
assert self ._discovered_device is not None
766
768
device = self ._discovered_device
767
769
await self ._async_set_discovered_mac (device , self ._allow_update_mac )
768
- host = device [ATTR_UL_IP_ADDRESS ]
770
+ host = device . ip_address # [ATTR_UL_IP_ADDRESS]
769
771
for progress in self ._async_in_progress ():
770
772
if progress .get ("context" , {}).get (CONF_HOST ) == host :
771
773
return self .async_abort (reason = "already_in_progress" )
772
774
773
- if not device [ATTR_UL_MODEL_NAME ]:
774
- mac_address = device [ATTR_UL_MAC_ADDRESS ]
775
+ if not device . model_name : # [ATTR_UL_MODEL_NAME]:
776
+ mac_address = device . mac_address # [ATTR_UL_MAC_ADDRESS]
775
777
assert mac_address is not None
776
778
# mac = UniledNetDevice.format_mac(mac_address)
777
779
mac = dr .format_mac (mac_address )
778
780
try :
779
781
device = await async_discover_device (self .hass , host )
780
782
except Exception :
781
783
return self .async_abort (reason = "cannot_connect" )
782
- discovered_mac = device [ATTR_UL_MAC_ADDRESS ]
783
- if device [ATTR_UL_MODEL_NAME ] or (
784
+ discovered_mac = device .mac_address # [ATTR_UL_MAC_ADDRESS]
785
+ # if device[ATTR_UL_MODEL_NAME] or (
786
+ if device .model_name or (
784
787
discovered_mac is not None
785
788
and (
786
789
# formatted_discovered_mac := UniledNetDevice.format_mac(
@@ -802,17 +805,17 @@ async def async_step_network_confirm(
802
805
"""Confirm network discovery."""
803
806
assert self ._discovered_device is not None
804
807
device = self ._discovered_device
805
- mac_address = device [ATTR_UL_MAC_ADDRESS ]
808
+ mac_address = device . mac_address # [ATTR_UL_MAC_ADDRESS]
806
809
assert mac_address is not None
807
- model = device [ATTR_UL_MODEL_NAME ]
808
- code = device [ATTR_UL_MODEL_CODE ]
809
- name = device [ATTR_UL_LOCAL_NAME ]
810
+ model = device . model_name # [ATTR_UL_MODEL_NAME]
811
+ code = device . model_code # [ATTR_UL_MODEL_CODE]
812
+ name = device . local_name # [ATTR_UL_LOCAL_NAME]
810
813
811
814
placeholders = {
812
815
"name" : async_name_from_discovery (device ),
813
816
"device_name" : name or mac_address ,
814
817
"model" : f"({ model } )" if model else f"ID#: { code } " ,
815
- "ip" : device [ATTR_UL_IP_ADDRESS ],
818
+ "ip" : device . ip_address , # [ATTR_UL_IP_ADDRESS],
816
819
}
817
820
self .context ["title_placeholders" ] = placeholders
818
821
@@ -826,7 +829,7 @@ async def async_step_network_confirm(
826
829
@callback
827
830
def _async_network_create_entry (self , device : UniledDiscovery ):
828
831
"""Create network entry"""
829
- if device [ATTR_UL_MODEL_NAME ] is None :
832
+ if device . model_name is None : # [ATTR_UL_MODEL_NAME] is None:
830
833
raise AbortFlow ("not_supported" )
831
834
# data: dict[str, Any] = {CONF_TRANSPORT: UNILED_TRANSPORT_NET}
832
835
data : dict [str , Any ] = {}
0 commit comments