@@ -61,6 +61,42 @@ async def async_setup_entry(hass: HomeAssistant, entry: LaMarzoccoConfigEntry) -
6161 client = client ,
6262 )
6363
64+ # initialize the firmware update coordinator early to check the firmware version
65+ firmware_device = LaMarzoccoMachine (
66+ model = entry .data [CONF_MODEL ],
67+ serial_number = entry .unique_id ,
68+ name = entry .data [CONF_NAME ],
69+ cloud_client = cloud_client ,
70+ )
71+
72+ firmware_coordinator = LaMarzoccoFirmwareUpdateCoordinator (
73+ hass , entry , firmware_device
74+ )
75+ await firmware_coordinator .async_config_entry_first_refresh ()
76+ gateway_version = version .parse (
77+ firmware_device .firmware [FirmwareType .GATEWAY ].current_version
78+ )
79+
80+ if gateway_version >= version .parse ("v5.0.9" ):
81+ # remove host from config entry, it is not supported anymore
82+ data = {k : v for k , v in entry .data .items () if k != CONF_HOST }
83+ hass .config_entries .async_update_entry (
84+ entry ,
85+ data = data ,
86+ )
87+
88+ elif gateway_version < version .parse ("v3.4-rc5" ):
89+ # incompatible gateway firmware, create an issue
90+ ir .async_create_issue (
91+ hass ,
92+ DOMAIN ,
93+ "unsupported_gateway_firmware" ,
94+ is_fixable = False ,
95+ severity = ir .IssueSeverity .ERROR ,
96+ translation_key = "unsupported_gateway_firmware" ,
97+ translation_placeholders = {"gateway_version" : str (gateway_version )},
98+ )
99+
64100 # initialize local API
65101 local_client : LaMarzoccoLocalClient | None = None
66102 if (host := entry .data .get (CONF_HOST )) is not None :
@@ -117,30 +153,16 @@ def bluetooth_configured() -> bool:
117153
118154 coordinators = LaMarzoccoRuntimeData (
119155 LaMarzoccoConfigUpdateCoordinator (hass , entry , device , local_client ),
120- LaMarzoccoFirmwareUpdateCoordinator ( hass , entry , device ) ,
156+ firmware_coordinator ,
121157 LaMarzoccoStatisticsUpdateCoordinator (hass , entry , device ),
122158 )
123159
124160 # API does not like concurrent requests, so no asyncio.gather here
125161 await coordinators .config_coordinator .async_config_entry_first_refresh ()
126- await coordinators .firmware_coordinator .async_config_entry_first_refresh ()
127162 await coordinators .statistics_coordinator .async_config_entry_first_refresh ()
128163
129164 entry .runtime_data = coordinators
130165
131- gateway_version = device .firmware [FirmwareType .GATEWAY ].current_version
132- if version .parse (gateway_version ) < version .parse ("v3.4-rc5" ):
133- # incompatible gateway firmware, create an issue
134- ir .async_create_issue (
135- hass ,
136- DOMAIN ,
137- "unsupported_gateway_firmware" ,
138- is_fixable = False ,
139- severity = ir .IssueSeverity .ERROR ,
140- translation_key = "unsupported_gateway_firmware" ,
141- translation_placeholders = {"gateway_version" : gateway_version },
142- )
143-
144166 await hass .config_entries .async_forward_entry_setups (entry , PLATFORMS )
145167
146168 async def update_listener (
0 commit comments