One-window install: profile, wifi, USB flash and pairing hints (0.2.27)
"Nieuw scherm" used to span two dialogs plus a copy/download of the installation YAML. It is now one dialog: board, name (node name derived, editable), wifi only when secrets.yaml lacks it, the detected USB port, and Installeren. The add-on writes the profile with unique API/OTA keys, merges just the missing wifi lines into secrets.yaml (comments and other secrets untouched, result re-parsed before writing), then builds and flashes with the live ESPHome log and stage in the same dialog; a failed build offers a retry without a second profile. The YAML download endpoint is gone: the profile already lives in the ESPHome folder. Pairing happens in Home Assistant itself, so the done view and a sidebar card per not-yet-paired profile say so, with a button to Apparaten & diensten, the API key to copy and the reminder to allow HA actions. One profile per screen; the dialog says that too. Tests: wifi merge cases, install pre-checks, pending list, profile metadata; the date-anchored hourly forecast test now follows the clock. Firmware 0.2.22 stays current. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
+17
-2
@@ -154,9 +154,24 @@ class ManagerTests(unittest.IsolatedAsyncioTestCase):
|
||||
self.assertEqual(response.status,400)
|
||||
response=await client.put('/api/screens/text.screen',headers=headers,json={'title':'Test','tiles':[]})
|
||||
self.assertEqual(response.status,200)
|
||||
response=await client.post('/api/install',headers=headers,json={'board':'guition','name':'screen-new','friendly_name':'Nieuw'})
|
||||
from firmware import Firmware
|
||||
m.firmware=Firmware(Path(temp)/'esphome',Path(temp))
|
||||
profile={'board':'guition','name':'screen-new','friendly_name':'Nieuw','wifi_ssid':'net','wifi_password':'pw'}
|
||||
# A refused USB target leaves no profile behind.
|
||||
response=await client.post('/api/firmware/profiles',headers=headers,json={**profile,'target':'/dev/ttyUSB9'})
|
||||
self.assertEqual(response.status,400)
|
||||
self.assertFalse((Path(temp)/'esphome'/'screen-new.yaml').exists())
|
||||
response=await client.post('/api/firmware/profiles',headers=headers,json=profile)
|
||||
self.assertEqual(response.status,200)
|
||||
self.assertEqual(response.headers['Cache-Control'],'no-store')
|
||||
self.assertIn('packages/guition.yaml',await response.text())
|
||||
result=await response.json()
|
||||
self.assertEqual(result['file'],'screen-new.yaml')
|
||||
self.assertEqual(len(base64.b64decode(result['api_key'])),32)
|
||||
self.assertNotIn('job',result)
|
||||
self.assertIn('packages/guition.yaml',(Path(temp)/'esphome'/'screen-new.yaml').read_text())
|
||||
self.assertNotIn('pw',json.dumps((await (await client.get('/api/firmware')).json())['wifi']))
|
||||
# Until Home Assistant lists the screen, the page shows the profile as "not yet in HA" with its key.
|
||||
pending=(await (await client.get('/api/inventory?light=1')).json())['pending']
|
||||
self.assertEqual([(p['file'],p['friendly'],p['installed'],p['api_key']==result['api_key']) for p in pending],[('screen-new.yaml','Nieuw',False,True)])
|
||||
|
||||
if __name__=='__main__':unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user