matterbridge-daikin-local 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/apps/frontend/build/app.js +3 -3
- package/apps/frontend/build/app.js.map +3 -3
- package/dist/module.js +2 -2
- package/dist/setup/setupApi.js +7 -7
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.12.1] - 2026-11-01
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- [setup]: Show the reason when an air conditioner could not be removed. The setup page removed one through a DELETE request, which Matterbridge answers with 204 and no body whatever the plugin returns, so a removal that failed showed as a success. It is now a POST to `remove-device`, whose reply the page reads like every other.
|
|
12
|
+
|
|
7
13
|
## [0.12.0] - 2026-10-25
|
|
8
14
|
|
|
9
15
|
### Added
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
async function M(e,t,o){try{let[s,a]=e.split(" "),r={method:s};t!==void 0&&(r.headers={"Content-Type":"application/json"},r.body=JSON.stringify(t));let c=await fetch(new URL(`api/${a}${o===void 0?"":`?${o}`}`,document.baseURI),r);if(c.status===204)return{ok:!0};if(c.status===503)return{ok:!1,error:"The plugin is not running. Start it in Matterbridge, then reload this page."};let d=await c.json();return"ok"in d?d:{ok:!1,error:d.error??`The plugin answered with status ${c.status}`}}catch{return{ok:!1,error:"Matterbridge did not answer. Check that it is running, then try again."}}}var i={screen:"loading",setup:void 0,found:[],selected:new Set,queue:[],saved:[],handled:[],isBusy:!1,busyText:"",error:"",info:"",confirmingRemoval:""};function S(){return i.queue[0]}function C(e){return e.name===""?e.adapter.host:e.name}function G(e){return(i.setup?.devices??[]).some(t=>t.macAddress===e.macAddress)}function R(e){let{fanControl:t,fanSpeedWhenHidden:o,swingControl:s,swingAxes:a,swingModeWhenHidden:r,modeControl:c,modeSwitches:d,modeReplacements:l,fanAutoControl:p,hasSeparateFan:g,specialModeSwitches:m,hasOutdoorTemperatureSensor:x,hasSeparateHumiditySensor:T,isComposed:w}=e;return{fanControl:t,fanSpeedWhenHidden:o,swingControl:s,swingAxes:a,swingModeWhenHidden:r,modeControl:c,modeSwitches:[...d],modeReplacements:{...l},fanAutoControl:p,hasSeparateFan:g,specialModeSwitches:[...m],hasOutdoorTemperatureSensor:x,hasSeparateHumiditySensor:T,isComposed:w}}var Se={fanControl:"steps",fanSpeedWhenHidden:"keep",swingControl:"switches",swingAxes:"both",swingModeWhenHidden:"keep",modeControl:"native",modeSwitches:[],modeReplacements:{},fanAutoControl:"native",hasSeparateFan:!1,specialModeSwitches:[],hasOutdoorTemperatureSensor:!1,hasSeparateHumiditySensor:!1,isComposed:!0},be=32;function Q(e,t){if(e===""||!t.has(e))return e;for(let o=2;;o++){let s=` ${o}`,a=`${e.slice(0,be-s.length).trimEnd()}${s}`;if(!t.has(a))return a}}function te(e){let t=(i.setup?.devices??[]).filter(s=>s.macAddress!==e.adapter.macAddress).map(s=>s.name),o=i.queue.filter(s=>s!==e).map(s=>s.name);return new Set([...t,...o].filter(s=>s!==""))}function ne(e){let t=new Set((i.setup?.devices??[]).map(o=>o.name));return e.map(o=>{let s=Q(o.name??"",t);return s!==""&&t.add(s),{adapter:o,name:s,isNew:!0,...R(Se)}})}function oe(e){let{capabilities:t,controls:o,name:s,macAddress:a,host:r,protocol:c,requiresRegistration:d,usesHttps:l,requiresLocalPassword:p}=e;return{adapter:{host:r,protocol:c,macAddress:a,requiresRegistration:d,usesHttps:l,requiresLocalPassword:p},name:s,isNew:!1,capabilities:t,controls:o,...R(e)}}var se={fanSteps:[],hasFanAuto:!1,hasSwing:!1,swingModes:[],swingsOnBothAxes:!1,switchableModes:[],lackingModes:[],specialModes:[]};function J(e,t,o,s){if(!s.switchableModes.includes(e)||!s.lackingModes.includes(t))return!1;let a=s.switchableModes.filter(c=>c!==e).map(c=>o[c]);if(a.includes(t))return!1;if(t!=="auto")return!0;let r=new Set([...s.switchableModes,...a]);return r.has("cool")&&r.has("heat")}function D(e,t){let o={};for(let s of t.switchableModes){let a=e[s];a!==void 0&&J(s,a,e,t)&&(o[s]=a)}return o}var I={apple:{title:"Apple Home",text:"Fan speed as a percentage, the swing as the rocking of the fan on one axis, the humidity on a sensor of its own too, and a switch for auto fan and for each of dry and fan, each a device of its own."},google:{title:"Google Home",text:"Fan speed as steps, the swing as the rocking of the fan on one axis, the humidity on a sensor of its own too, and a switch for auto fan and for each of dry and fan, each a device of its own."},matter:{title:"Full Matter support",text:"For apps that show every Matter control: fan speed as steps with its auto mode, the swing as the rocking of the fan, a switch for each special mode and the outdoor temperature, all as one device."}};function L(e,t){let o=e==="matter",s=t.hasSwing&&(o||t.fanSteps.length>0),a=s?"native":"hidden",r=o?[]:t.switchableModes.filter(c=>c==="dehumidify"||c==="fan");return{fanControl:t.fanSteps.length===0?"hidden":e==="apple"?"percent":"steps",fanSpeedWhenHidden:"keep",swingControl:a,swingAxes:!o&&s&&t.swingsOnBothAxes?"horizontal":"both",swingModeWhenHidden:"keep",modeControl:r.length>0?"switches":"native",modeSwitches:r,modeReplacements:{},fanAutoControl:!o&&t.hasFanAuto?"switch":"native",hasSeparateFan:!1,specialModeSwitches:o?[...t.specialModes]:[],hasOutdoorTemperatureSensor:o,hasSeparateHumiditySensor:!o,isComposed:o}}function ie(e,t,o){let s=R(e);o.fanSteps.length===0&&Object.assign(s,{fanControl:"hidden",fanSpeedWhenHidden:"keep"}),s.fanControl==="hidden"&&(s.hasSeparateFan=!1);let a=s.fanAutoControl==="firstStep"||s.fanAutoControl==="lastStep",r=s.fanControl==="hidden"&&s.fanSpeedWhenHidden!=="keep";return(!o.hasFanAuto||a&&s.fanControl==="hidden"||r)&&(s.fanAutoControl="native"),o.hasSwing||Object.assign(s,{swingControl:"hidden",swingModeWhenHidden:"keep"}),s.fanControl==="hidden"&&s.swingControl==="switches"&&(s.swingControl="native"),(s.swingControl!=="native"&&s.swingControl!=="switches"||!o.swingsOnBothAxes)&&(s.swingAxes="both"),s.modeSwitches=s.modeControl==="switches"?o.switchableModes.filter(d=>s.modeSwitches.includes(d)):[],s.modeReplacements=D(s.modeReplacements,o),{native:!0,select:o.switchableModes.includes("dehumidify")||o.switchableModes.includes("fan"),switches:s.modeSwitches.length>0}[s.modeControl]||(s.modeControl="native"),s.specialModeSwitches=o.specialModes.filter(d=>s.specialModeSwitches.includes(d)),JSON.stringify(s)===JSON.stringify(L(t,o))}var Z;function ae(e){Z=e}function h(){let e=document.getElementById("app");if(e===null||Z===void 0)return;let t=`${i.screen}:${S()?.adapter.host??""}`,o=e.dataset.form===t,s=document.activeElement,a=s instanceof HTMLElement?s.id:"",r=s instanceof HTMLInputElement&&(s.type==="text"||s.type==="password")?{start:s.selectionStart,end:s.selectionEnd}:void 0,c=new Map;for(let l of e.querySelectorAll("input[type=text], input[type=password]"))l.id!==""&&c.set(l.id,l.value);if(e.replaceChildren(...Z[i.screen]().filter(l=>l!==!1&&l!==null&&l!==void 0)),e.dataset.form=t,!o)return;for(let[l,p]of c){let g=document.getElementById(l);g instanceof HTMLInputElement&&(g.value=p)}if(a==="")return;let d=document.getElementById(a);d?.focus(),r!==void 0&&d instanceof HTMLInputElement&&d.setSelectionRange(r.start,r.end)}async function N(e,t){i.isBusy=!0,i.busyText=e,i.error="",i.info="",h();try{return await t()}finally{i.isBusy=!1,h()}}async function B(){let e=await M("GET state");if(!e.ok){i.error=e.error,i.screen="home",h();return}if(i.setup=e.state,e.state.devices.length===0){await F();return}i.screen="home",h()}async function W(){let e=await M("GET state");e.ok&&(i.setup=e.state)}function k(){i.queue=[],i.saved=[],i.handled=[],i.error="",i.info="",i.screen="home",W().then(h),h()}async function F(){i.screen="find";let e=await N("Searching your network. This takes about three seconds\u2026",async()=>M("POST discover"));if(!e.ok){i.error=`The search did not run: ${e.error}`,h();return}await W();let t=i.found.filter(o=>!e.devices.some(s=>s.host===o.host)&&i.selected.has(o.host)).map(o=>({...o,isConfigured:G(o)}));i.found=[...e.devices,...t];for(let o of e.devices)o.isConfigured||i.selected.add(o.host);h()}async function re(e){let t=await N(`Looking for an adapter at ${e}\u2026`,async()=>M("POST identify",{host:e}));if(!t.ok){i.error=t.error,h();return}let o=G(t.device),s=t.device.requiresRegistration===!0;i.found=[...i.found.filter(a=>a.host!==t.device.host),{...t.device,isConfigured:o,needsRegistration:s}],o||i.selected.add(t.device.host),h()}function U(e){i.queue=e,i.saved=[],i.handled=[],X()}async function X(){let e=S();if(e===void 0){i.screen=i.saved.length>0?"done":"home",await W(),h();return}i.screen="connect",i.error="",i.info="",e.probe=void 0,h(),await P(e)}async function P(e,t){let o={device:e.adapter,localPassword:e.localPassword,key:t},s=t===void 0?`Checking ${C(e)}\u2026`:`Registering with ${C(e)}\u2026`,a=await N(s,async()=>M(t===void 0?"POST probe":"POST register",o));if(!a.ok){i.error=a.error,h();return}if(e.probe=a.result,e.adapter=a.result.device,a.result.status==="ready"){let r=e.controls===void 0;e.capabilities=a.result.capabilities,e.controls=a.result.controls,e.isNew&&r&&e.controls!==void 0&&Object.assign(e,L("apple",e.controls));let c=a.result.device.name??"";e.name===""&&c!==""&&(e.name=Q(c,te(e))),i.screen="options"}h()}function ce(){let e=i.queue.shift();e!==void 0&&i.handled.push({label:C(e),isSaved:!1}),X()}async function le(e){let t=e.name.trim(),o=xe(e,t);if(o!==""){i.error=o,h();return}let{adapter:s,localPassword:a}=e,r={...s,name:t,localPassword:a,...R(e)},c=await N(`Saving ${t}\u2026`,async()=>M("POST device",{device:r}));if(!c.ok){i.error=c.error,h();return}i.setup=c.state,i.saved.push(t),i.handled.push({label:t,isSaved:!0}),i.queue.shift(),await X()}function xe(e,t){return t===""?"Give the air conditioner a name: it is the name it gets in Matter.":(i.setup?.devices??[]).some(s=>s.name===t&&s.macAddress!==e.adapter.macAddress)?`"${t}" is already the name of another air conditioner. Pick a different one.`:""}var _="Matterbridge's own list of devices shows the change once you reload its page.",de="Restart Matterbridge to apply the new options in Matter: until then the air conditioner keeps its current controls.";async function pe(e){let t=await N(`Removing ${e.name}\u2026`,async()=>M("DELETE device",void 0,`macAddress=${encodeURIComponent(e.macAddress)}`));i.confirmingRemoval="",t.ok?i.info=`${e.name} is removed. ${_}`:i.error=t.error,await W(),h()}function n(e,t={},...o){let s=document.createElement(e);for(let[a,r]of Object.entries(t))r===void 0||r===!1||(a==="class"?s.className=String(r):a==="html"?s.innerHTML=String(r):a.startsWith("on")&&typeof r=="function"?s.addEventListener(a.slice(2),r):a in s?s[a]=r:s.setAttribute(a,String(r)));for(let a of o)a!==!1&&a!==null&&a!==void 0&&s.append(a);return s}function u(e,t,o="quiet",s=!1){return n("button",{type:"button",class:`button ${o}`,onclick:t,disabled:s||i.isBusy},e)}function b(){return i.isBusy?n("p",{class:"notice working",role:"status"},n("span",{class:"spinner"}),i.busyText):i.error!==""?n("p",{class:"notice problem",role:"alert"},i.error):i.info!==""?n("p",{class:"notice",role:"status"},i.info):null}function K(){let e=S();if(e===void 0||!e.isNew||i.handled.length+i.queue.length<2)return null;let t=i.screen==="connect"?"Connecting":"Choosing options";return n("ol",{class:"units","aria-label":"Air conditioners in this setup"},...i.handled.map(o=>n("li",{class:o.isSaved?"done":"skipped"},n("strong",{},o.label),n("span",{class:"meta"},o.isSaved?"Added":"Skipped"))),...i.queue.map((o,s)=>n("li",{class:s===0?"current":"ahead","aria-current":s===0?"true":void 0},n("strong",{},C(o)),n("span",{class:"meta"},s===0?t:"Waiting"))))}function z(e,t){return n("header",{class:"unit-header"},n("h1",{},C(e)),n("p",{class:"meta"},t))}function E(){if(i.queue.length>0&&!i.queue.some(s=>s.isNew))return null;let e=["Find","Connect","Options"],o=["find","connect","options"].indexOf(i.screen);return n("ol",{class:"steps"},...e.map((s,a)=>{let r="ahead";return a<o?r="done":a===o&&(r="current"),n("li",{class:r,"aria-current":a===o?"step":void 0},s)}))}function Me(e,t){let o=n("input",{type:"password",id:"lock-code",inputMode:"numeric",autocomplete:"off",maxLength:64});return n("div",{class:"field"},n("label",{for:"lock-code"},"Child lock code"),n("p",{class:"help"},"The 4-digit code set under Child lock in the Daikin app the adapter was set up with. It is not printed on the adapter."),t?n("p",{class:"problem-text"},"The adapter did not accept that code."):null,n("div",{class:"inline-form"},o,u("Check the code",()=>{o.value!==""&&(e.localPassword=o.value,P(e))},"primary")))}function ke(e,t){let o=n("input",{type:"text",id:"adapter-key",autocomplete:"off",spellcheck:!1,maxLength:64});return n("div",{class:"field"},n("label",{for:"adapter-key"},"KEY on the adapter"),n("p",{class:"help"},"This adapter only answers apps it has registered. The KEY is printed on its label, next to the SSID, and in the operation manual. It is used once and not stored."),t?n("p",{class:"problem-text"},"The adapter did not accept that KEY."):null,n("div",{class:"inline-form"},o,u("Register",()=>{o.value.trim()!==""&&P(e,o.value.trim())},"primary")))}function Ce(e){let t=e.probe?.status;return t==="localPasswordRequired"||t==="localPasswordRejected"?Me(e,t==="localPasswordRejected"):t==="registrationRequired"||t==="registrationRejected"?ke(e,t==="registrationRejected"):t==="unreachable"?n("p",{class:"notice problem",role:"alert"},`${e.name} did not answer at ${e.adapter.host}. Check that it has power and is on the network, then try again.`):t==="failed"?n("p",{class:"notice problem",role:"alert"},`${e.name} answered with an error: ${e.probe?.message??"unknown"}`):null}function he(){let e=S();if(e===void 0)return[b()];let t=e.probe?.status==="unreachable"||e.probe?.status==="failed"||i.error!=="";return[E(),K(),z(e,`Connecting to its adapter at ${e.adapter.host}.`),b(),i.isBusy?null:Ce(e),n("div",{class:"footer"},t?u("Try again",()=>{P(e)}):null,u(e.isNew&&i.queue.length>1?"Skip this one":"Cancel",e.isNew&&i.queue.length>1?ce:k))]}function ue(){let e=i.saved,t=(i.setup?.devices??[]).some(o=>e.includes(o.name)&&o.needsRestart);return[n("header",{},n("h1",{},e.length===1?`${e[0]} is set up`:`${e.length} air conditioners are set up`)),n("p",{class:"lead"},"They now appear in the Matter apps paired with Matterbridge. If Matterbridge is not paired yet, pair it from its home page."),t?n("p",{class:"help"},n("strong",{},de)):null,n("p",{class:"help"},_),n("div",{class:"footer"},u("Done",k,"primary"))]}function Ae(e){let t=!e.isConfigured,o=[];e.isConfigured&&o.push("Already set up."),e.name===void 0&&o.push("It has not told its name yet: you will name it in its options."),t&&e.needsRegistration?o.push("Asks for the KEY printed on its label."):t&&e.requiresRegistration&&o.push("Already registered with this plugin, so it will not ask for its KEY."),t&&e.requiresLocalPassword&&o.push("Asks for its child lock code.");let s=n("input",{type:"checkbox",id:`found-${e.host}`,checked:t&&i.selected.has(e.host),disabled:!t,onchange:()=>{s.checked?i.selected.add(e.host):i.selected.delete(e.host),h()}});return n("li",{class:t?"found":"found unavailable"},n("label",{for:`found-${e.host}`},s,n("span",{},n("strong",{},e.name??"Unnamed adapter"),n("span",{class:"meta"},` ${e.host}`),...o.map(a=>n("span",{class:"meta note"},a)))))}function fe(){let e=i.found.filter(a=>i.selected.has(a.host)&&!a.isConfigured),t=n("input",{type:"text",id:"host",placeholder:"192.168.1.50",spellcheck:!1,autocomplete:"off"}),o=()=>{t.value.trim()!==""&&re(t.value.trim())};t.addEventListener("keydown",a=>{a.key==="Enter"&&o()});let s=e.length===1?"Set up 1 air conditioner":`Set up ${e.length} air conditioners`;return[E(),n("header",{},n("h1",{},"Find your air conditioners")),b(),i.found.length>0?n("ul",{class:"found-list"},...i.found.map(Ae)):null,!i.isBusy&&i.found.length===0?n("p",{class:"empty"},"No adapter answered. A search only reaches adapters on the same network segment as Matterbridge: add the others by address below."):null,n("details",{class:"manual",open:!i.isBusy&&i.found.length===0},n("summary",{},"Can't see your air conditioner?"),n("p",{class:"help"},"Enter the address of its adapter. The plugin reads the name of the adapter there and follows it to a new address like any other, as long as a search can reach it. An adapter on another subnet or VLAN keeps this address."),n("div",{class:"inline-form"},n("label",{for:"host",class:"visually-hidden"},"Adapter address"),t,u("Look it up",o))),n("div",{class:"footer"},u("Search again",()=>{F()}),u("Cancel",k),u(s,()=>U(ne(e)),"primary",e.length===0))]}var V={auto:"auto mode",cool:"cool mode",heat:"heat mode",dehumidify:"dry mode",fan:"fan mode"};function $e(e){let t=e.controls===void 0||e.controls.fanSteps.length>0,o=e.controls===void 0||e.controls.hasSwing,s=e.hasSeparateFan?" on a fan of its own":"",a={native:"",switch:"",firstStep:" with auto first",lastStep:" with auto last"}[e.fanAutoControl],r=e.fanControl==="hidden"?"fan speed not shown":`fan speed as ${e.fanControl==="steps"?"steps":"a percentage"}${a}${s}`,c={both:"",vertical:" up and down",horizontal:" left and right"}[e.swingAxes],d={native:`swing as native rocking${c}`,switches:`swing as switches${c}`,select:"swing as a mode select",hidden:"swing not shown"}[e.swingControl],l=[t?r:"",o?d:""].filter(w=>w!=="").join(", "),p=e.modeControl==="switches"?e.modeSwitches.map(w=>V[w]):[],g=Object.keys(V).flatMap(w=>{let q=e.modeReplacements[w];return q===void 0?[]:[`${V[w]} as ${V[q].replace(" mode","")}`]}),m=[...p,e.fanAutoControl==="switch"?"auto fan":"",...e.specialModeSwitches].filter(w=>w!==""),x=[m.length===0?"":`a switch for ${m.join(", ")}`,e.modeControl==="select"?"a mode select":"",g.join(" and ")].filter(w=>w!=="").join(" and "),T=e.isComposed?", all as one device":"";return l===""?`${x===""?"power, mode and temperature":x}${T}`:`${x===""?l:`${l}, and ${x}`}${T}`}function Te(e){let t={online:"Online",offline:"Not answering",stopped:"Not started"}[e.status],o=i.confirmingRemoval===e.macAddress;return n("li",{class:"device"},n("div",{class:"device-main"},n("h3",{},e.name),n("p",{class:"meta"},n("span",{class:`status ${e.status}`},t),` at ${e.host}. In Matter: ${$e(e)}.`),e.status!=="online"&&e.error?n("p",{class:"meta problem-text"},e.error):null,e.needsRestart?n("p",{class:"meta"},n("strong",{},"Restart Matterbridge")," to apply the new options in Matter. Until then it keeps its current controls."):null),o?n("div",{class:"actions"},n("span",{class:"meta"},"Remove it from Matter too?"),u("Remove",()=>{pe(e)},"danger"),u("Keep",()=>{i.confirmingRemoval="",h()})):n("div",{class:"actions"},u(e.status==="online"?"Options":"Reconnect",()=>U([oe(e)])),u("Remove",()=>{i.confirmingRemoval=e.macAddress,h()})))}function me(){let e=i.setup?.devices??[];return[n("header",{},n("h1",{},"Daikin air conditioners"),i.setup?u("Add air conditioners",()=>{F()},"primary"):null),b(),e.length===0&&i.setup?n("p",{class:"empty"},"No air conditioner is set up yet. Add one to control it from Matter."):n("ul",{class:"devices"},...e.map(Te)),i.setup?null:u("Try again",()=>{B()},"primary")]}var Y={auto:"Auto",silent:"Silent",level1:"Level 1",level2:"Level 2",level3:"Level 3",level4:"Level 4",level5:"Level 5"},ee={off:"No swing",vertical:"Up and down",horizontal:"Left and right",both:"3D swing"},H={auto:"Auto",cool:"Cool",heat:"Heat",dehumidify:"Dry",fan:"Fan"},we={powerful:{title:"Powerful",text:"Runs the unit at full power for a while."},econo:{title:"Econo",text:"Limits how much power the unit draws."},streamer:{title:"Streamer",text:"Runs the air purifying of the unit."},heatPlus:{title:"Heat Plus",text:"The Heat Plus mode of the unit, which it takes in heat alone."}},A={steps:'<svg viewBox="0 0 48 28" aria-hidden="true"><rect x="2" y="20" width="8" height="6"/><rect x="14" y="14" width="8" height="12"/><rect x="26" y="8" width="8" height="18"/><rect x="38" y="2" width="8" height="24"/></svg>',percent:'<svg viewBox="0 0 48 28" aria-hidden="true"><path d="M2 26 L46 2 L46 26 Z"/></svg>',hidden:'<svg viewBox="0 0 48 28" aria-hidden="true"><path class="stroke" d="M6 14 H42" stroke-dasharray="3 5"/></svg>',switches:'<svg viewBox="0 0 48 28" aria-hidden="true"><path class="stroke" d="M12 4 V24 M7 9 L12 4 L17 9 M7 19 L12 24 L17 19"/><path class="stroke" d="M26 14 H46 M31 9 L26 14 L31 19 M41 9 L46 14 L41 19"/></svg>',select:'<svg viewBox="0 0 48 28" aria-hidden="true"><rect class="stroke" x="3" y="5" width="42" height="18" rx="4"/><path class="stroke" d="M31 12 L35 16 L39 12"/></svg>',rocking:'<svg viewBox="0 0 48 28" aria-hidden="true"><path class="stroke" d="M8 20 Q24 0 40 20"/><path class="stroke" d="M8 13 V20 H15 M40 13 V20 H33"/></svg>'},ge="Few apps show a mode select: Home Assistant does, Apple Home does not.";function j(e,t,o){return e.isComposed?o?`It appears as a part of "${e.name}", tagged "${t}"`:`It appears as a part of "${e.name}"`:`It appears as "${e.name} ${t}"`}function f(e,t){Object.assign(e,t),h()}function $(e,t,o,s,a,r,c){let d=`${e}-${t}`,l=n("input",{type:"radio",name:e,id:d,checked:t===o,onchange:()=>c(t)});return n("label",{class:"choice pictured",for:d},l,n("span",{class:"glyph",html:r}),n("span",{},n("strong",{},s),n("span",{class:"meta"},a)))}function y(e,t,o,s,a,r){let c=`${e}-${t}`,d=n("input",{type:"radio",name:e,id:c,checked:t===o,onchange:()=>r(t)});return n("label",{class:"choice",for:c},d,n("span",{},n("strong",{},s),n("span",{class:"meta"},a)))}function O(e,t,o,s,a){let r=n("input",{type:"checkbox",id:e,checked:t,onchange:()=>a(r.checked)});return n("label",{class:"choice",for:e},r,n("span",{},n("strong",{},o),n("span",{class:"meta"},s)))}function Re(e,t,o,s,a,r){return n("div",{class:"chips",role:"group","aria-label":t},...o.map(c=>{let d=`${e}-${c}`,l=n("input",{type:"checkbox",id:d,checked:s.includes(c),onchange:()=>r(o.filter(p=>p===c?l.checked:s.includes(p)))});return n("label",{class:"chip",for:d},l,a[c])}))}function Ee(e){let t=e.adapter.name,o=`at ${e.adapter.host}`;return t===void 0||t===""?`the air conditioner ${o}`:`the air conditioner named "${t}" in its Daikin app, ${o}`}function He(e){let t=n("input",{type:"text",id:"device-name",value:e.name,maxLength:32,autocomplete:"off",spellcheck:!1});t.addEventListener("input",a=>{e.name=t.value.trim(),a.isComposing||h()});let o=e.adapter.name,s=o===void 0||o===""?"Its adapter has no name of its own.":`Its adapter is named "${o}" in its Daikin app, which other adapters can share.`;return n("section",{},n("h2",{},n("label",{for:"device-name"},"Name in Matter")),n("p",{class:"help"},`${s} The name here is what your Matter apps show, up to 32 characters, and no two air conditioners of this plugin share one. A new name of the adapter does not change it.`),n("div",{class:"inline-form"},t))}function De(e,t){return n("section",{class:"presets"},n("h2",{},"Start from a preset"),n("div",{class:"preset-list"},...Object.keys(I).map(o=>n("button",{type:"button",class:"preset","aria-pressed":String(ie(e,o,t)),onclick:()=>f(e,L(o,t))},n("strong",{},I[o].title),n("span",{class:"meta"},I[o].text)))),n("p",{class:"help"},"A preset fills in the choices below for what this unit can do. Change any of them afterwards."))}function Le(e){let t=e.map(o=>Y[o]);return t.length===1?t[0]:`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function Ne(e,t,o){if(!t.hasFanAuto||e.fanControl==="hidden"&&e.fanSpeedWhenHidden!=="keep")return null;let s=p=>f(e,{fanAutoControl:p}),a=e.fanControl==="hidden",r=`${j(e,"Auto Fan",!0)}. On sets the fan to auto, off puts it back at the speed it last ran at.`,c=Y[t.fanSteps[0]],d=Y[t.fanSteps[t.fanSteps.length-1]],l=a?[y("fan-auto","native",o,"Not shown in Matter","Without a fan speed in Matter, auto has no place there either.",s),y("fan-auto","switch",o,"A switch",r,s)]:[y("fan-auto","native",o,"Native fan mode only","Auto is a mode of the fan speed, beside its speeds, as Matter has it.",s),y("fan-auto","switch",o,"A switch",`${r} Auto stays a fan mode as well.`,s),y("fan-auto","firstStep",o,"The first step",`Auto comes below ${c}: step 1, or the bottom of the slider.`,s),y("fan-auto","lastStep",o,"The last step",`Auto comes above ${d}: the top step, or 100 %.`,s)];return n("div",{class:"field"},n("h3",{id:"fan-auto-title"},"Auto fan speed"),a?null:n("p",{class:"help"},"Matter has auto as a fan mode, which not every app shows. A switch makes it reachable there too, and a step takes its place."),n("div",{class:"choices",role:"radiogroup","aria-labelledby":"fan-auto-title"},...l))}function Fe(e,t){let o=e.capabilities?.fanSpeeds??[];if(t.fanSteps.length===0)return n("section",{},n("h2",{},"Fan speed"),n("p",{class:"help"},"This unit does not let apps set its fan speed, so there is nothing to choose."));let a=e.fanControl==="hidden",r=t.hasFanAuto&&!a&&(e.fanAutoControl==="firstStep"||e.fanAutoControl==="lastStep"),c=t.hasFanAuto&&e.fanAutoControl==="switch",d=t.fanSteps;r&&(d=e.fanAutoControl==="firstStep"?["auto",...t.fanSteps]:[...t.fanSteps,"auto"]);let p=t.hasFanAuto&&!r?" Auto is not among them: it is a fan mode of its own.":"",g=`${d.length} ${d.length===1?"speed":"speeds"}, ${r?"in order":"slowest first"}: ${Le(d)}.${p}`;return n("section",{},n("h2",{},"Fan speed"),n("div",{class:"choices"},$("fan","steps",e.fanControl,"Steps",g,A.steps,m=>f(e,{fanControl:m})),$("fan","percent",e.fanControl,"Percentage",`A slider from 0 to 100, which the plugin rounds to the nearest of ${g}`,A.percent,m=>f(e,{fanControl:m})),$("fan","hidden",e.fanControl,"Not shown in Matter","No fan control. Pick below what the plugin does with the fan speed instead.",A.hidden,m=>f(e,{fanControl:m}))),e.fanControl==="hidden"?n("div",{class:"field"},n("label",{for:"fan-fixed"},"When the plugin sends a command, the fan speed"),n("select",{id:"fan-fixed",onchange:m=>f(e,{fanSpeedWhenHidden:m.target.value})},n("option",{value:"keep",selected:e.fanSpeedWhenHidden==="keep"},"stays as it is"),...o.map(m=>n("option",{value:m,selected:e.fanSpeedWhenHidden===m},`is set to ${Y[m]}`)))):null,e.fanControl==="hidden"?null:O("separate-fan",e.hasSeparateFan,"Show the fan as a device of its own",`${j(e,"Fan",!1)}, and the air conditioner has no fan speed of its own. For apps that show no fan speed on an air conditioner, or do not show it well. It always shows the speed the unit holds, also while the unit is off.`,m=>f(e,{hasSeparateFan:m})),Ne(e,t,a&&!c?"native":e.fanAutoControl))}function Pe(e,t){let{swingModes:o}=t;if(o.length===0)return n("section",{},n("h2",{},"Swing"),n("p",{class:"help"},"This unit does not let apps move its louvers, so there is nothing to choose."));let s=o.includes("vertical"),a=o.includes("horizontal"),r=e.fanControl!=="hidden"&&t.fanSteps.length>0,c=e.swingControl==="native"&&!r?"switches":e.swingControl,d=r?" The fan control then has no rocking.":"",l="One switch, for the up and down swing.";return s&&a?l="Two switches: one for the up and down swing, one for left and right.":a&&(l="One switch, for the left and right swing."),n("section",{},n("h2",{},"Swing"),n("div",{class:"choices"},r?$("swing","native",c,"Native rocking","The rocking of the fan control, as Matter has it: up and down for the vertical swing, left and right for the horizontal. Not every app shows it, and Apple Home shows it as a single Oscillate on/off.",A.rocking,p=>f(e,{swingControl:p})):null,$("swing","switches",c,"Switches",`${l}${d}`,A.switches,p=>f(e,{swingControl:p})),$("swing","select",c,"A mode select",`${j(e,"Swing",!0)}, and picks one of: ${o.map(p=>p==="both"?ee[p]:ee[p].toLowerCase()).join(", ")}.${d} ${ge}`,A.select,p=>f(e,{swingControl:p})),$("swing","hidden",c,"Not shown in Matter","No swing control. Pick below what the plugin does with the swing instead.",A.hidden,p=>f(e,{swingControl:p}))),c==="native"&&t.swingsOnBothAxes||c==="switches"&&s&&a?Oe(e,c==="native"):null,e.swingControl==="hidden"?n("div",{class:"field"},n("label",{for:"swing-fixed"},"When the plugin sends a command, the swing"),n("select",{id:"swing-fixed",onchange:p=>f(e,{swingModeWhenHidden:p.target.value})},n("option",{value:"keep",selected:e.swingModeWhenHidden==="keep"},"stays as it is"),...o.map(p=>n("option",{value:p,selected:e.swingModeWhenHidden===p},`is set to: ${ee[p]}`)))):null)}function Oe(e,t){let o=r=>f(e,{swingAxes:r}),s="The other axis has no control in Matter, and stays as it is.",a=t?"Some apps, such as Apple Home, show the rocking as a single Oscillate on/off. One axis alone makes that switch swing the louvers on it.":"One switch alone, for the axis picked, instead of a switch for each axis.";return n("div",{class:"field"},n("h3",{id:"swing-axes-title"},t?"Rocking axes":"Switch axes"),n("p",{class:"help"},a),n("div",{class:"choices",role:"radiogroup","aria-labelledby":"swing-axes-title"},y("swing-axes","both",e.swingAxes,"Both axes",t?"Up and down, and left and right, each rocking on its own.":"A switch for up and down, and one for left and right.",o),y("swing-axes","vertical",e.swingAxes,"Up and down alone",s,o),y("swing-axes","horizontal",e.swingAxes,"Left and right alone",s,o)))}function je(e,t){let o=D(e.modeReplacements,t);return n("div",{class:"replacements"},...t.lackingModes.flatMap(s=>{let a=`mode-replacement-${s}`,r=t.switchableModes.find(l=>o[l]===s),c=Object.fromEntries(Object.entries(o).filter(([,l])=>l!==s)),d=l=>{let p=l.target.value,g={...c};p!==""&&(g[p]=s),f(e,{modeReplacements:D(g,t)})};return[n("label",{for:a},H[s]),n("select",{id:a,onchange:d},n("option",{value:"",selected:r===void 0},"is not offered"),...t.switchableModes.map(l=>n("option",{value:l,selected:r===l,disabled:c[l]!==void 0||!J(l,s,c,t)},`runs ${H[l].toLowerCase()}`)))]}))}function qe(e,t){let{switchableModes:o,lackingModes:s}=t;if(o.length===0)return null;let a=o.filter(v=>e.modeSwitches.includes(v)),r=o.filter(v=>v==="dehumidify"||v==="fan"),c=r.length>0,d=e.modeControl==="select"&&!c?"native":e.modeControl,l=v=>{v==="switches"&&a.length===0?f(e,{modeControl:v,modeSwitches:c?r:[...o]}):f(e,{modeControl:v})},p=o.includes("cool")?"cool":"heat",g=r.map(v=>H[v].toLowerCase()).join(" and "),m=c?`Off turns the unit off, or from ${g} puts it back in ${p}.`:"Off turns the unit off.",x=`${H[a.length>0?a[0]:o[0]]} Mode`,T=e.isComposed?`Each appears as a part of "${e.name}", tagged with its mode, such as "${x}".`:`Each appears as "${e.name} ${x}", and so on.`,w=s.map(v=>H[v].toLowerCase()),q=w.length===1?w[0]:`${w.slice(0,-1).join(", ")} or ${w[w.length-1]}`;return n("section",{},n("h2",{},"Modes"),n("p",{class:"help"},"Every mode of the unit is a mode of the air conditioner in Matter, but some apps, such as Apple Home and Google Home, only offer off, cool, heat and auto."),n("div",{class:"choices",role:"radiogroup","aria-label":"Modes"},y("mode-control","native",d,"Native modes only","The modes of the unit are those of the air conditioner, as Matter has them, and nothing more is added.",l),c?y("mode-control","select",d,"A mode select",`${j(e,"Mode",!0)}, with Off and every mode of the unit, as the air conditioner has them. Picking a mode turns the unit on in it. ${ge}`,l):null,y("mode-control","switches",d,"Switches",`A switch for each mode picked below. On turns the unit on in that mode. ${m}`,l),d==="switches"?n("div",{class:"sub"},Re("mode-switch","Modes that get a switch",o,a,H,v=>f(e,{modeSwitches:v})),n("p",{class:"help"},T)):null),s.length>0?n("div",{class:"field"},n("h3",{},"Modes the unit lacks"),n("p",{class:"help"},`This unit has no ${q}. Each can run one of its modes instead, such as heat running dry on a unit that only cools: an app then reaches that mode from the modes it offers, and nothing is added to Matter. The air conditioner shows the mode picked while the unit is in it, with its setpoint. Auto is offered once the air conditioner both cools and heats, counting these.`),je(e,t)):null)}function Ie(e,t){return t.specialModes.length===0?null:n("section",{},n("h2",{},"Special modes"),n("p",{class:"help"},"Matter has no control for these, so each can get a switch of its own. A switch only takes effect in the modes this unit offers that special mode in."),n("div",{class:"choices"},...t.specialModes.map(o=>O(`special-${o}`,e.specialModeSwitches.includes(o),`Add a switch for ${we[o].title}`,we[o].text,s=>f(e,{specialModeSwitches:t.specialModes.filter(a=>a===o?s:e.specialModeSwitches.includes(a))})))))}function Be(e){return n("section",{},n("h2",{},"Humidity and outdoor temperature"),n("p",{class:"help"},"No adapter says which readings its unit has, so each of these takes effect once the unit gives that reading. The room temperature and the humidity are always on the air conditioner."),n("div",{class:"choices"},O("separate-humidity",e.hasSeparateHumiditySensor,"Also show the humidity on a sensor of its own",`${j(e,"Humidity",!1)}, and the air conditioner keeps its humidity. For apps that show no humidity on an air conditioner, which Apple Home is reported to be.`,t=>f(e,{hasSeparateHumiditySensor:t})),O("outdoor-sensor",e.hasOutdoorTemperatureSensor,"Add a sensor for the outdoor temperature",`It appears as "${e.name} Outdoor Temperature". It is a device of its own, which you can put in another room, such as outside. Until you do, a Matter app may show the outdoor temperature as that of the room it put the sensor in. Some units give no outdoor temperature while they are idle: the sensor then shows no value.`,t=>f(e,{hasOutdoorTemperatureSensor:t}))))}function We(e){return n("section",{},n("h2",{},"One device or several"),n("p",{class:"help"},"The switches, a fan of its own and a humidity sensor of its own can be parts of the air conditioner in Matter, or devices of their own beside it. The outdoor temperature sensor is always a device of its own, so that you can put it in another room than the air conditioner."),n("div",{class:"choices"},O("composed",e.isComposed,"Make them parts of the air conditioner",`Your Matter app has one device, "${e.name}", and they move between rooms with it. A part has no name of its own in Matter, so an app may show the switches as numbered outlets, and an app that shows no parts shows the air conditioner alone. Turned off, each is a device of its own with its own name, which your app puts in a room by itself.`,t=>f(e,{isComposed:t}))))}function ve(){let e=S();if(e===void 0)return[b()];let t=e.controls??se;return[E(),K(),z(e,`Options for ${Ee(e)}. Power, mode and temperature always appear in Matter: choose how the rest appears.`),He(e),De(e,t),Fe(e,t),Pe(e,t),qe(e,t),Ie(e,t),Be(e),We(e),e.isNew?null:n("p",{class:"help"},"A change of any of these applies at the next restart of Matterbridge. A switch or a sensor you add is new in your Matter app, in its default room, and one you remove is gone."),b(),n("div",{class:"footer"},u("Cancel",k),u(e.isNew?`Add ${e.name}`:"Save options",()=>{le(e)},"primary"))]}function ye(){try{if(window.parent===window)return;let e=getComputedStyle(window.parent.document.body);for(let t of["--primary-color","--div-bg-color","--div-text-color","--main-bg-color","--main-label-color","--div-border-color","--main-light-color"]){let o=e.getPropertyValue(t).trim();o!==""&&document.documentElement.style.setProperty(`--host${t.slice(1)}`,o)}document.documentElement.style.setProperty("--host-font",e.fontFamily)}catch{}}ae({loading:()=>[n("p",{class:"notice working",role:"status"},n("span",{class:"spinner"}),"Loading\u2026")],home:me,find:fe,connect:he,options:ve,done:ue});ye();h();B();
|
|
1
|
+
async function M(e,t){try{let[o,s]=e.split(" "),a={method:o};t!==void 0&&(a.headers={"Content-Type":"application/json"},a.body=JSON.stringify(t));let r=await fetch(new URL(`api/${s}`,document.baseURI),a);if(r.status===503)return{ok:!1,error:"The plugin is not running. Start it in Matterbridge, then reload this page."};let c=await r.json();return"ok"in c?c:{ok:!1,error:c.error??`The plugin answered with status ${r.status}`}}catch{return{ok:!1,error:"Matterbridge did not answer. Check that it is running, then try again."}}}var i={screen:"loading",setup:void 0,found:[],selected:new Set,queue:[],saved:[],handled:[],isBusy:!1,busyText:"",error:"",info:"",confirmingRemoval:""};function S(){return i.queue[0]}function C(e){return e.name===""?e.adapter.host:e.name}function G(e){return(i.setup?.devices??[]).some(t=>t.macAddress===e.macAddress)}function R(e){let{fanControl:t,fanSpeedWhenHidden:o,swingControl:s,swingAxes:a,swingModeWhenHidden:r,modeControl:c,modeSwitches:d,modeReplacements:l,fanAutoControl:p,hasSeparateFan:g,specialModeSwitches:m,hasOutdoorTemperatureSensor:x,hasSeparateHumiditySensor:T,isComposed:w}=e;return{fanControl:t,fanSpeedWhenHidden:o,swingControl:s,swingAxes:a,swingModeWhenHidden:r,modeControl:c,modeSwitches:[...d],modeReplacements:{...l},fanAutoControl:p,hasSeparateFan:g,specialModeSwitches:[...m],hasOutdoorTemperatureSensor:x,hasSeparateHumiditySensor:T,isComposed:w}}var Se={fanControl:"steps",fanSpeedWhenHidden:"keep",swingControl:"switches",swingAxes:"both",swingModeWhenHidden:"keep",modeControl:"native",modeSwitches:[],modeReplacements:{},fanAutoControl:"native",hasSeparateFan:!1,specialModeSwitches:[],hasOutdoorTemperatureSensor:!1,hasSeparateHumiditySensor:!1,isComposed:!0},be=32;function Q(e,t){if(e===""||!t.has(e))return e;for(let o=2;;o++){let s=` ${o}`,a=`${e.slice(0,be-s.length).trimEnd()}${s}`;if(!t.has(a))return a}}function te(e){let t=(i.setup?.devices??[]).filter(s=>s.macAddress!==e.adapter.macAddress).map(s=>s.name),o=i.queue.filter(s=>s!==e).map(s=>s.name);return new Set([...t,...o].filter(s=>s!==""))}function ne(e){let t=new Set((i.setup?.devices??[]).map(o=>o.name));return e.map(o=>{let s=Q(o.name??"",t);return s!==""&&t.add(s),{adapter:o,name:s,isNew:!0,...R(Se)}})}function oe(e){let{capabilities:t,controls:o,name:s,macAddress:a,host:r,protocol:c,requiresRegistration:d,usesHttps:l,requiresLocalPassword:p}=e;return{adapter:{host:r,protocol:c,macAddress:a,requiresRegistration:d,usesHttps:l,requiresLocalPassword:p},name:s,isNew:!1,capabilities:t,controls:o,...R(e)}}var se={fanSteps:[],hasFanAuto:!1,hasSwing:!1,swingModes:[],swingsOnBothAxes:!1,switchableModes:[],lackingModes:[],specialModes:[]};function J(e,t,o,s){if(!s.switchableModes.includes(e)||!s.lackingModes.includes(t))return!1;let a=s.switchableModes.filter(c=>c!==e).map(c=>o[c]);if(a.includes(t))return!1;if(t!=="auto")return!0;let r=new Set([...s.switchableModes,...a]);return r.has("cool")&&r.has("heat")}function D(e,t){let o={};for(let s of t.switchableModes){let a=e[s];a!==void 0&&J(s,a,e,t)&&(o[s]=a)}return o}var I={apple:{title:"Apple Home",text:"Fan speed as a percentage, the swing as the rocking of the fan on one axis, the humidity on a sensor of its own too, and a switch for auto fan and for each of dry and fan, each a device of its own."},google:{title:"Google Home",text:"Fan speed as steps, the swing as the rocking of the fan on one axis, the humidity on a sensor of its own too, and a switch for auto fan and for each of dry and fan, each a device of its own."},matter:{title:"Full Matter support",text:"For apps that show every Matter control: fan speed as steps with its auto mode, the swing as the rocking of the fan, a switch for each special mode and the outdoor temperature, all as one device."}};function L(e,t){let o=e==="matter",s=t.hasSwing&&(o||t.fanSteps.length>0),a=s?"native":"hidden",r=o?[]:t.switchableModes.filter(c=>c==="dehumidify"||c==="fan");return{fanControl:t.fanSteps.length===0?"hidden":e==="apple"?"percent":"steps",fanSpeedWhenHidden:"keep",swingControl:a,swingAxes:!o&&s&&t.swingsOnBothAxes?"horizontal":"both",swingModeWhenHidden:"keep",modeControl:r.length>0?"switches":"native",modeSwitches:r,modeReplacements:{},fanAutoControl:!o&&t.hasFanAuto?"switch":"native",hasSeparateFan:!1,specialModeSwitches:o?[...t.specialModes]:[],hasOutdoorTemperatureSensor:o,hasSeparateHumiditySensor:!o,isComposed:o}}function ie(e,t,o){let s=R(e);o.fanSteps.length===0&&Object.assign(s,{fanControl:"hidden",fanSpeedWhenHidden:"keep"}),s.fanControl==="hidden"&&(s.hasSeparateFan=!1);let a=s.fanAutoControl==="firstStep"||s.fanAutoControl==="lastStep",r=s.fanControl==="hidden"&&s.fanSpeedWhenHidden!=="keep";return(!o.hasFanAuto||a&&s.fanControl==="hidden"||r)&&(s.fanAutoControl="native"),o.hasSwing||Object.assign(s,{swingControl:"hidden",swingModeWhenHidden:"keep"}),s.fanControl==="hidden"&&s.swingControl==="switches"&&(s.swingControl="native"),(s.swingControl!=="native"&&s.swingControl!=="switches"||!o.swingsOnBothAxes)&&(s.swingAxes="both"),s.modeSwitches=s.modeControl==="switches"?o.switchableModes.filter(d=>s.modeSwitches.includes(d)):[],s.modeReplacements=D(s.modeReplacements,o),{native:!0,select:o.switchableModes.includes("dehumidify")||o.switchableModes.includes("fan"),switches:s.modeSwitches.length>0}[s.modeControl]||(s.modeControl="native"),s.specialModeSwitches=o.specialModes.filter(d=>s.specialModeSwitches.includes(d)),JSON.stringify(s)===JSON.stringify(L(t,o))}var Z;function ae(e){Z=e}function h(){let e=document.getElementById("app");if(e===null||Z===void 0)return;let t=`${i.screen}:${S()?.adapter.host??""}`,o=e.dataset.form===t,s=document.activeElement,a=s instanceof HTMLElement?s.id:"",r=s instanceof HTMLInputElement&&(s.type==="text"||s.type==="password")?{start:s.selectionStart,end:s.selectionEnd}:void 0,c=new Map;for(let l of e.querySelectorAll("input[type=text], input[type=password]"))l.id!==""&&c.set(l.id,l.value);if(e.replaceChildren(...Z[i.screen]().filter(l=>l!==!1&&l!==null&&l!==void 0)),e.dataset.form=t,!o)return;for(let[l,p]of c){let g=document.getElementById(l);g instanceof HTMLInputElement&&(g.value=p)}if(a==="")return;let d=document.getElementById(a);d?.focus(),r!==void 0&&d instanceof HTMLInputElement&&d.setSelectionRange(r.start,r.end)}async function N(e,t){i.isBusy=!0,i.busyText=e,i.error="",i.info="",h();try{return await t()}finally{i.isBusy=!1,h()}}async function B(){let e=await M("GET state");if(!e.ok){i.error=e.error,i.screen="home",h();return}if(i.setup=e.state,e.state.devices.length===0){await F();return}i.screen="home",h()}async function W(){let e=await M("GET state");e.ok&&(i.setup=e.state)}function k(){i.queue=[],i.saved=[],i.handled=[],i.error="",i.info="",i.screen="home",W().then(h),h()}async function F(){i.screen="find";let e=await N("Searching your network. This takes about three seconds\u2026",async()=>M("POST discover"));if(!e.ok){i.error=`The search did not run: ${e.error}`,h();return}await W();let t=i.found.filter(o=>!e.devices.some(s=>s.host===o.host)&&i.selected.has(o.host)).map(o=>({...o,isConfigured:G(o)}));i.found=[...e.devices,...t];for(let o of e.devices)o.isConfigured||i.selected.add(o.host);h()}async function re(e){let t=await N(`Looking for an adapter at ${e}\u2026`,async()=>M("POST identify",{host:e}));if(!t.ok){i.error=t.error,h();return}let o=G(t.device),s=t.device.requiresRegistration===!0;i.found=[...i.found.filter(a=>a.host!==t.device.host),{...t.device,isConfigured:o,needsRegistration:s}],o||i.selected.add(t.device.host),h()}function U(e){i.queue=e,i.saved=[],i.handled=[],X()}async function X(){let e=S();if(e===void 0){i.screen=i.saved.length>0?"done":"home",await W(),h();return}i.screen="connect",i.error="",i.info="",e.probe=void 0,h(),await P(e)}async function P(e,t){let o={device:e.adapter,localPassword:e.localPassword,key:t},s=t===void 0?`Checking ${C(e)}\u2026`:`Registering with ${C(e)}\u2026`,a=await N(s,async()=>M(t===void 0?"POST probe":"POST register",o));if(!a.ok){i.error=a.error,h();return}if(e.probe=a.result,e.adapter=a.result.device,a.result.status==="ready"){let r=e.controls===void 0;e.capabilities=a.result.capabilities,e.controls=a.result.controls,e.isNew&&r&&e.controls!==void 0&&Object.assign(e,L("apple",e.controls));let c=a.result.device.name??"";e.name===""&&c!==""&&(e.name=Q(c,te(e))),i.screen="options"}h()}function ce(){let e=i.queue.shift();e!==void 0&&i.handled.push({label:C(e),isSaved:!1}),X()}async function le(e){let t=e.name.trim(),o=xe(e,t);if(o!==""){i.error=o,h();return}let{adapter:s,localPassword:a}=e,r={...s,name:t,localPassword:a,...R(e)},c=await N(`Saving ${t}\u2026`,async()=>M("POST device",{device:r}));if(!c.ok){i.error=c.error,h();return}i.setup=c.state,i.saved.push(t),i.handled.push({label:t,isSaved:!0}),i.queue.shift(),await X()}function xe(e,t){return t===""?"Give the air conditioner a name: it is the name it gets in Matter.":(i.setup?.devices??[]).some(s=>s.name===t&&s.macAddress!==e.adapter.macAddress)?`"${t}" is already the name of another air conditioner. Pick a different one.`:""}var _="Matterbridge's own list of devices shows the change once you reload its page.",de="Restart Matterbridge to apply the new options in Matter: until then the air conditioner keeps its current controls.";async function pe(e){let t=await N(`Removing ${e.name}\u2026`,async()=>M("POST remove-device",{macAddress:e.macAddress}));i.confirmingRemoval="",t.ok?i.info=`${e.name} is removed. ${_}`:i.error=t.error,await W(),h()}function n(e,t={},...o){let s=document.createElement(e);for(let[a,r]of Object.entries(t))r===void 0||r===!1||(a==="class"?s.className=String(r):a==="html"?s.innerHTML=String(r):a.startsWith("on")&&typeof r=="function"?s.addEventListener(a.slice(2),r):a in s?s[a]=r:s.setAttribute(a,String(r)));for(let a of o)a!==!1&&a!==null&&a!==void 0&&s.append(a);return s}function u(e,t,o="quiet",s=!1){return n("button",{type:"button",class:`button ${o}`,onclick:t,disabled:s||i.isBusy},e)}function b(){return i.isBusy?n("p",{class:"notice working",role:"status"},n("span",{class:"spinner"}),i.busyText):i.error!==""?n("p",{class:"notice problem",role:"alert"},i.error):i.info!==""?n("p",{class:"notice",role:"status"},i.info):null}function K(){let e=S();if(e===void 0||!e.isNew||i.handled.length+i.queue.length<2)return null;let t=i.screen==="connect"?"Connecting":"Choosing options";return n("ol",{class:"units","aria-label":"Air conditioners in this setup"},...i.handled.map(o=>n("li",{class:o.isSaved?"done":"skipped"},n("strong",{},o.label),n("span",{class:"meta"},o.isSaved?"Added":"Skipped"))),...i.queue.map((o,s)=>n("li",{class:s===0?"current":"ahead","aria-current":s===0?"true":void 0},n("strong",{},C(o)),n("span",{class:"meta"},s===0?t:"Waiting"))))}function z(e,t){return n("header",{class:"unit-header"},n("h1",{},C(e)),n("p",{class:"meta"},t))}function E(){if(i.queue.length>0&&!i.queue.some(s=>s.isNew))return null;let e=["Find","Connect","Options"],o=["find","connect","options"].indexOf(i.screen);return n("ol",{class:"steps"},...e.map((s,a)=>{let r="ahead";return a<o?r="done":a===o&&(r="current"),n("li",{class:r,"aria-current":a===o?"step":void 0},s)}))}function Me(e,t){let o=n("input",{type:"password",id:"lock-code",inputMode:"numeric",autocomplete:"off",maxLength:64});return n("div",{class:"field"},n("label",{for:"lock-code"},"Child lock code"),n("p",{class:"help"},"The 4-digit code set under Child lock in the Daikin app the adapter was set up with. It is not printed on the adapter."),t?n("p",{class:"problem-text"},"The adapter did not accept that code."):null,n("div",{class:"inline-form"},o,u("Check the code",()=>{o.value!==""&&(e.localPassword=o.value,P(e))},"primary")))}function ke(e,t){let o=n("input",{type:"text",id:"adapter-key",autocomplete:"off",spellcheck:!1,maxLength:64});return n("div",{class:"field"},n("label",{for:"adapter-key"},"KEY on the adapter"),n("p",{class:"help"},"This adapter only answers apps it has registered. The KEY is printed on its label, next to the SSID, and in the operation manual. It is used once and not stored."),t?n("p",{class:"problem-text"},"The adapter did not accept that KEY."):null,n("div",{class:"inline-form"},o,u("Register",()=>{o.value.trim()!==""&&P(e,o.value.trim())},"primary")))}function Ce(e){let t=e.probe?.status;return t==="localPasswordRequired"||t==="localPasswordRejected"?Me(e,t==="localPasswordRejected"):t==="registrationRequired"||t==="registrationRejected"?ke(e,t==="registrationRejected"):t==="unreachable"?n("p",{class:"notice problem",role:"alert"},`${e.name} did not answer at ${e.adapter.host}. Check that it has power and is on the network, then try again.`):t==="failed"?n("p",{class:"notice problem",role:"alert"},`${e.name} answered with an error: ${e.probe?.message??"unknown"}`):null}function he(){let e=S();if(e===void 0)return[b()];let t=e.probe?.status==="unreachable"||e.probe?.status==="failed"||i.error!=="";return[E(),K(),z(e,`Connecting to its adapter at ${e.adapter.host}.`),b(),i.isBusy?null:Ce(e),n("div",{class:"footer"},t?u("Try again",()=>{P(e)}):null,u(e.isNew&&i.queue.length>1?"Skip this one":"Cancel",e.isNew&&i.queue.length>1?ce:k))]}function ue(){let e=i.saved,t=(i.setup?.devices??[]).some(o=>e.includes(o.name)&&o.needsRestart);return[n("header",{},n("h1",{},e.length===1?`${e[0]} is set up`:`${e.length} air conditioners are set up`)),n("p",{class:"lead"},"They now appear in the Matter apps paired with Matterbridge. If Matterbridge is not paired yet, pair it from its home page."),t?n("p",{class:"help"},n("strong",{},de)):null,n("p",{class:"help"},_),n("div",{class:"footer"},u("Done",k,"primary"))]}function Ae(e){let t=!e.isConfigured,o=[];e.isConfigured&&o.push("Already set up."),e.name===void 0&&o.push("It has not told its name yet: you will name it in its options."),t&&e.needsRegistration?o.push("Asks for the KEY printed on its label."):t&&e.requiresRegistration&&o.push("Already registered with this plugin, so it will not ask for its KEY."),t&&e.requiresLocalPassword&&o.push("Asks for its child lock code.");let s=n("input",{type:"checkbox",id:`found-${e.host}`,checked:t&&i.selected.has(e.host),disabled:!t,onchange:()=>{s.checked?i.selected.add(e.host):i.selected.delete(e.host),h()}});return n("li",{class:t?"found":"found unavailable"},n("label",{for:`found-${e.host}`},s,n("span",{},n("strong",{},e.name??"Unnamed adapter"),n("span",{class:"meta"},` ${e.host}`),...o.map(a=>n("span",{class:"meta note"},a)))))}function fe(){let e=i.found.filter(a=>i.selected.has(a.host)&&!a.isConfigured),t=n("input",{type:"text",id:"host",placeholder:"192.168.1.50",spellcheck:!1,autocomplete:"off"}),o=()=>{t.value.trim()!==""&&re(t.value.trim())};t.addEventListener("keydown",a=>{a.key==="Enter"&&o()});let s=e.length===1?"Set up 1 air conditioner":`Set up ${e.length} air conditioners`;return[E(),n("header",{},n("h1",{},"Find your air conditioners")),b(),i.found.length>0?n("ul",{class:"found-list"},...i.found.map(Ae)):null,!i.isBusy&&i.found.length===0?n("p",{class:"empty"},"No adapter answered. A search only reaches adapters on the same network segment as Matterbridge: add the others by address below."):null,n("details",{class:"manual",open:!i.isBusy&&i.found.length===0},n("summary",{},"Can't see your air conditioner?"),n("p",{class:"help"},"Enter the address of its adapter. The plugin reads the name of the adapter there and follows it to a new address like any other, as long as a search can reach it. An adapter on another subnet or VLAN keeps this address."),n("div",{class:"inline-form"},n("label",{for:"host",class:"visually-hidden"},"Adapter address"),t,u("Look it up",o))),n("div",{class:"footer"},u("Search again",()=>{F()}),u("Cancel",k),u(s,()=>U(ne(e)),"primary",e.length===0))]}var V={auto:"auto mode",cool:"cool mode",heat:"heat mode",dehumidify:"dry mode",fan:"fan mode"};function $e(e){let t=e.controls===void 0||e.controls.fanSteps.length>0,o=e.controls===void 0||e.controls.hasSwing,s=e.hasSeparateFan?" on a fan of its own":"",a={native:"",switch:"",firstStep:" with auto first",lastStep:" with auto last"}[e.fanAutoControl],r=e.fanControl==="hidden"?"fan speed not shown":`fan speed as ${e.fanControl==="steps"?"steps":"a percentage"}${a}${s}`,c={both:"",vertical:" up and down",horizontal:" left and right"}[e.swingAxes],d={native:`swing as native rocking${c}`,switches:`swing as switches${c}`,select:"swing as a mode select",hidden:"swing not shown"}[e.swingControl],l=[t?r:"",o?d:""].filter(w=>w!=="").join(", "),p=e.modeControl==="switches"?e.modeSwitches.map(w=>V[w]):[],g=Object.keys(V).flatMap(w=>{let q=e.modeReplacements[w];return q===void 0?[]:[`${V[w]} as ${V[q].replace(" mode","")}`]}),m=[...p,e.fanAutoControl==="switch"?"auto fan":"",...e.specialModeSwitches].filter(w=>w!==""),x=[m.length===0?"":`a switch for ${m.join(", ")}`,e.modeControl==="select"?"a mode select":"",g.join(" and ")].filter(w=>w!=="").join(" and "),T=e.isComposed?", all as one device":"";return l===""?`${x===""?"power, mode and temperature":x}${T}`:`${x===""?l:`${l}, and ${x}`}${T}`}function Te(e){let t={online:"Online",offline:"Not answering",stopped:"Not started"}[e.status],o=i.confirmingRemoval===e.macAddress;return n("li",{class:"device"},n("div",{class:"device-main"},n("h3",{},e.name),n("p",{class:"meta"},n("span",{class:`status ${e.status}`},t),` at ${e.host}. In Matter: ${$e(e)}.`),e.status!=="online"&&e.error?n("p",{class:"meta problem-text"},e.error):null,e.needsRestart?n("p",{class:"meta"},n("strong",{},"Restart Matterbridge")," to apply the new options in Matter. Until then it keeps its current controls."):null),o?n("div",{class:"actions"},n("span",{class:"meta"},"Remove it from Matter too?"),u("Remove",()=>{pe(e)},"danger"),u("Keep",()=>{i.confirmingRemoval="",h()})):n("div",{class:"actions"},u(e.status==="online"?"Options":"Reconnect",()=>U([oe(e)])),u("Remove",()=>{i.confirmingRemoval=e.macAddress,h()})))}function me(){let e=i.setup?.devices??[];return[n("header",{},n("h1",{},"Daikin air conditioners"),i.setup?u("Add air conditioners",()=>{F()},"primary"):null),b(),e.length===0&&i.setup?n("p",{class:"empty"},"No air conditioner is set up yet. Add one to control it from Matter."):n("ul",{class:"devices"},...e.map(Te)),i.setup?null:u("Try again",()=>{B()},"primary")]}var Y={auto:"Auto",silent:"Silent",level1:"Level 1",level2:"Level 2",level3:"Level 3",level4:"Level 4",level5:"Level 5"},ee={off:"No swing",vertical:"Up and down",horizontal:"Left and right",both:"3D swing"},H={auto:"Auto",cool:"Cool",heat:"Heat",dehumidify:"Dry",fan:"Fan"},we={powerful:{title:"Powerful",text:"Runs the unit at full power for a while."},econo:{title:"Econo",text:"Limits how much power the unit draws."},streamer:{title:"Streamer",text:"Runs the air purifying of the unit."},heatPlus:{title:"Heat Plus",text:"The Heat Plus mode of the unit, which it takes in heat alone."}},A={steps:'<svg viewBox="0 0 48 28" aria-hidden="true"><rect x="2" y="20" width="8" height="6"/><rect x="14" y="14" width="8" height="12"/><rect x="26" y="8" width="8" height="18"/><rect x="38" y="2" width="8" height="24"/></svg>',percent:'<svg viewBox="0 0 48 28" aria-hidden="true"><path d="M2 26 L46 2 L46 26 Z"/></svg>',hidden:'<svg viewBox="0 0 48 28" aria-hidden="true"><path class="stroke" d="M6 14 H42" stroke-dasharray="3 5"/></svg>',switches:'<svg viewBox="0 0 48 28" aria-hidden="true"><path class="stroke" d="M12 4 V24 M7 9 L12 4 L17 9 M7 19 L12 24 L17 19"/><path class="stroke" d="M26 14 H46 M31 9 L26 14 L31 19 M41 9 L46 14 L41 19"/></svg>',select:'<svg viewBox="0 0 48 28" aria-hidden="true"><rect class="stroke" x="3" y="5" width="42" height="18" rx="4"/><path class="stroke" d="M31 12 L35 16 L39 12"/></svg>',rocking:'<svg viewBox="0 0 48 28" aria-hidden="true"><path class="stroke" d="M8 20 Q24 0 40 20"/><path class="stroke" d="M8 13 V20 H15 M40 13 V20 H33"/></svg>'},ge="Few apps show a mode select: Home Assistant does, Apple Home does not.";function j(e,t,o){return e.isComposed?o?`It appears as a part of "${e.name}", tagged "${t}"`:`It appears as a part of "${e.name}"`:`It appears as "${e.name} ${t}"`}function f(e,t){Object.assign(e,t),h()}function $(e,t,o,s,a,r,c){let d=`${e}-${t}`,l=n("input",{type:"radio",name:e,id:d,checked:t===o,onchange:()=>c(t)});return n("label",{class:"choice pictured",for:d},l,n("span",{class:"glyph",html:r}),n("span",{},n("strong",{},s),n("span",{class:"meta"},a)))}function y(e,t,o,s,a,r){let c=`${e}-${t}`,d=n("input",{type:"radio",name:e,id:c,checked:t===o,onchange:()=>r(t)});return n("label",{class:"choice",for:c},d,n("span",{},n("strong",{},s),n("span",{class:"meta"},a)))}function O(e,t,o,s,a){let r=n("input",{type:"checkbox",id:e,checked:t,onchange:()=>a(r.checked)});return n("label",{class:"choice",for:e},r,n("span",{},n("strong",{},o),n("span",{class:"meta"},s)))}function Re(e,t,o,s,a,r){return n("div",{class:"chips",role:"group","aria-label":t},...o.map(c=>{let d=`${e}-${c}`,l=n("input",{type:"checkbox",id:d,checked:s.includes(c),onchange:()=>r(o.filter(p=>p===c?l.checked:s.includes(p)))});return n("label",{class:"chip",for:d},l,a[c])}))}function Ee(e){let t=e.adapter.name,o=`at ${e.adapter.host}`;return t===void 0||t===""?`the air conditioner ${o}`:`the air conditioner named "${t}" in its Daikin app, ${o}`}function He(e){let t=n("input",{type:"text",id:"device-name",value:e.name,maxLength:32,autocomplete:"off",spellcheck:!1});t.addEventListener("input",a=>{e.name=t.value.trim(),a.isComposing||h()});let o=e.adapter.name,s=o===void 0||o===""?"Its adapter has no name of its own.":`Its adapter is named "${o}" in its Daikin app, which other adapters can share.`;return n("section",{},n("h2",{},n("label",{for:"device-name"},"Name in Matter")),n("p",{class:"help"},`${s} The name here is what your Matter apps show, up to 32 characters, and no two air conditioners of this plugin share one. A new name of the adapter does not change it.`),n("div",{class:"inline-form"},t))}function De(e,t){return n("section",{class:"presets"},n("h2",{},"Start from a preset"),n("div",{class:"preset-list"},...Object.keys(I).map(o=>n("button",{type:"button",class:"preset","aria-pressed":String(ie(e,o,t)),onclick:()=>f(e,L(o,t))},n("strong",{},I[o].title),n("span",{class:"meta"},I[o].text)))),n("p",{class:"help"},"A preset fills in the choices below for what this unit can do. Change any of them afterwards."))}function Le(e){let t=e.map(o=>Y[o]);return t.length===1?t[0]:`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function Ne(e,t,o){if(!t.hasFanAuto||e.fanControl==="hidden"&&e.fanSpeedWhenHidden!=="keep")return null;let s=p=>f(e,{fanAutoControl:p}),a=e.fanControl==="hidden",r=`${j(e,"Auto Fan",!0)}. On sets the fan to auto, off puts it back at the speed it last ran at.`,c=Y[t.fanSteps[0]],d=Y[t.fanSteps[t.fanSteps.length-1]],l=a?[y("fan-auto","native",o,"Not shown in Matter","Without a fan speed in Matter, auto has no place there either.",s),y("fan-auto","switch",o,"A switch",r,s)]:[y("fan-auto","native",o,"Native fan mode only","Auto is a mode of the fan speed, beside its speeds, as Matter has it.",s),y("fan-auto","switch",o,"A switch",`${r} Auto stays a fan mode as well.`,s),y("fan-auto","firstStep",o,"The first step",`Auto comes below ${c}: step 1, or the bottom of the slider.`,s),y("fan-auto","lastStep",o,"The last step",`Auto comes above ${d}: the top step, or 100 %.`,s)];return n("div",{class:"field"},n("h3",{id:"fan-auto-title"},"Auto fan speed"),a?null:n("p",{class:"help"},"Matter has auto as a fan mode, which not every app shows. A switch makes it reachable there too, and a step takes its place."),n("div",{class:"choices",role:"radiogroup","aria-labelledby":"fan-auto-title"},...l))}function Fe(e,t){let o=e.capabilities?.fanSpeeds??[];if(t.fanSteps.length===0)return n("section",{},n("h2",{},"Fan speed"),n("p",{class:"help"},"This unit does not let apps set its fan speed, so there is nothing to choose."));let a=e.fanControl==="hidden",r=t.hasFanAuto&&!a&&(e.fanAutoControl==="firstStep"||e.fanAutoControl==="lastStep"),c=t.hasFanAuto&&e.fanAutoControl==="switch",d=t.fanSteps;r&&(d=e.fanAutoControl==="firstStep"?["auto",...t.fanSteps]:[...t.fanSteps,"auto"]);let p=t.hasFanAuto&&!r?" Auto is not among them: it is a fan mode of its own.":"",g=`${d.length} ${d.length===1?"speed":"speeds"}, ${r?"in order":"slowest first"}: ${Le(d)}.${p}`;return n("section",{},n("h2",{},"Fan speed"),n("div",{class:"choices"},$("fan","steps",e.fanControl,"Steps",g,A.steps,m=>f(e,{fanControl:m})),$("fan","percent",e.fanControl,"Percentage",`A slider from 0 to 100, which the plugin rounds to the nearest of ${g}`,A.percent,m=>f(e,{fanControl:m})),$("fan","hidden",e.fanControl,"Not shown in Matter","No fan control. Pick below what the plugin does with the fan speed instead.",A.hidden,m=>f(e,{fanControl:m}))),e.fanControl==="hidden"?n("div",{class:"field"},n("label",{for:"fan-fixed"},"When the plugin sends a command, the fan speed"),n("select",{id:"fan-fixed",onchange:m=>f(e,{fanSpeedWhenHidden:m.target.value})},n("option",{value:"keep",selected:e.fanSpeedWhenHidden==="keep"},"stays as it is"),...o.map(m=>n("option",{value:m,selected:e.fanSpeedWhenHidden===m},`is set to ${Y[m]}`)))):null,e.fanControl==="hidden"?null:O("separate-fan",e.hasSeparateFan,"Show the fan as a device of its own",`${j(e,"Fan",!1)}, and the air conditioner has no fan speed of its own. For apps that show no fan speed on an air conditioner, or do not show it well. It always shows the speed the unit holds, also while the unit is off.`,m=>f(e,{hasSeparateFan:m})),Ne(e,t,a&&!c?"native":e.fanAutoControl))}function Pe(e,t){let{swingModes:o}=t;if(o.length===0)return n("section",{},n("h2",{},"Swing"),n("p",{class:"help"},"This unit does not let apps move its louvers, so there is nothing to choose."));let s=o.includes("vertical"),a=o.includes("horizontal"),r=e.fanControl!=="hidden"&&t.fanSteps.length>0,c=e.swingControl==="native"&&!r?"switches":e.swingControl,d=r?" The fan control then has no rocking.":"",l="One switch, for the up and down swing.";return s&&a?l="Two switches: one for the up and down swing, one for left and right.":a&&(l="One switch, for the left and right swing."),n("section",{},n("h2",{},"Swing"),n("div",{class:"choices"},r?$("swing","native",c,"Native rocking","The rocking of the fan control, as Matter has it: up and down for the vertical swing, left and right for the horizontal. Not every app shows it, and Apple Home shows it as a single Oscillate on/off.",A.rocking,p=>f(e,{swingControl:p})):null,$("swing","switches",c,"Switches",`${l}${d}`,A.switches,p=>f(e,{swingControl:p})),$("swing","select",c,"A mode select",`${j(e,"Swing",!0)}, and picks one of: ${o.map(p=>p==="both"?ee[p]:ee[p].toLowerCase()).join(", ")}.${d} ${ge}`,A.select,p=>f(e,{swingControl:p})),$("swing","hidden",c,"Not shown in Matter","No swing control. Pick below what the plugin does with the swing instead.",A.hidden,p=>f(e,{swingControl:p}))),c==="native"&&t.swingsOnBothAxes||c==="switches"&&s&&a?Oe(e,c==="native"):null,e.swingControl==="hidden"?n("div",{class:"field"},n("label",{for:"swing-fixed"},"When the plugin sends a command, the swing"),n("select",{id:"swing-fixed",onchange:p=>f(e,{swingModeWhenHidden:p.target.value})},n("option",{value:"keep",selected:e.swingModeWhenHidden==="keep"},"stays as it is"),...o.map(p=>n("option",{value:p,selected:e.swingModeWhenHidden===p},`is set to: ${ee[p]}`)))):null)}function Oe(e,t){let o=r=>f(e,{swingAxes:r}),s="The other axis has no control in Matter, and stays as it is.",a=t?"Some apps, such as Apple Home, show the rocking as a single Oscillate on/off. One axis alone makes that switch swing the louvers on it.":"One switch alone, for the axis picked, instead of a switch for each axis.";return n("div",{class:"field"},n("h3",{id:"swing-axes-title"},t?"Rocking axes":"Switch axes"),n("p",{class:"help"},a),n("div",{class:"choices",role:"radiogroup","aria-labelledby":"swing-axes-title"},y("swing-axes","both",e.swingAxes,"Both axes",t?"Up and down, and left and right, each rocking on its own.":"A switch for up and down, and one for left and right.",o),y("swing-axes","vertical",e.swingAxes,"Up and down alone",s,o),y("swing-axes","horizontal",e.swingAxes,"Left and right alone",s,o)))}function je(e,t){let o=D(e.modeReplacements,t);return n("div",{class:"replacements"},...t.lackingModes.flatMap(s=>{let a=`mode-replacement-${s}`,r=t.switchableModes.find(l=>o[l]===s),c=Object.fromEntries(Object.entries(o).filter(([,l])=>l!==s)),d=l=>{let p=l.target.value,g={...c};p!==""&&(g[p]=s),f(e,{modeReplacements:D(g,t)})};return[n("label",{for:a},H[s]),n("select",{id:a,onchange:d},n("option",{value:"",selected:r===void 0},"is not offered"),...t.switchableModes.map(l=>n("option",{value:l,selected:r===l,disabled:c[l]!==void 0||!J(l,s,c,t)},`runs ${H[l].toLowerCase()}`)))]}))}function qe(e,t){let{switchableModes:o,lackingModes:s}=t;if(o.length===0)return null;let a=o.filter(v=>e.modeSwitches.includes(v)),r=o.filter(v=>v==="dehumidify"||v==="fan"),c=r.length>0,d=e.modeControl==="select"&&!c?"native":e.modeControl,l=v=>{v==="switches"&&a.length===0?f(e,{modeControl:v,modeSwitches:c?r:[...o]}):f(e,{modeControl:v})},p=o.includes("cool")?"cool":"heat",g=r.map(v=>H[v].toLowerCase()).join(" and "),m=c?`Off turns the unit off, or from ${g} puts it back in ${p}.`:"Off turns the unit off.",x=`${H[a.length>0?a[0]:o[0]]} Mode`,T=e.isComposed?`Each appears as a part of "${e.name}", tagged with its mode, such as "${x}".`:`Each appears as "${e.name} ${x}", and so on.`,w=s.map(v=>H[v].toLowerCase()),q=w.length===1?w[0]:`${w.slice(0,-1).join(", ")} or ${w[w.length-1]}`;return n("section",{},n("h2",{},"Modes"),n("p",{class:"help"},"Every mode of the unit is a mode of the air conditioner in Matter, but some apps, such as Apple Home and Google Home, only offer off, cool, heat and auto."),n("div",{class:"choices",role:"radiogroup","aria-label":"Modes"},y("mode-control","native",d,"Native modes only","The modes of the unit are those of the air conditioner, as Matter has them, and nothing more is added.",l),c?y("mode-control","select",d,"A mode select",`${j(e,"Mode",!0)}, with Off and every mode of the unit, as the air conditioner has them. Picking a mode turns the unit on in it. ${ge}`,l):null,y("mode-control","switches",d,"Switches",`A switch for each mode picked below. On turns the unit on in that mode. ${m}`,l),d==="switches"?n("div",{class:"sub"},Re("mode-switch","Modes that get a switch",o,a,H,v=>f(e,{modeSwitches:v})),n("p",{class:"help"},T)):null),s.length>0?n("div",{class:"field"},n("h3",{},"Modes the unit lacks"),n("p",{class:"help"},`This unit has no ${q}. Each can run one of its modes instead, such as heat running dry on a unit that only cools: an app then reaches that mode from the modes it offers, and nothing is added to Matter. The air conditioner shows the mode picked while the unit is in it, with its setpoint. Auto is offered once the air conditioner both cools and heats, counting these.`),je(e,t)):null)}function Ie(e,t){return t.specialModes.length===0?null:n("section",{},n("h2",{},"Special modes"),n("p",{class:"help"},"Matter has no control for these, so each can get a switch of its own. A switch only takes effect in the modes this unit offers that special mode in."),n("div",{class:"choices"},...t.specialModes.map(o=>O(`special-${o}`,e.specialModeSwitches.includes(o),`Add a switch for ${we[o].title}`,we[o].text,s=>f(e,{specialModeSwitches:t.specialModes.filter(a=>a===o?s:e.specialModeSwitches.includes(a))})))))}function Be(e){return n("section",{},n("h2",{},"Humidity and outdoor temperature"),n("p",{class:"help"},"No adapter says which readings its unit has, so each of these takes effect once the unit gives that reading. The room temperature and the humidity are always on the air conditioner."),n("div",{class:"choices"},O("separate-humidity",e.hasSeparateHumiditySensor,"Also show the humidity on a sensor of its own",`${j(e,"Humidity",!1)}, and the air conditioner keeps its humidity. For apps that show no humidity on an air conditioner, which Apple Home is reported to be.`,t=>f(e,{hasSeparateHumiditySensor:t})),O("outdoor-sensor",e.hasOutdoorTemperatureSensor,"Add a sensor for the outdoor temperature",`It appears as "${e.name} Outdoor Temperature". It is a device of its own, which you can put in another room, such as outside. Until you do, a Matter app may show the outdoor temperature as that of the room it put the sensor in. Some units give no outdoor temperature while they are idle: the sensor then shows no value.`,t=>f(e,{hasOutdoorTemperatureSensor:t}))))}function We(e){return n("section",{},n("h2",{},"One device or several"),n("p",{class:"help"},"The switches, a fan of its own and a humidity sensor of its own can be parts of the air conditioner in Matter, or devices of their own beside it. The outdoor temperature sensor is always a device of its own, so that you can put it in another room than the air conditioner."),n("div",{class:"choices"},O("composed",e.isComposed,"Make them parts of the air conditioner",`Your Matter app has one device, "${e.name}", and they move between rooms with it. A part has no name of its own in Matter, so an app may show the switches as numbered outlets, and an app that shows no parts shows the air conditioner alone. Turned off, each is a device of its own with its own name, which your app puts in a room by itself.`,t=>f(e,{isComposed:t}))))}function ve(){let e=S();if(e===void 0)return[b()];let t=e.controls??se;return[E(),K(),z(e,`Options for ${Ee(e)}. Power, mode and temperature always appear in Matter: choose how the rest appears.`),He(e),De(e,t),Fe(e,t),Pe(e,t),qe(e,t),Ie(e,t),Be(e),We(e),e.isNew?null:n("p",{class:"help"},"A change of any of these applies at the next restart of Matterbridge. A switch or a sensor you add is new in your Matter app, in its default room, and one you remove is gone."),b(),n("div",{class:"footer"},u("Cancel",k),u(e.isNew?`Add ${e.name}`:"Save options",()=>{le(e)},"primary"))]}function ye(){try{if(window.parent===window)return;let e=getComputedStyle(window.parent.document.body);for(let t of["--primary-color","--div-bg-color","--div-text-color","--main-bg-color","--main-label-color","--div-border-color","--main-light-color"]){let o=e.getPropertyValue(t).trim();o!==""&&document.documentElement.style.setProperty(`--host${t.slice(1)}`,o)}document.documentElement.style.setProperty("--host-font",e.fontFamily)}catch{}}ae({loading:()=>[n("p",{class:"notice working",role:"status"},n("span",{class:"spinner"}),"Loading\u2026")],home:me,find:fe,connect:he,options:ve,done:ue});ye();h();B();
|
|
2
2
|
/**
|
|
3
3
|
* @file apps/frontend/src/api.ts
|
|
4
4
|
* @description What the plugin's API sends and takes, and the call to it: see src/setup/setupApi.ts in the plugin.
|
|
5
5
|
* @author Calvin Che
|
|
6
6
|
* @created 2026-10-13
|
|
7
|
-
* @version 1.
|
|
7
|
+
* @version 1.1.0
|
|
8
8
|
* @license Apache-2.0
|
|
9
9
|
*
|
|
10
10
|
* Copyright 2026 Calvin Che.
|
|
@@ -115,7 +115,7 @@ async function M(e,t,o){try{let[s,a]=e.split(" "),r={method:s};t!==void 0&&(r.he
|
|
|
115
115
|
* @description What the setup page does: each action calls the plugin, changes the state of the page and redraws it.
|
|
116
116
|
* @author Calvin Che
|
|
117
117
|
* @created 2026-10-13
|
|
118
|
-
* @version 1.
|
|
118
|
+
* @version 1.2.0
|
|
119
119
|
* @license Apache-2.0
|
|
120
120
|
*
|
|
121
121
|
* Copyright 2026 Calvin Che.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/api.ts", "../src/state.ts", "../src/exposure.ts", "../src/presets.ts", "../src/render.ts", "../src/actions.ts", "../src/dom.ts", "../src/components.ts", "../src/screens/connect.ts", "../src/screens/done.ts", "../src/screens/find.ts", "../src/screens/home.ts", "../src/screens/options.ts", "../src/theme.ts", "../src/app.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @file apps/frontend/src/api.ts\n * @description What the plugin's API sends and takes, and the call to it: see src/setup/setupApi.ts in the plugin.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DaikinCapabilities, DaikinDevice } from 'daikin-local-control';\n\nimport type { DaikinDeviceExposure } from '../../../src/config.js';\nimport type { DiscoveredDevice, SetupDevice, SetupReplies, SetupReply } from '../../../src/setup/setupApi.js';\n\n// The types are the plugin's own, so the page and the plugin cannot drift apart. They are only types: nothing of the\n// plugin is loaded in the browser. The page has its own words for some of them.\nexport type { FanSpeed, SpecialMode, SwingMode } from 'daikin-local-control';\nexport type { ModeReplacements, SwitchedMode } from '../../../src/config.js';\nexport type { AvailableControls } from '../../../src/controls.js';\nexport type { ProbeResult } from '../../../src/setup/probe.js';\nexport type { SetupState } from '../../../src/setup/setupApi.js';\n\nexport type Capabilities = DaikinCapabilities;\nexport type Adapter = DaikinDevice;\nexport type Exposure = DaikinDeviceExposure;\nexport type StoredDevice = SetupDevice;\nexport type FoundAdapter = DiscoveredDevice;\n\n/** A request the plugin serves, by its method and its path after `api/`. */\nexport type Route = keyof SetupReplies;\n\n/** The reply to a request, with what the plugin sends back when the request worked. */\nexport type Reply<R extends Route> = ({ ok: true } & SetupReplies[R]) | Extract<SetupReply, { ok: false }>;\n\n/**\n * Call the plugin.\n *\n * @param route The method and the path, such as `POST probe`.\n * @param body The JSON body.\n * @param query The query string, without its `?`.\n * @returns The reply, with `ok: false` and the reason when the call did not work.\n */\nexport async function api<R extends Route>(route: R, body?: unknown, query?: string): Promise<Reply<R>> {\n try {\n const [method, path] = route.split(' ');\n const init: RequestInit = { method };\n if (body !== undefined) {\n init.headers = { 'Content-Type': 'application/json' };\n init.body = JSON.stringify(body);\n }\n const response = await fetch(new URL(`api/${path}${query === undefined ? '' : `?${query}`}`, document.baseURI), init);\n if (response.status === 204) return { ok: true } as Reply<R>;\n if (response.status === 503) return { ok: false, error: 'The plugin is not running. Start it in Matterbridge, then reload this page.' };\n const reply = (await response.json()) as Reply<R> | { error?: string };\n if ('ok' in reply) return reply;\n return { ok: false, error: reply.error ?? `The plugin answered with status ${response.status}` };\n } catch {\n return { ok: false, error: 'Matterbridge did not answer. Check that it is running, then try again.' };\n }\n}\n", "/**\n * @file apps/frontend/src/state.ts\n * @description What the setup page knows at any moment, and what it reads from that.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Adapter, AvailableControls, Capabilities, Exposure, FoundAdapter, ProbeResult, SetupState } from './api.js';\n\n/** One air conditioner on its way through Connect and Options. */\nexport interface Draft extends Exposure {\n adapter: Adapter;\n name: string;\n isNew: boolean;\n localPassword?: string;\n capabilities?: Capabilities;\n /** What the plugin says the unit leaves to choose in Options. */\n controls?: AvailableControls;\n probe?: ProbeResult;\n}\n\nexport type ScreenName = 'loading' | 'home' | 'find' | 'connect' | 'options' | 'done';\n\nexport const view = {\n screen: 'loading' as ScreenName,\n setup: undefined as SetupState | undefined,\n found: [] as FoundAdapter[],\n selected: new Set<string>(),\n queue: [] as Draft[],\n saved: [] as string[],\n /** The units this run is done with, in the order it went through them. */\n handled: [] as { label: string; isSaved: boolean }[],\n isBusy: false,\n busyText: '',\n error: '',\n /** A note for the user that is no problem, such as what to do after a change. */\n info: '',\n confirmingRemoval: '',\n};\n\nexport function currentDraft(): Draft | undefined {\n return view.queue[0];\n}\n\n/** What a unit is called on the page: its name, or its address until it has one. */\nexport function draftLabel(draft: Draft): string {\n return draft.name === '' ? draft.adapter.host : draft.name;\n}\n\n/** Whether an adapter is that of a stored device, which is known by its MAC address. */\nexport function isStored(adapter: Adapter): boolean {\n return (view.setup?.devices ?? []).some((device) => device.macAddress === adapter.macAddress);\n}\n", "/**\n * @file apps/frontend/src/exposure.ts\n * @description How a device appears in Matter: the choices a draft starts with.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Adapter, AvailableControls, Exposure, ModeReplacements, StoredDevice, SwitchedMode } from './api.js';\nimport { type Draft, view } from './state.js';\n\n/** Copy the choices of how a device appears in Matter, and nothing else. */\nexport function pickExposure(source: Exposure): Exposure {\n const {\n fanControl,\n fanSpeedWhenHidden,\n swingControl,\n swingAxes,\n swingModeWhenHidden,\n modeControl,\n modeSwitches,\n modeReplacements,\n fanAutoControl,\n hasSeparateFan,\n specialModeSwitches,\n hasOutdoorTemperatureSensor,\n hasSeparateHumiditySensor,\n isComposed,\n } = source;\n return {\n fanControl,\n fanSpeedWhenHidden,\n swingControl,\n swingAxes,\n swingModeWhenHidden,\n modeControl,\n modeSwitches: [...modeSwitches],\n modeReplacements: { ...modeReplacements },\n fanAutoControl,\n hasSeparateFan,\n specialModeSwitches: [...specialModeSwitches],\n hasOutdoorTemperatureSensor,\n hasSeparateHumiditySensor,\n isComposed,\n };\n}\n\n// What a new device holds until the plugin says what its unit can do: it then takes the Apple Home preset. What a\n// stored device without a setting gets is the default of `parseDeviceConfig` in the plugin, which stands for how the\n// plugin behaved before that setting existed: the two may differ.\nconst defaultExposure: Exposure = {\n fanControl: 'steps',\n fanSpeedWhenHidden: 'keep',\n swingControl: 'switches',\n swingAxes: 'both',\n swingModeWhenHidden: 'keep',\n modeControl: 'native',\n modeSwitches: [],\n modeReplacements: {},\n fanAutoControl: 'native',\n hasSeparateFan: false,\n specialModeSwitches: [],\n hasOutdoorTemperatureSensor: false,\n hasSeparateHumiditySensor: false,\n isComposed: true,\n};\n\n/** The longest name Matter takes. */\nconst maxNameLength = 32;\n\n/** A name no device has yet: the name the adapter tells, or that name with a number after it, such as \"Bedroom 2\". */\nexport function uniqueName(base: string, taken: ReadonlySet<string>): string {\n if (base === '' || !taken.has(base)) return base;\n for (let count = 2; ; count++) {\n const suffix = ` ${count}`;\n const name = `${base.slice(0, maxNameLength - suffix.length).trimEnd()}${suffix}`;\n if (!taken.has(name)) return name;\n }\n}\n\n/** The names a draft cannot take: those of the stored devices but its own, and those of the other drafts of the run. */\nexport function takenNames(draft: Draft): Set<string> {\n const stored = (view.setup?.devices ?? []).filter((device) => device.macAddress !== draft.adapter.macAddress).map((device) => device.name);\n const queued = view.queue.filter((other) => other !== draft).map((other) => other.name);\n return new Set([...stored, ...queued].filter((name) => name !== ''));\n}\n\n/**\n * The drafts of adapters picked in the Find step, each named after its adapter. Adapters can share a name, so each\n * draft gets one no stored device and no draft before it has.\n */\nexport function draftsFromAdapters(adapters: readonly Adapter[]): Draft[] {\n const taken = new Set((view.setup?.devices ?? []).map((device) => device.name));\n return adapters.map((adapter) => {\n const name = uniqueName(adapter.name ?? '', taken);\n if (name !== '') taken.add(name);\n return { adapter, name, isNew: true, ...pickExposure(defaultExposure) };\n });\n}\n\nexport function draftFromStored(device: StoredDevice): Draft {\n const { capabilities, controls, name, macAddress, host, protocol, requiresRegistration, usesHttps, requiresLocalPassword } = device;\n // The stored name is the one given in the setup page: the check in Connect reads the adapter's own.\n const adapter: Adapter = { host, protocol, macAddress, requiresRegistration, usesHttps, requiresLocalPassword };\n return { adapter, name, isNew: false, capabilities, controls, ...pickExposure(device) };\n}\n\n// What a unit the plugin told nothing about can have: no control and no switch.\nexport const noControls: AvailableControls = {\n fanSteps: [],\n hasFanAuto: false,\n hasSwing: false,\n swingModes: [],\n swingsOnBothAxes: false,\n switchableModes: [],\n lackingModes: [],\n specialModes: [],\n};\n\n/**\n * Whether a mode of the unit can be shown as a thermostat mode, given what its other modes are shown as, as\n * `getModeReplacements` in the plugin keeps it: only as a mode the unit lacks, no two as the same one, and as Auto\n * only on a thermostat that both cools and heats, counting the replacements, because Matter has Auto only with both.\n */\nexport function canReplace(mode: SwitchedMode, replacement: SwitchedMode, replacements: ModeReplacements, controls: AvailableControls): boolean {\n if (!controls.switchableModes.includes(mode) || !controls.lackingModes.includes(replacement)) return false;\n const others = controls.switchableModes.filter((other) => other !== mode).map((other) => replacements[other]);\n if (others.includes(replacement)) return false;\n if (replacement !== 'auto') return true;\n const modes = new Set([...controls.switchableModes, ...others]);\n return modes.has('cool') && modes.has('heat');\n}\n\n/** The replacements the plugin keeps for a unit: those it can take. */\nexport function fitModeReplacements(replacements: ModeReplacements, controls: AvailableControls): ModeReplacements {\n const fitted: ModeReplacements = {};\n for (const mode of controls.switchableModes) {\n const replacement = replacements[mode];\n if (replacement !== undefined && canReplace(mode, replacement, replacements, controls)) fitted[mode] = replacement;\n }\n return fitted;\n}\n", "/**\n * @file apps/frontend/src/presets.ts\n * @description The presets of the Options step: each fills in the choices of how a device appears in Matter.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { AvailableControls, Exposure } from './api.js';\nimport { fitModeReplacements, pickExposure } from './exposure.js';\nimport type { Draft } from './state.js';\n\nexport type PresetName = 'apple' | 'google' | 'matter';\n\nexport const presets: Record<PresetName, { title: string; text: string }> = {\n apple: {\n title: 'Apple Home',\n text: 'Fan speed as a percentage, the swing as the rocking of the fan on one axis, the humidity on a sensor of its own too, and a switch for auto fan and for each of dry and fan, each a device of its own.',\n },\n google: {\n title: 'Google Home',\n text: 'Fan speed as steps, the swing as the rocking of the fan on one axis, the humidity on a sensor of its own too, and a switch for auto fan and for each of dry and fan, each a device of its own.',\n },\n matter: {\n title: 'Full Matter support',\n text: 'For apps that show every Matter control: fan speed as steps with its auto mode, the swing as the rocking of the fan, a switch for each special mode and the outdoor temperature, all as one device.',\n },\n};\n\n/**\n * The choices a preset makes for a unit: never a switch or a control the unit has no use for. The Apple Home and the\n * Google Home presets make the switches, a fan of its own and a humidity sensor of its own devices of their own, and\n * the Full Matter support preset makes them parts of the air conditioner.\n */\nexport function presetExposure(name: PresetName, controls: AvailableControls): Exposure {\n const isMatter = name === 'matter';\n // An app that shows every Matter control gets the rocking of the fan control on every axis, or its switches on a unit\n // without a fan control. Home shows the rocking as a single Oscillate on/off, so it gets one axis alone, left and right\n // where the unit swings on both, and Google Home gets the same. Both leave the swing as it is on a unit without a fan\n // control, rather than add a switch for each axis.\n const hasRocking = controls.hasSwing && (isMatter || controls.fanSteps.length > 0);\n const swingControl: Exposure['swingControl'] = hasRocking ? 'native' : 'hidden';\n // Home and Google Home are reported to offer off, cool, heat and auto alone, so dry and fan get a switch each where\n // the unit has them.\n const modeSwitches = isMatter ? [] : controls.switchableModes.filter((mode) => mode === 'dehumidify' || mode === 'fan');\n return {\n fanControl: controls.fanSteps.length === 0 ? 'hidden' : name === 'apple' ? 'percent' : 'steps',\n fanSpeedWhenHidden: 'keep',\n swingControl,\n swingAxes: !isMatter && hasRocking && controls.swingsOnBothAxes ? 'horizontal' : 'both',\n swingModeWhenHidden: 'keep',\n // An app that shows every Matter control has dry and fan among the modes of the thermostat.\n modeControl: modeSwitches.length > 0 ? 'switches' : 'native',\n modeSwitches,\n modeReplacements: {},\n // Neither Home nor Google Home is known to show the auto fan mode, which the switch is beside.\n fanAutoControl: !isMatter && controls.hasFanAuto ? 'switch' : 'native',\n // No preset takes the fan off the air conditioner: that is for an app that shows no fan speed there.\n hasSeparateFan: false,\n // Matter has nothing for the special modes, so a switch is the one way to them.\n specialModeSwitches: isMatter ? [...controls.specialModes] : [],\n // An app may show the outdoor temperature as that of the room it puts the sensor in, until the sensor is moved.\n hasOutdoorTemperatureSensor: isMatter,\n // Home is reported to show a humidity on a sensor of its own only, and Google Home lists the humidity sensor among\n // what it supports but not the Room Air Conditioner. The humidity stays on the air conditioner too.\n hasSeparateHumiditySensor: !isMatter,\n // Home shows the parts of a composed device without their names. Google lists neither composed devices nor the\n // Room Air Conditioner among what Google Home supports, but says every device behind a bridge appears as normal.\n isComposed: isMatter,\n };\n}\n\n/** Whether the choices in a draft are exactly those of a preset, leaving aside what the unit has no use for. */\nexport function matchesPreset(draft: Draft, name: PresetName, controls: AvailableControls): boolean {\n const chosen = pickExposure(draft);\n if (controls.fanSteps.length === 0) Object.assign(chosen, { fanControl: 'hidden', fanSpeedWhenHidden: 'keep' });\n // The choice shows nowhere while the fan is hidden.\n if (chosen.fanControl === 'hidden') chosen.hasSeparateFan = false;\n // Nor does the auto fan speed on a unit without one, a step of a hidden fan, or a switch beside a fixed fan speed.\n const isAutoStep = chosen.fanAutoControl === 'firstStep' || chosen.fanAutoControl === 'lastStep';\n const hasFixedFanSpeed = chosen.fanControl === 'hidden' && chosen.fanSpeedWhenHidden !== 'keep';\n if (!controls.hasFanAuto || (isAutoStep && chosen.fanControl === 'hidden') || hasFixedFanSpeed) chosen.fanAutoControl = 'native';\n if (!controls.hasSwing) Object.assign(chosen, { swingControl: 'hidden', swingModeWhenHidden: 'keep' });\n // Without a fan control, the rocking is the switches.\n if (chosen.fanControl === 'hidden' && chosen.swingControl === 'switches') chosen.swingControl = 'native';\n // The axes show only for the rocking or the switches of a unit that swings on both axes.\n if ((chosen.swingControl !== 'native' && chosen.swingControl !== 'switches') || !controls.swingsOnBothAxes) chosen.swingAxes = 'both';\n // The switches are a choice only while they are chosen, and both they and the replacements only for what the unit\n // has. A mode select shows nothing more than the thermostat on a unit without a dry or a fan mode.\n chosen.modeSwitches = chosen.modeControl === 'switches' ? controls.switchableModes.filter((mode) => chosen.modeSwitches.includes(mode)) : [];\n chosen.modeReplacements = fitModeReplacements(chosen.modeReplacements, controls);\n const isOfUse: Record<Exposure['modeControl'], boolean> = {\n native: true,\n select: controls.switchableModes.includes('dehumidify') || controls.switchableModes.includes('fan'),\n switches: chosen.modeSwitches.length > 0,\n };\n if (!isOfUse[chosen.modeControl]) chosen.modeControl = 'native';\n chosen.specialModeSwitches = controls.specialModes.filter((mode) => chosen.specialModeSwitches.includes(mode));\n return JSON.stringify(chosen) === JSON.stringify(presetExposure(name, controls));\n}\n", "/**\n * @file apps/frontend/src/render.ts\n * @description Draws the screen the setup page is on. The screens are handed in by app.ts, so that they and the\n * actions can call for a redraw without this file depending on them.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Child } from './dom.js';\nimport { currentDraft, type ScreenName, view } from './state.js';\n\nexport type Screens = Record<ScreenName, () => Child[]>;\n\nlet screens: Screens | undefined;\n\n/** Tell the page what each screen draws. */\nexport function setScreens(all: Screens): void {\n screens = all;\n}\n\nexport function render(): void {\n const root = document.getElementById('app');\n if (root === null || screens === undefined) return;\n // Keep what the user is typing when the same form redraws around it, and never carry it over to another form.\n const form = `${view.screen}:${currentDraft()?.adapter.host ?? ''}`;\n const isSameForm = root.dataset.form === form;\n const active = document.activeElement;\n const activeId = active instanceof HTMLElement ? active.id : '';\n // Where the caret is in the field being typed in, so that a redraw while typing does not move it to the end.\n const caret =\n active instanceof HTMLInputElement && (active.type === 'text' || active.type === 'password') ? { start: active.selectionStart, end: active.selectionEnd } : undefined;\n const typed = new Map<string, string>();\n for (const input of root.querySelectorAll<HTMLInputElement>('input[type=text], input[type=password]')) {\n if (input.id !== '') typed.set(input.id, input.value);\n }\n root.replaceChildren(...screens[view.screen]().filter((child): child is Node | string => child !== false && child !== null && child !== undefined));\n root.dataset.form = form;\n if (!isSameForm) return;\n for (const [id, value] of typed) {\n const input = document.getElementById(id);\n if (input instanceof HTMLInputElement) input.value = value;\n }\n if (activeId === '') return;\n const focused = document.getElementById(activeId);\n focused?.focus();\n if (caret !== undefined && focused instanceof HTMLInputElement) focused.setSelectionRange(caret.start, caret.end);\n}\n", "/**\n * @file apps/frontend/src/actions.ts\n * @description What the setup page does: each action calls the plugin, changes the state of the page and redraws it.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.1.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { api, type StoredDevice } from './api.js';\nimport { pickExposure, takenNames, uniqueName } from './exposure.js';\nimport { presetExposure } from './presets.js';\nimport { render } from './render.js';\nimport { currentDraft, type Draft, draftLabel, isStored, view } from './state.js';\n\n/**\n * Run a call while the page shows that it is working.\n *\n * @param text What the page says meanwhile.\n * @param task The call.\n * @returns What the call returned.\n */\nasync function busy<T>(text: string, task: () => Promise<T>): Promise<T> {\n view.isBusy = true;\n view.busyText = text;\n view.error = '';\n view.info = '';\n render();\n try {\n return await task();\n } finally {\n view.isBusy = false;\n render();\n }\n}\n\nexport async function loadState(): Promise<void> {\n const reply = await api('GET state');\n if (!reply.ok) {\n view.error = reply.error;\n view.screen = 'home';\n render();\n return;\n }\n view.setup = reply.state;\n // With nothing set up yet, the page goes straight to finding the air conditioners.\n if (reply.state.devices.length === 0) {\n await search();\n return;\n }\n view.screen = 'home';\n render();\n}\n\nasync function refreshState(): Promise<void> {\n const reply = await api('GET state');\n if (reply.ok) view.setup = reply.state;\n}\n\nexport function goHome(): void {\n view.queue = [];\n view.saved = [];\n view.handled = [];\n view.error = '';\n view.info = '';\n view.screen = 'home';\n void refreshState().then(render);\n render();\n}\n\nexport async function search(): Promise<void> {\n view.screen = 'find';\n const reply = await busy('Searching your network. This takes about three seconds\u2026', async () => api('POST discover'));\n if (!reply.ok) {\n view.error = `The search did not run: ${reply.error}`;\n render();\n return;\n }\n // Keep the adapters added by address: a search does not find them. One of them may have been set up since.\n await refreshState();\n const byAddress = view.found\n .filter((adapter) => !reply.devices.some((device) => device.host === adapter.host) && view.selected.has(adapter.host))\n .map((adapter) => ({ ...adapter, isConfigured: isStored(adapter) }));\n view.found = [...reply.devices, ...byAddress];\n for (const adapter of reply.devices) {\n if (!adapter.isConfigured) view.selected.add(adapter.host);\n }\n render();\n}\n\nexport async function lookUp(host: string): Promise<void> {\n const reply = await busy(`Looking for an adapter at ${host}\u2026`, async () => api('POST identify', { host }));\n if (!reply.ok) {\n view.error = reply.error;\n render();\n return;\n }\n const isConfigured = isStored(reply.device);\n // Whether the adapter knows this plugin already shows in the Connect step: an address alone does not tell.\n const needsRegistration = reply.device.requiresRegistration === true;\n view.found = [...view.found.filter((adapter) => adapter.host !== reply.device.host), { ...reply.device, isConfigured, needsRegistration }];\n if (!isConfigured) view.selected.add(reply.device.host);\n render();\n}\n\nexport function startQueue(drafts: Draft[]): void {\n view.queue = drafts;\n view.saved = [];\n view.handled = [];\n void enterConnect();\n}\n\nasync function enterConnect(): Promise<void> {\n const draft = currentDraft();\n if (draft === undefined) {\n view.screen = view.saved.length > 0 ? 'done' : 'home';\n await refreshState();\n render();\n return;\n }\n view.screen = 'connect';\n view.error = '';\n view.info = '';\n draft.probe = undefined;\n render();\n await check(draft);\n}\n\nexport async function check(draft: Draft, key?: string): Promise<void> {\n // The adapter as it announced itself: an adapter whose name is not known yet is asked for it.\n const body = { device: draft.adapter, localPassword: draft.localPassword, key };\n const text = key === undefined ? `Checking ${draftLabel(draft)}\u2026` : `Registering with ${draftLabel(draft)}\u2026`;\n const reply = await busy(text, async () => api(key === undefined ? 'POST probe' : 'POST register', body));\n if (!reply.ok) {\n view.error = reply.error;\n render();\n return;\n }\n draft.probe = reply.result;\n draft.adapter = reply.result.device;\n if (reply.result.status === 'ready') {\n const isFirstReading = draft.controls === undefined;\n draft.capabilities = reply.result.capabilities;\n draft.controls = reply.result.controls;\n // A new unit starts with the Apple Home preset, once what it can do is known. A later check, such as after a\n // registration, keeps what was chosen since.\n if (draft.isNew && isFirstReading && draft.controls !== undefined) Object.assign(draft, presetExposure('apple', draft.controls));\n // A unit that has no name yet starts with the one its adapter tells, which is its own from then on.\n const told = reply.result.device.name ?? '';\n if (draft.name === '' && told !== '') draft.name = uniqueName(told, takenNames(draft));\n view.screen = 'options';\n }\n render();\n}\n\nexport function skipDraft(): void {\n const skipped = view.queue.shift();\n if (skipped !== undefined) view.handled.push({ label: draftLabel(skipped), isSaved: false });\n void enterConnect();\n}\n\nexport async function saveDraft(draft: Draft): Promise<void> {\n const name = draft.name.trim();\n const problem = checkName(draft, name);\n if (problem !== '') {\n view.error = problem;\n render();\n return;\n }\n const { adapter, localPassword } = draft;\n const device = { ...adapter, name, localPassword, ...pickExposure(draft) };\n const reply = await busy(`Saving ${name}\u2026`, async () => api('POST device', { device }));\n if (!reply.ok) {\n view.error = reply.error;\n render();\n return;\n }\n view.setup = reply.state;\n view.saved.push(name);\n view.handled.push({ label: name, isSaved: true });\n view.queue.shift();\n await enterConnect();\n}\n\n/** What is wrong with the name of a draft, or nothing: the plugin refuses a name another device has. */\nfunction checkName(draft: Draft, name: string): string {\n if (name === '') return 'Give the air conditioner a name: it is the name it gets in Matter.';\n const isTaken = (view.setup?.devices ?? []).some((device) => device.name === name && device.macAddress !== draft.adapter.macAddress);\n return isTaken ? `\"${name}\" is already the name of another air conditioner. Pick a different one.` : '';\n}\n\n// Matterbridge does not tell its own page when a plugin adds or removes a device, so its device list waits for a reload.\nexport const reloadNote = \"Matterbridge's own list of devices shows the change once you reload its page.\";\n\n/** A change of how an air conditioner appears in Matter waits for a restart, which the plugin asks Matterbridge for as well. */\nexport const restartNote = 'Restart Matterbridge to apply the new options in Matter: until then the air conditioner keeps its current controls.';\n\nexport async function removeDevice(device: StoredDevice): Promise<void> {\n const reply = await busy(`Removing ${device.name}\u2026`, async () => api('DELETE device', undefined, `macAddress=${encodeURIComponent(device.macAddress)}`));\n view.confirmingRemoval = '';\n if (reply.ok) view.info = `${device.name} is removed. ${reloadNote}`;\n else view.error = reply.error;\n await refreshState();\n render();\n}\n", "/**\n * @file apps/frontend/src/dom.ts\n * @description The one helper the setup page builds its elements with.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type Child = Node | string | false | null | undefined;\n\n/**\n * Create an element.\n *\n * @param tag The tag name.\n * @param props `class`, `on<event>` listeners, and anything else as a property when the element has it, else an attribute.\n * @param children Nodes or text; false, null and undefined are skipped.\n * @returns The element.\n */\nexport function h<K extends keyof HTMLElementTagNameMap>(tag: K, props: Record<string, unknown> = {}, ...children: Child[]): HTMLElementTagNameMap[K] {\n const element = document.createElement(tag);\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined || value === false) continue;\n if (key === 'class') element.className = String(value);\n else if (key === 'html') element.innerHTML = String(value);\n else if (key.startsWith('on') && typeof value === 'function') element.addEventListener(key.slice(2), value as EventListener);\n else if (key in element) (element as unknown as Record<string, unknown>)[key] = value;\n else element.setAttribute(key, String(value));\n }\n for (const child of children) {\n if (child !== false && child !== null && child !== undefined) element.append(child);\n }\n return element;\n}\n", "/**\n * @file apps/frontend/src/components.ts\n * @description The pieces more than one screen of the setup page is made of.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Child, h } from './dom.js';\nimport { currentDraft, type Draft, draftLabel, type ScreenName, view } from './state.js';\n\nexport function button(label: string, onclick: () => void, kind: 'primary' | 'quiet' | 'danger' = 'quiet', disabled = false): HTMLButtonElement {\n return h('button', { type: 'button', class: `button ${kind}`, onclick, disabled: disabled || view.isBusy }, label);\n}\n\nexport function notice(): Child {\n if (view.isBusy) return h('p', { class: 'notice working', role: 'status' }, h('span', { class: 'spinner' }), view.busyText);\n if (view.error !== '') return h('p', { class: 'notice problem', role: 'alert' }, view.error);\n if (view.info !== '') return h('p', { class: 'notice', role: 'status' }, view.info);\n return null;\n}\n\n/**\n * The units of this run, with the one the page is on marked: shown when a run sets up more than one, so that it is\n * plain which unit the Connect and Options steps are about.\n */\nexport function unitStrip(): Child {\n const current = currentDraft();\n if (current === undefined || !current.isNew || view.handled.length + view.queue.length < 2) return null;\n const doing = view.screen === 'connect' ? 'Connecting' : 'Choosing options';\n return h(\n 'ol',\n { 'class': 'units', 'aria-label': 'Air conditioners in this setup' },\n ...view.handled.map((unit) =>\n h('li', { class: unit.isSaved ? 'done' : 'skipped' }, h('strong', {}, unit.label), h('span', { class: 'meta' }, unit.isSaved ? 'Added' : 'Skipped')),\n ),\n ...view.queue.map((draft, index) =>\n h(\n 'li',\n { 'class': index === 0 ? 'current' : 'ahead', 'aria-current': index === 0 ? 'true' : undefined },\n h('strong', {}, draftLabel(draft)),\n h('span', { class: 'meta' }, index === 0 ? doing : 'Waiting'),\n ),\n ),\n );\n}\n\n/** The heading of a step that is about one unit: the unit first, then what the step does with it. */\nexport function unitHeader(draft: Draft, text: string): HTMLElement {\n return h('header', { class: 'unit-header' }, h('h1', {}, draftLabel(draft)), h('p', { class: 'meta' }, text));\n}\n\nexport function steps(): Child {\n if (view.queue.length > 0 && !view.queue.some((draft) => draft.isNew)) return null;\n const names = ['Find', 'Connect', 'Options'];\n const screens: ScreenName[] = ['find', 'connect', 'options'];\n const current = screens.indexOf(view.screen);\n return h(\n 'ol',\n { class: 'steps' },\n ...names.map((name, index) => {\n let state = 'ahead';\n if (index < current) state = 'done';\n else if (index === current) state = 'current';\n return h('li', { 'class': state, 'aria-current': index === current ? 'step' : undefined }, name);\n }),\n );\n}\n", "/**\n * @file apps/frontend/src/screens/connect.ts\n * @description The Connect step: the page checks an adapter and asks for what the adapter wants before it answers.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { check, goHome, skipDraft } from '../actions.js';\nimport { button, notice, steps, unitHeader, unitStrip } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { currentDraft, type Draft, view } from '../state.js';\n\nfunction lockCodeForm(draft: Draft, isRejected: boolean): HTMLElement {\n const code = h('input', { type: 'password', id: 'lock-code', inputMode: 'numeric', autocomplete: 'off', maxLength: 64 });\n return h(\n 'div',\n { class: 'field' },\n h('label', { for: 'lock-code' }, 'Child lock code'),\n h('p', { class: 'help' }, 'The 4-digit code set under Child lock in the Daikin app the adapter was set up with. It is not printed on the adapter.'),\n isRejected ? h('p', { class: 'problem-text' }, 'The adapter did not accept that code.') : null,\n h(\n 'div',\n { class: 'inline-form' },\n code,\n button(\n 'Check the code',\n () => {\n if (code.value === '') return;\n draft.localPassword = code.value;\n void check(draft);\n },\n 'primary',\n ),\n ),\n );\n}\n\nfunction keyForm(draft: Draft, isRejected: boolean): HTMLElement {\n const key = h('input', { type: 'text', id: 'adapter-key', autocomplete: 'off', spellcheck: false, maxLength: 64 });\n return h(\n 'div',\n { class: 'field' },\n h('label', { for: 'adapter-key' }, 'KEY on the adapter'),\n h(\n 'p',\n { class: 'help' },\n 'This adapter only answers apps it has registered. The KEY is printed on its label, next to the SSID, and in the operation manual. It is used once and not stored.',\n ),\n isRejected ? h('p', { class: 'problem-text' }, 'The adapter did not accept that KEY.') : null,\n h(\n 'div',\n { class: 'inline-form' },\n key,\n button(\n 'Register',\n () => {\n if (key.value.trim() !== '') void check(draft, key.value.trim());\n },\n 'primary',\n ),\n ),\n );\n}\n\n/** What the adapter wants before the page can go on, or why the page cannot: nothing while the check has no answer. */\nfunction credentialForm(draft: Draft): Child {\n const status = draft.probe?.status;\n if (status === 'localPasswordRequired' || status === 'localPasswordRejected') return lockCodeForm(draft, status === 'localPasswordRejected');\n if (status === 'registrationRequired' || status === 'registrationRejected') return keyForm(draft, status === 'registrationRejected');\n if (status === 'unreachable') {\n return h(\n 'p',\n { class: 'notice problem', role: 'alert' },\n `${draft.name} did not answer at ${draft.adapter.host}. Check that it has power and is on the network, then try again.`,\n );\n }\n if (status === 'failed') return h('p', { class: 'notice problem', role: 'alert' }, `${draft.name} answered with an error: ${draft.probe?.message ?? 'unknown'}`);\n return null;\n}\n\nexport function connectScreen(): Child[] {\n const draft = currentDraft();\n if (draft === undefined) return [notice()];\n const canRetry = draft.probe?.status === 'unreachable' || draft.probe?.status === 'failed' || view.error !== '';\n return [\n steps(),\n unitStrip(),\n unitHeader(draft, `Connecting to its adapter at ${draft.adapter.host}.`),\n notice(),\n view.isBusy ? null : credentialForm(draft),\n h(\n 'div',\n { class: 'footer' },\n canRetry ? button('Try again', () => void check(draft)) : null,\n button(draft.isNew && view.queue.length > 1 ? 'Skip this one' : 'Cancel', draft.isNew && view.queue.length > 1 ? skipDraft : goHome),\n ),\n ];\n}\n", "/**\n * @file apps/frontend/src/screens/done.ts\n * @description The screen a run ends on: what it set up.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.1.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { goHome, reloadNote, restartNote } from '../actions.js';\nimport { button } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { view } from '../state.js';\n\nexport function doneScreen(): Child[] {\n const names = view.saved;\n const needsRestart = (view.setup?.devices ?? []).some((device) => names.includes(device.name) && device.needsRestart);\n return [\n h('header', {}, h('h1', {}, names.length === 1 ? `${names[0]} is set up` : `${names.length} air conditioners are set up`)),\n h('p', { class: 'lead' }, 'They now appear in the Matter apps paired with Matterbridge. If Matterbridge is not paired yet, pair it from its home page.'),\n needsRestart ? h('p', { class: 'help' }, h('strong', {}, restartNote)) : null,\n h('p', { class: 'help' }, reloadNote),\n h('div', { class: 'footer' }, button('Done', goHome, 'primary')),\n ];\n}\n", "/**\n * @file apps/frontend/src/screens/find.ts\n * @description The Find step: the adapters a search found or an address led to, and which of them to set up.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { goHome, lookUp, search, startQueue } from '../actions.js';\nimport type { FoundAdapter } from '../api.js';\nimport { button, notice, steps } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { draftsFromAdapters } from '../exposure.js';\nimport { render } from '../render.js';\nimport { view } from '../state.js';\n\nfunction foundRow(adapter: FoundAdapter): HTMLElement {\n const isSelectable = !adapter.isConfigured;\n const notes: string[] = [];\n if (adapter.isConfigured) notes.push('Already set up.');\n if (adapter.name === undefined) notes.push('It has not told its name yet: you will name it in its options.');\n if (isSelectable && adapter.needsRegistration) notes.push('Asks for the KEY printed on its label.');\n else if (isSelectable && adapter.requiresRegistration) notes.push('Already registered with this plugin, so it will not ask for its KEY.');\n if (isSelectable && adapter.requiresLocalPassword) notes.push('Asks for its child lock code.');\n const checkbox = h('input', {\n type: 'checkbox',\n id: `found-${adapter.host}`,\n checked: isSelectable && view.selected.has(adapter.host),\n disabled: !isSelectable,\n onchange: () => {\n if (checkbox.checked) view.selected.add(adapter.host);\n else view.selected.delete(adapter.host);\n render();\n },\n });\n return h(\n 'li',\n { class: isSelectable ? 'found' : 'found unavailable' },\n h(\n 'label',\n { for: `found-${adapter.host}` },\n checkbox,\n h(\n 'span',\n {},\n h('strong', {}, adapter.name ?? 'Unnamed adapter'),\n h('span', { class: 'meta' }, ` ${adapter.host}`),\n ...notes.map((note) => h('span', { class: 'meta note' }, note)),\n ),\n ),\n );\n}\n\nexport function findScreen(): Child[] {\n const chosen = view.found.filter((adapter) => view.selected.has(adapter.host) && !adapter.isConfigured);\n const host = h('input', { type: 'text', id: 'host', placeholder: '192.168.1.50', spellcheck: false, autocomplete: 'off' });\n const lookUpHost = (): void => {\n if (host.value.trim() !== '') void lookUp(host.value.trim());\n };\n host.addEventListener('keydown', (event) => {\n if (event.key === 'Enter') lookUpHost();\n });\n const continueLabel = chosen.length === 1 ? 'Set up 1 air conditioner' : `Set up ${chosen.length} air conditioners`;\n return [\n steps(),\n h('header', {}, h('h1', {}, 'Find your air conditioners')),\n notice(),\n view.found.length > 0 ? h('ul', { class: 'found-list' }, ...view.found.map(foundRow)) : null,\n !view.isBusy && view.found.length === 0\n ? h('p', { class: 'empty' }, 'No adapter answered. A search only reaches adapters on the same network segment as Matterbridge: add the others by address below.')\n : null,\n h(\n 'details',\n { class: 'manual', open: !view.isBusy && view.found.length === 0 },\n h('summary', {}, \"Can't see your air conditioner?\"),\n h(\n 'p',\n { class: 'help' },\n 'Enter the address of its adapter. The plugin reads the name of the adapter there and follows it to a new address like any other, as long as a search can reach it. An adapter on another subnet or VLAN keeps this address.',\n ),\n h('div', { class: 'inline-form' }, h('label', { for: 'host', class: 'visually-hidden' }, 'Adapter address'), host, button('Look it up', lookUpHost)),\n ),\n h(\n 'div',\n { class: 'footer' },\n button('Search again', () => void search()),\n button('Cancel', goHome),\n button(continueLabel, () => startQueue(draftsFromAdapters(chosen)), 'primary', chosen.length === 0),\n ),\n ];\n}\n", "/**\n * @file apps/frontend/src/screens/home.ts\n * @description The home screen: the air conditioners that are set up, and the way to add more.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.1.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadState, removeDevice, search, startQueue } from '../actions.js';\nimport type { StoredDevice, SwitchedMode } from '../api.js';\nimport { button, notice } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { draftFromStored } from '../exposure.js';\nimport { render } from '../render.js';\nimport { view } from '../state.js';\n\nconst modeNames: Record<SwitchedMode, string> = { auto: 'auto mode', cool: 'cool mode', heat: 'heat mode', dehumidify: 'dry mode', fan: 'fan mode' };\n\nfunction describeExposure(device: StoredDevice): string {\n // What the unit cannot do is left out, whatever is stored for it. A unit the plugin has not asked yet is described as stored.\n const hasFan = device.controls === undefined || device.controls.fanSteps.length > 0;\n const hasSwing = device.controls === undefined || device.controls.hasSwing;\n const fanPlace = device.hasSeparateFan ? ' on a fan of its own' : '';\n const autoStep = { native: '', switch: '', firstStep: ' with auto first', lastStep: ' with auto last' }[device.fanAutoControl];\n const fan = device.fanControl === 'hidden' ? 'fan speed not shown' : `fan speed as ${device.fanControl === 'steps' ? 'steps' : 'a percentage'}${autoStep}${fanPlace}`;\n const swingAxes = { both: '', vertical: ' up and down', horizontal: ' left and right' }[device.swingAxes];\n const swing = { native: `swing as native rocking${swingAxes}`, switches: `swing as switches${swingAxes}`, select: 'swing as a mode select', hidden: 'swing not shown' }[\n device.swingControl\n ];\n const controls = [hasFan ? fan : '', hasSwing ? swing : ''].filter((text) => text !== '').join(', ');\n const modeSwitches = device.modeControl === 'switches' ? device.modeSwitches.map((mode) => modeNames[mode]) : [];\n // Such as \"dry mode as heat\".\n const replacements = (Object.keys(modeNames) as SwitchedMode[]).flatMap((mode) => {\n const replacement = device.modeReplacements[mode];\n return replacement === undefined ? [] : [`${modeNames[mode]} as ${modeNames[replacement].replace(' mode', '')}`];\n });\n const switches = [...modeSwitches, device.fanAutoControl === 'switch' ? 'auto fan' : '', ...device.specialModeSwitches].filter((name) => name !== '');\n const extra = [switches.length === 0 ? '' : `a switch for ${switches.join(', ')}`, device.modeControl === 'select' ? 'a mode select' : '', replacements.join(' and ')]\n .filter((text) => text !== '')\n .join(' and ');\n const place = device.isComposed ? ', all as one device' : '';\n if (controls === '') return `${extra === '' ? 'power, mode and temperature' : extra}${place}`;\n return `${extra === '' ? controls : `${controls}, and ${extra}`}${place}`;\n}\n\nfunction deviceRow(device: StoredDevice): HTMLElement {\n const statusText = { online: 'Online', offline: 'Not answering', stopped: 'Not started' }[device.status];\n const isConfirming = view.confirmingRemoval === device.macAddress;\n return h(\n 'li',\n { class: 'device' },\n h(\n 'div',\n { class: 'device-main' },\n h('h3', {}, device.name),\n h('p', { class: 'meta' }, h('span', { class: `status ${device.status}` }, statusText), ` at ${device.host}. In Matter: ${describeExposure(device)}.`),\n device.status !== 'online' && device.error ? h('p', { class: 'meta problem-text' }, device.error) : null,\n device.needsRestart\n ? h('p', { class: 'meta' }, h('strong', {}, 'Restart Matterbridge'), ' to apply the new options in Matter. Until then it keeps its current controls.')\n : null,\n ),\n isConfirming\n ? h(\n 'div',\n { class: 'actions' },\n h('span', { class: 'meta' }, 'Remove it from Matter too?'),\n button('Remove', () => void removeDevice(device), 'danger'),\n button('Keep', () => {\n view.confirmingRemoval = '';\n render();\n }),\n )\n : h(\n 'div',\n { class: 'actions' },\n // Either way the unit is asked first what it accepts now, so the options offered are the ones it has today.\n button(device.status === 'online' ? 'Options' : 'Reconnect', () => startQueue([draftFromStored(device)])),\n button('Remove', () => {\n view.confirmingRemoval = device.macAddress;\n render();\n }),\n ),\n );\n}\n\nexport function homeScreen(): Child[] {\n const devices = view.setup?.devices ?? [];\n return [\n h('header', {}, h('h1', {}, 'Daikin air conditioners'), view.setup ? button('Add air conditioners', () => void search(), 'primary') : null),\n notice(),\n devices.length === 0 && view.setup\n ? h('p', { class: 'empty' }, 'No air conditioner is set up yet. Add one to control it from Matter.')\n : h('ul', { class: 'devices' }, ...devices.map(deviceRow)),\n view.setup ? null : button('Try again', () => void loadState(), 'primary'),\n ];\n}\n", "/**\n * @file apps/frontend/src/screens/options.ts\n * @description The Options step: how the fan, the swing, the modes and the readings of a unit appear in Matter, one section each, and whether as one device.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { goHome, saveDraft } from '../actions.js';\nimport type { AvailableControls, Exposure, FanSpeed, ModeReplacements, SpecialMode, SwingMode, SwitchedMode } from '../api.js';\nimport { button, notice, steps, unitHeader, unitStrip } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { canReplace, fitModeReplacements, noControls } from '../exposure.js';\nimport { matchesPreset, presetExposure, type PresetName, presets } from '../presets.js';\nimport { render } from '../render.js';\nimport { currentDraft, type Draft } from '../state.js';\n\nconst fanSpeedLabels: Record<FanSpeed, string> = {\n auto: 'Auto',\n silent: 'Silent',\n level1: 'Level 1',\n level2: 'Level 2',\n level3: 'Level 3',\n level4: 'Level 4',\n level5: 'Level 5',\n};\n\nconst swingModeLabels: Record<SwingMode, string> = {\n off: 'No swing',\n vertical: 'Up and down',\n horizontal: 'Left and right',\n both: '3D swing',\n};\n\nconst modeLabels: Record<SwitchedMode, string> = { auto: 'Auto', cool: 'Cool', heat: 'Heat', dehumidify: 'Dry', fan: 'Fan' };\n\nconst specialModeTexts: Record<SpecialMode, { title: string; text: string }> = {\n powerful: { title: 'Powerful', text: 'Runs the unit at full power for a while.' },\n econo: { title: 'Econo', text: 'Limits how much power the unit draws.' },\n streamer: { title: 'Streamer', text: 'Runs the air purifying of the unit.' },\n heatPlus: { title: 'Heat Plus', text: 'The Heat Plus mode of the unit, which it takes in heat alone.' },\n};\n\n// Static drawings, so innerHTML is safe for them. Everything that comes from the network goes through text nodes.\nconst glyphs = {\n steps:\n '<svg viewBox=\"0 0 48 28\" aria-hidden=\"true\"><rect x=\"2\" y=\"20\" width=\"8\" height=\"6\"/><rect x=\"14\" y=\"14\" width=\"8\" height=\"12\"/><rect x=\"26\" y=\"8\" width=\"8\" height=\"18\"/><rect x=\"38\" y=\"2\" width=\"8\" height=\"24\"/></svg>',\n percent: '<svg viewBox=\"0 0 48 28\" aria-hidden=\"true\"><path d=\"M2 26 L46 2 L46 26 Z\"/></svg>',\n hidden: '<svg viewBox=\"0 0 48 28\" aria-hidden=\"true\"><path class=\"stroke\" d=\"M6 14 H42\" stroke-dasharray=\"3 5\"/></svg>',\n switches:\n '<svg viewBox=\"0 0 48 28\" aria-hidden=\"true\"><path class=\"stroke\" d=\"M12 4 V24 M7 9 L12 4 L17 9 M7 19 L12 24 L17 19\"/><path class=\"stroke\" d=\"M26 14 H46 M31 9 L26 14 L31 19 M41 9 L46 14 L41 19\"/></svg>',\n select: '<svg viewBox=\"0 0 48 28\" aria-hidden=\"true\"><rect class=\"stroke\" x=\"3\" y=\"5\" width=\"42\" height=\"18\" rx=\"4\"/><path class=\"stroke\" d=\"M31 12 L35 16 L39 12\"/></svg>',\n rocking: '<svg viewBox=\"0 0 48 28\" aria-hidden=\"true\"><path class=\"stroke\" d=\"M8 20 Q24 0 40 20\"/><path class=\"stroke\" d=\"M8 13 V20 H15 M40 13 V20 H33\"/></svg>',\n};\n\n// Home Assistant is the one app known to show a mode select.\nconst selectSupport = 'Few apps show a mode select: Home Assistant does, Apple Home does not.';\n\n// A part of the air conditioner has no name of its own in Matter: a switch or a mode select is tagged with what it is.\nfunction placement(draft: Draft, label: string, isTagged: boolean): string {\n if (!draft.isComposed) return `It appears as \"${draft.name} ${label}\"`;\n return isTagged ? `It appears as a part of \"${draft.name}\", tagged \"${label}\"` : `It appears as a part of \"${draft.name}\"`;\n}\n\nfunction update(draft: Draft, change: Partial<Exposure>): void {\n Object.assign(draft, change);\n render();\n}\n\nfunction choice<T extends string>(group: string, value: T, current: T, title: string, text: string, glyph: string, onpick: (value: T) => void): HTMLElement {\n const id = `${group}-${value}`;\n const input = h('input', { type: 'radio', name: group, id, checked: value === current, onchange: () => onpick(value) });\n return h(\n 'label',\n { class: 'choice pictured', for: id },\n input,\n h('span', { class: 'glyph', html: glyph }),\n h('span', {}, h('strong', {}, title), h('span', { class: 'meta' }, text)),\n );\n}\n\nfunction radio<T extends string>(group: string, value: T, current: T, title: string, text: string, onpick: (value: T) => void): HTMLElement {\n const id = `${group}-${value}`;\n const input = h('input', { type: 'radio', name: group, id, checked: value === current, onchange: () => onpick(value) });\n return h('label', { class: 'choice', for: id }, input, h('span', {}, h('strong', {}, title), h('span', { class: 'meta' }, text)));\n}\n\nfunction toggle(id: string, isOn: boolean, title: string, text: string, onpick: (isOn: boolean) => void): HTMLElement {\n const input = h('input', { type: 'checkbox', id, checked: isOn, onchange: () => onpick(input.checked) });\n return h('label', { class: 'choice', for: id }, input, h('span', {}, h('strong', {}, title), h('span', { class: 'meta' }, text)));\n}\n\n// A compact multi-select, one chip for each value: for a list that full sized choices would make too long.\nfunction chips<T extends string>(group: string, label: string, values: readonly T[], picked: readonly T[], labels: Record<T, string>, onpick: (picked: T[]) => void): HTMLElement {\n return h(\n 'div',\n { 'class': 'chips', 'role': 'group', 'aria-label': label },\n ...values.map((value) => {\n const id = `${group}-${value}`;\n const input = h('input', {\n type: 'checkbox',\n id,\n checked: picked.includes(value),\n onchange: () => onpick(values.filter((other) => (other === value ? input.checked : picked.includes(other)))),\n });\n return h('label', { class: 'chip', for: id }, input, labels[value]);\n }),\n );\n}\n\n// The air conditioner as its adapter tells it apart from the others: by the name of its Daikin app, then by its address.\nfunction adapterText(draft: Draft): string {\n const told = draft.adapter.name;\n const address = `at ${draft.adapter.host}`;\n return told === undefined || told === '' ? `the air conditioner ${address}` : `the air conditioner named \"${told}\" in its Daikin app, ${address}`;\n}\n\n// Redrawn as it is typed, so that the texts that name the device follow. A redraw when the field is left instead would\n// replace the button the click leaving it is on, and lose that click.\nfunction nameSection(draft: Draft): HTMLElement {\n const input = h('input', { type: 'text', id: 'device-name', value: draft.name, maxLength: 32, autocomplete: 'off', spellcheck: false });\n input.addEventListener('input', (event) => {\n draft.name = input.value.trim();\n // A redraw in the middle of a composition, such as of Japanese text, would end it.\n if (!(event as InputEvent).isComposing) render();\n });\n const told = draft.adapter.name;\n const toldText = told === undefined || told === '' ? 'Its adapter has no name of its own.' : `Its adapter is named \"${told}\" in its Daikin app, which other adapters can share.`;\n return h(\n 'section',\n {},\n h('h2', {}, h('label', { for: 'device-name' }, 'Name in Matter')),\n h(\n 'p',\n { class: 'help' },\n `${toldText} The name here is what your Matter apps show, up to 32 characters, and no two air conditioners of this plugin share one. A new name of the adapter does not change it.`,\n ),\n h('div', { class: 'inline-form' }, input),\n );\n}\n\nfunction presetSection(draft: Draft, controls: AvailableControls): HTMLElement {\n return h(\n 'section',\n { class: 'presets' },\n h('h2', {}, 'Start from a preset'),\n h(\n 'div',\n { class: 'preset-list' },\n ...(Object.keys(presets) as PresetName[]).map((name) =>\n h(\n 'button',\n { 'type': 'button', 'class': 'preset', 'aria-pressed': String(matchesPreset(draft, name, controls)), 'onclick': () => update(draft, presetExposure(name, controls)) },\n h('strong', {}, presets[name].title),\n h('span', { class: 'meta' }, presets[name].text),\n ),\n ),\n ),\n h('p', { class: 'help' }, 'A preset fills in the choices below for what this unit can do. Change any of them afterwards.'),\n );\n}\n\n// Such as \"Silent, Level 1 and Level 2\".\nfunction listSpeeds(speeds: readonly FanSpeed[]): string {\n const labels = speeds.map((speed) => fanSpeedLabels[speed]);\n return labels.length === 1 ? labels[0] : `${labels.slice(0, -1).join(', ')} and ${labels[labels.length - 1]}`;\n}\n\ntype FanAutoControl = Exposure['fanAutoControl'];\n\nfunction fanAutoSection(draft: Draft, controls: AvailableControls, current: FanAutoControl): Child {\n // A fixed fan speed is sent with every command, so auto would not hold.\n if (!controls.hasFanAuto || (draft.fanControl === 'hidden' && draft.fanSpeedWhenHidden !== 'keep')) return null;\n const pick = (fanAutoControl: FanAutoControl): void => update(draft, { fanAutoControl });\n const isFanHidden = draft.fanControl === 'hidden';\n const switchText = `${placement(draft, 'Auto Fan', true)}. On sets the fan to auto, off puts it back at the speed it last ran at.`;\n const slowest = fanSpeedLabels[controls.fanSteps[0]];\n const fastest = fanSpeedLabels[controls.fanSteps[controls.fanSteps.length - 1]];\n const choices = isFanHidden\n ? [\n radio('fan-auto', 'native', current, 'Not shown in Matter', 'Without a fan speed in Matter, auto has no place there either.', pick),\n radio('fan-auto', 'switch', current, 'A switch', switchText, pick),\n ]\n : [\n radio('fan-auto', 'native', current, 'Native fan mode only', 'Auto is a mode of the fan speed, beside its speeds, as Matter has it.', pick),\n radio('fan-auto', 'switch', current, 'A switch', `${switchText} Auto stays a fan mode as well.`, pick),\n radio('fan-auto', 'firstStep', current, 'The first step', `Auto comes below ${slowest}: step 1, or the bottom of the slider.`, pick),\n radio('fan-auto', 'lastStep', current, 'The last step', `Auto comes above ${fastest}: the top step, or 100 %.`, pick),\n ];\n return h(\n 'div',\n { class: 'field' },\n h('h3', { id: 'fan-auto-title' }, 'Auto fan speed'),\n isFanHidden ? null : h('p', { class: 'help' }, 'Matter has auto as a fan mode, which not every app shows. A switch makes it reachable there too, and a step takes its place.'),\n h('div', { 'class': 'choices', 'role': 'radiogroup', 'aria-labelledby': 'fan-auto-title' }, ...choices),\n );\n}\n\nfunction fanSection(draft: Draft, controls: AvailableControls): HTMLElement {\n const fanSpeeds = draft.capabilities?.fanSpeeds ?? [];\n const stepCount = controls.fanSteps.length;\n if (stepCount === 0)\n return h('section', {}, h('h2', {}, 'Fan speed'), h('p', { class: 'help' }, 'This unit does not let apps set its fan speed, so there is nothing to choose.'));\n const isFanHidden = draft.fanControl === 'hidden';\n // Auto is a step only of a fan control that is shown, and the step takes the place of the switch.\n const hasAutoStep = controls.hasFanAuto && !isFanHidden && (draft.fanAutoControl === 'firstStep' || draft.fanAutoControl === 'lastStep');\n const hasAutoSwitch = controls.hasFanAuto && draft.fanAutoControl === 'switch';\n let positions = controls.fanSteps;\n if (hasAutoStep) positions = draft.fanAutoControl === 'firstStep' ? ['auto', ...controls.fanSteps] : [...controls.fanSteps, 'auto'];\n // A step takes the place of the fan mode Auto.\n const hasAutoMode = controls.hasFanAuto && !hasAutoStep;\n const autoMode = hasAutoMode ? ' Auto is not among them: it is a fan mode of its own.' : '';\n // Such as \"6 speeds, slowest first: Silent, Level 1 \u2026 and Level 5. Auto is not among them: it is a fan mode of its own.\"\n const speedList = `${positions.length} ${positions.length === 1 ? 'speed' : 'speeds'}, ${hasAutoStep ? 'in order' : 'slowest first'}: ${listSpeeds(positions)}.${autoMode}`;\n return h(\n 'section',\n {},\n h('h2', {}, 'Fan speed'),\n h(\n 'div',\n { class: 'choices' },\n choice('fan', 'steps', draft.fanControl, 'Steps', speedList, glyphs.steps, (fanControl) => update(draft, { fanControl })),\n choice('fan', 'percent', draft.fanControl, 'Percentage', `A slider from 0 to 100, which the plugin rounds to the nearest of ${speedList}`, glyphs.percent, (fanControl) =>\n update(draft, { fanControl }),\n ),\n choice('fan', 'hidden', draft.fanControl, 'Not shown in Matter', 'No fan control. Pick below what the plugin does with the fan speed instead.', glyphs.hidden, (fanControl) =>\n update(draft, { fanControl }),\n ),\n ),\n draft.fanControl === 'hidden'\n ? h(\n 'div',\n { class: 'field' },\n h('label', { for: 'fan-fixed' }, 'When the plugin sends a command, the fan speed'),\n h(\n 'select',\n { id: 'fan-fixed', onchange: (event: Event) => update(draft, { fanSpeedWhenHidden: (event.target as HTMLSelectElement).value as Exposure['fanSpeedWhenHidden'] }) },\n h('option', { value: 'keep', selected: draft.fanSpeedWhenHidden === 'keep' }, 'stays as it is'),\n ...fanSpeeds.map((speed) => h('option', { value: speed, selected: draft.fanSpeedWhenHidden === speed }, `is set to ${fanSpeedLabels[speed]}`)),\n ),\n )\n : null,\n draft.fanControl === 'hidden'\n ? null\n : toggle(\n 'separate-fan',\n draft.hasSeparateFan,\n 'Show the fan as a device of its own',\n `${placement(draft, 'Fan', false)}, and the air conditioner has no fan speed of its own. For apps that show no fan speed on an air conditioner, or do not show it well. It always shows the speed the unit holds, also while the unit is off.`,\n (hasSeparateFan) => update(draft, { hasSeparateFan }),\n ),\n // A step of a fan that is hidden is no step.\n fanAutoSection(draft, controls, isFanHidden && !hasAutoSwitch ? 'native' : draft.fanAutoControl),\n );\n}\n\n// The swing is natively the rocking of the fan control, which a unit whose fan speed is not shown has none of.\nfunction swingSection(draft: Draft, controls: AvailableControls): HTMLElement {\n const { swingModes } = controls;\n if (swingModes.length === 0)\n return h('section', {}, h('h2', {}, 'Swing'), h('p', { class: 'help' }, 'This unit does not let apps move its louvers, so there is nothing to choose.'));\n const hasVertical = swingModes.includes('vertical');\n const hasHorizontal = swingModes.includes('horizontal');\n const hasRocking = draft.fanControl !== 'hidden' && controls.fanSteps.length > 0;\n const current = draft.swingControl === 'native' && !hasRocking ? 'switches' : draft.swingControl;\n const insteadOfRocking = hasRocking ? ' The fan control then has no rocking.' : '';\n let switchText = 'One switch, for the up and down swing.';\n if (hasVertical && hasHorizontal) switchText = 'Two switches: one for the up and down swing, one for left and right.';\n else if (hasHorizontal) switchText = 'One switch, for the left and right swing.';\n return h(\n 'section',\n {},\n h('h2', {}, 'Swing'),\n h(\n 'div',\n { class: 'choices' },\n hasRocking\n ? choice(\n 'swing',\n 'native',\n current,\n 'Native rocking',\n 'The rocking of the fan control, as Matter has it: up and down for the vertical swing, left and right for the horizontal. Not every app shows it, and Apple Home shows it as a single Oscillate on/off.',\n glyphs.rocking,\n (swingControl) => update(draft, { swingControl }),\n )\n : null,\n choice('swing', 'switches', current, 'Switches', `${switchText}${insteadOfRocking}`, glyphs.switches, (swingControl) => update(draft, { swingControl })),\n choice(\n 'swing',\n 'select',\n current,\n 'A mode select',\n `${placement(draft, 'Swing', true)}, and picks one of: ${swingModes.map((mode) => (mode === 'both' ? swingModeLabels[mode] : swingModeLabels[mode].toLowerCase())).join(', ')}.${insteadOfRocking} ${selectSupport}`,\n glyphs.select,\n (swingControl) => update(draft, { swingControl }),\n ),\n choice('swing', 'hidden', current, 'Not shown in Matter', 'No swing control. Pick below what the plugin does with the swing instead.', glyphs.hidden, (swingControl) =>\n update(draft, { swingControl }),\n ),\n ),\n // A switch is for an axis the unit swings on alone, and the rocking also for one it swings on with the other.\n (current === 'native' && controls.swingsOnBothAxes) || (current === 'switches' && hasVertical && hasHorizontal) ? swingAxesField(draft, current === 'native') : null,\n draft.swingControl === 'hidden'\n ? h(\n 'div',\n { class: 'field' },\n h('label', { for: 'swing-fixed' }, 'When the plugin sends a command, the swing'),\n h(\n 'select',\n { id: 'swing-fixed', onchange: (event: Event) => update(draft, { swingModeWhenHidden: (event.target as HTMLSelectElement).value as Exposure['swingModeWhenHidden'] }) },\n h('option', { value: 'keep', selected: draft.swingModeWhenHidden === 'keep' }, 'stays as it is'),\n ...swingModes.map((mode) => h('option', { value: mode, selected: draft.swingModeWhenHidden === mode }, `is set to: ${swingModeLabels[mode]}`)),\n ),\n )\n : null,\n );\n}\n\n// Apple Home shows the rocking as one Oscillate on/off, so one axis alone is what it turns on and off. One switch alone\n// is for whoever wants one axis in Matter and not the other.\nfunction swingAxesField(draft: Draft, isRocking: boolean): HTMLElement {\n const pick = (swingAxes: Exposure['swingAxes']): void => update(draft, { swingAxes });\n const otherAxis = 'The other axis has no control in Matter, and stays as it is.';\n const help = isRocking\n ? 'Some apps, such as Apple Home, show the rocking as a single Oscillate on/off. One axis alone makes that switch swing the louvers on it.'\n : 'One switch alone, for the axis picked, instead of a switch for each axis.';\n return h(\n 'div',\n { class: 'field' },\n h('h3', { id: 'swing-axes-title' }, isRocking ? 'Rocking axes' : 'Switch axes'),\n h('p', { class: 'help' }, help),\n h(\n 'div',\n { 'class': 'choices', 'role': 'radiogroup', 'aria-labelledby': 'swing-axes-title' },\n radio(\n 'swing-axes',\n 'both',\n draft.swingAxes,\n 'Both axes',\n isRocking ? 'Up and down, and left and right, each rocking on its own.' : 'A switch for up and down, and one for left and right.',\n pick,\n ),\n radio('swing-axes', 'vertical', draft.swingAxes, 'Up and down alone', otherAxis, pick),\n radio('swing-axes', 'horizontal', draft.swingAxes, 'Left and right alone', otherAxis, pick),\n ),\n );\n}\n\n// One row for each thermostat mode the unit lacks: which of its modes, if any, an app picking that mode runs.\nfunction replacementFields(draft: Draft, controls: AvailableControls): HTMLElement {\n const replacements = fitModeReplacements(draft.modeReplacements, controls);\n return h(\n 'div',\n { class: 'replacements' },\n ...controls.lackingModes.flatMap((shown) => {\n const id = `mode-replacement-${shown}`;\n const current = controls.switchableModes.find((mode) => replacements[mode] === shown);\n // What the other rows hold, which this one picks among.\n const others: ModeReplacements = Object.fromEntries(Object.entries(replacements).filter(([, replacement]) => replacement !== shown));\n const onchange = (event: Event): void => {\n const value = (event.target as HTMLSelectElement).value as SwitchedMode | '';\n const next: ModeReplacements = { ...others };\n if (value !== '') next[value] = shown;\n update(draft, { modeReplacements: fitModeReplacements(next, controls) });\n };\n return [\n h('label', { for: id }, modeLabels[shown]),\n h(\n 'select',\n { id, onchange },\n h('option', { value: '', selected: current === undefined }, 'is not offered'),\n ...controls.switchableModes.map((mode) =>\n h(\n 'option',\n { value: mode, selected: current === mode, disabled: others[mode] !== undefined || !canReplace(mode, shown, others, controls) },\n `runs ${modeLabels[mode].toLowerCase()}`,\n ),\n ),\n ),\n ];\n }),\n );\n}\n\nfunction modeSection(draft: Draft, controls: AvailableControls): Child {\n const { switchableModes, lackingModes } = controls;\n if (switchableModes.length === 0) return null;\n const modeSwitches = switchableModes.filter((mode) => draft.modeSwitches.includes(mode));\n const extraModes = switchableModes.filter((mode) => mode === 'dehumidify' || mode === 'fan');\n const hasSelect = extraModes.length > 0;\n // A mode select is only of use for a dry or a fan mode.\n const current = draft.modeControl === 'select' && !hasSelect ? 'native' : draft.modeControl;\n // Switches with none picked would add nothing, so picking them starts with one for each of dry and fan.\n const pick = (modeControl: Exposure['modeControl']): void => {\n if (modeControl === 'switches' && modeSwitches.length === 0) update(draft, { modeControl, modeSwitches: hasSelect ? extraModes : [...switchableModes] });\n else update(draft, { modeControl });\n };\n const fallback = switchableModes.includes('cool') ? 'cool' : 'heat';\n const extra = extraModes.map((mode) => modeLabels[mode].toLowerCase()).join(' and ');\n const switchOff = hasSelect ? `Off turns the unit off, or from ${extra} puts it back in ${fallback}.` : 'Off turns the unit off.';\n const example = `${modeLabels[modeSwitches.length > 0 ? modeSwitches[0] : switchableModes[0]]} Mode`;\n const switchPlace = draft.isComposed\n ? `Each appears as a part of \"${draft.name}\", tagged with its mode, such as \"${example}\".`\n : `Each appears as \"${draft.name} ${example}\", and so on.`;\n // Such as \"auto, dry or heat\".\n const lackingLabels = lackingModes.map((mode) => modeLabels[mode].toLowerCase());\n const lacking = lackingLabels.length === 1 ? lackingLabels[0] : `${lackingLabels.slice(0, -1).join(', ')} or ${lackingLabels[lackingLabels.length - 1]}`;\n return h(\n 'section',\n {},\n h('h2', {}, 'Modes'),\n h(\n 'p',\n { class: 'help' },\n 'Every mode of the unit is a mode of the air conditioner in Matter, but some apps, such as Apple Home and Google Home, only offer off, cool, heat and auto.',\n ),\n h(\n 'div',\n { 'class': 'choices', 'role': 'radiogroup', 'aria-label': 'Modes' },\n radio('mode-control', 'native', current, 'Native modes only', 'The modes of the unit are those of the air conditioner, as Matter has them, and nothing more is added.', pick),\n hasSelect\n ? radio(\n 'mode-control',\n 'select',\n current,\n 'A mode select',\n `${placement(draft, 'Mode', true)}, with Off and every mode of the unit, as the air conditioner has them. Picking a mode turns the unit on in it. ${selectSupport}`,\n pick,\n )\n : null,\n radio('mode-control', 'switches', current, 'Switches', `A switch for each mode picked below. On turns the unit on in that mode. ${switchOff}`, pick),\n current === 'switches'\n ? h(\n 'div',\n { class: 'sub' },\n chips('mode-switch', 'Modes that get a switch', switchableModes, modeSwitches, modeLabels, (picked) => update(draft, { modeSwitches: picked })),\n h('p', { class: 'help' }, switchPlace),\n )\n : null,\n ),\n // The replacements are on the thermostat, so they go with any of the choices above.\n lackingModes.length > 0\n ? h(\n 'div',\n { class: 'field' },\n h('h3', {}, 'Modes the unit lacks'),\n h(\n 'p',\n { class: 'help' },\n `This unit has no ${lacking}. Each can run one of its modes instead, such as heat running dry on a unit that only cools: an app then reaches that mode from the modes it offers, and nothing is added to Matter. The air conditioner shows the mode picked while the unit is in it, with its setpoint. Auto is offered once the air conditioner both cools and heats, counting these.`,\n ),\n replacementFields(draft, controls),\n )\n : null,\n );\n}\n\nfunction specialSection(draft: Draft, controls: AvailableControls): Child {\n if (controls.specialModes.length === 0) return null;\n return h(\n 'section',\n {},\n h('h2', {}, 'Special modes'),\n h(\n 'p',\n { class: 'help' },\n 'Matter has no control for these, so each can get a switch of its own. A switch only takes effect in the modes this unit offers that special mode in.',\n ),\n h(\n 'div',\n { class: 'choices' },\n ...controls.specialModes.map((mode) =>\n toggle(`special-${mode}`, draft.specialModeSwitches.includes(mode), `Add a switch for ${specialModeTexts[mode].title}`, specialModeTexts[mode].text, (isOn) =>\n update(draft, { specialModeSwitches: controls.specialModes.filter((other) => (other === mode ? isOn : draft.specialModeSwitches.includes(other))) }),\n ),\n ),\n ),\n );\n}\n\nfunction sensorSection(draft: Draft): HTMLElement {\n return h(\n 'section',\n {},\n h('h2', {}, 'Humidity and outdoor temperature'),\n h(\n 'p',\n { class: 'help' },\n 'No adapter says which readings its unit has, so each of these takes effect once the unit gives that reading. The room temperature and the humidity are always on the air conditioner.',\n ),\n h(\n 'div',\n { class: 'choices' },\n toggle(\n 'separate-humidity',\n draft.hasSeparateHumiditySensor,\n 'Also show the humidity on a sensor of its own',\n `${placement(draft, 'Humidity', false)}, and the air conditioner keeps its humidity. For apps that show no humidity on an air conditioner, which Apple Home is reported to be.`,\n (hasSeparateHumiditySensor) => update(draft, { hasSeparateHumiditySensor }),\n ),\n toggle(\n 'outdoor-sensor',\n draft.hasOutdoorTemperatureSensor,\n 'Add a sensor for the outdoor temperature',\n `It appears as \"${draft.name} Outdoor Temperature\". It is a device of its own, which you can put in another room, such as outside. Until you do, a Matter app may show the outdoor temperature as that of the room it put the sensor in. Some units give no outdoor temperature while they are idle: the sensor then shows no value.`,\n (hasOutdoorTemperatureSensor) => update(draft, { hasOutdoorTemperatureSensor }),\n ),\n ),\n );\n}\n\nfunction composedSection(draft: Draft): HTMLElement {\n return h(\n 'section',\n {},\n h('h2', {}, 'One device or several'),\n h(\n 'p',\n { class: 'help' },\n 'The switches, a fan of its own and a humidity sensor of its own can be parts of the air conditioner in Matter, or devices of their own beside it. The outdoor temperature sensor is always a device of its own, so that you can put it in another room than the air conditioner.',\n ),\n h(\n 'div',\n { class: 'choices' },\n toggle(\n 'composed',\n draft.isComposed,\n 'Make them parts of the air conditioner',\n `Your Matter app has one device, \"${draft.name}\", and they move between rooms with it. A part has no name of its own in Matter, so an app may show the switches as numbered outlets, and an app that shows no parts shows the air conditioner alone. Turned off, each is a device of its own with its own name, which your app puts in a room by itself.`,\n (isComposed) => update(draft, { isComposed }),\n ),\n ),\n );\n}\n\nexport function optionsScreen(): Child[] {\n const draft = currentDraft();\n if (draft === undefined) return [notice()];\n const controls = draft.controls ?? noControls;\n return [\n steps(),\n unitStrip(),\n unitHeader(draft, `Options for ${adapterText(draft)}. Power, mode and temperature always appear in Matter: choose how the rest appears.`),\n nameSection(draft),\n presetSection(draft, controls),\n fanSection(draft, controls),\n swingSection(draft, controls),\n modeSection(draft, controls),\n specialSection(draft, controls),\n sensorSection(draft),\n composedSection(draft),\n draft.isNew\n ? null\n : h(\n 'p',\n { class: 'help' },\n 'A change of any of these applies at the next restart of Matterbridge. A switch or a sensor you add is new in your Matter app, in its default room, and one you remove is gone.',\n ),\n notice(),\n h(\n 'div',\n { class: 'footer' },\n button('Cancel', goHome),\n button(draft.isNew ? `Add ${draft.name}` : 'Save options', () => void saveDraft(draft), 'primary'),\n ),\n ];\n}\n", "/**\n * @file apps/frontend/src/theme.ts\n * @description Makes the setup page look like the Matterbridge page it is shown in.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** Take the colours and the font of the Matterbridge page this one is shown in. */\nexport function adoptHostTheme(): void {\n try {\n if (window.parent === window) return;\n const host = getComputedStyle(window.parent.document.body);\n for (const name of ['--primary-color', '--div-bg-color', '--div-text-color', '--main-bg-color', '--main-label-color', '--div-border-color', '--main-light-color']) {\n const value = host.getPropertyValue(name).trim();\n if (value !== '') document.documentElement.style.setProperty(`--host${name.slice(1)}`, value);\n }\n document.documentElement.style.setProperty('--host-font', host.fontFamily);\n } catch {\n // Opened on its own or from another origin: the page keeps its own colours.\n }\n}\n", "/**\n * @file apps/frontend/src/app.ts\n * @description The guided setup page of the Matterbridge Daikin Local plugin. Matterbridge serves it at\n * /plugins/matterbridge-daikin-local/ and it talks to the plugin through api/<path> below that address.\n * This file starts the page: the rest is in the files next to it.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadState } from './actions.js';\nimport { h } from './dom.js';\nimport { render, setScreens } from './render.js';\nimport { connectScreen } from './screens/connect.js';\nimport { doneScreen } from './screens/done.js';\nimport { findScreen } from './screens/find.js';\nimport { homeScreen } from './screens/home.js';\nimport { optionsScreen } from './screens/options.js';\nimport { adoptHostTheme } from './theme.js';\n\nsetScreens({\n loading: () => [h('p', { class: 'notice working', role: 'status' }, h('span', { class: 'spinner' }), 'Loading\u2026')],\n home: homeScreen,\n find: findScreen,\n connect: connectScreen,\n options: optionsScreen,\n done: doneScreen,\n});\n\nadoptHostTheme();\nrender();\nvoid loadState();\n"],
|
|
5
|
-
"mappings": "AAwDA,eAAsBA,EAAqBC,EAAUC,EAAgBC,EAAmC,CACtG,GAAI,CACF,GAAM,CAACC,EAAQC,CAAI,EAAIJ,EAAM,MAAM,GAAG,EAChCK,EAAoB,CAAE,OAAAF,CAAO,EAC/BF,IAAS,SACXI,EAAK,QAAU,CAAE,eAAgB,kBAAmB,EACpDA,EAAK,KAAO,KAAK,UAAUJ,CAAI,GAEjC,IAAMK,EAAW,MAAM,MAAM,IAAI,IAAI,OAAOF,CAAI,GAAGF,IAAU,OAAY,GAAK,IAAIA,CAAK,EAAE,GAAI,SAAS,OAAO,EAAGG,CAAI,EACpH,GAAIC,EAAS,SAAW,IAAK,MAAO,CAAE,GAAI,EAAK,EAC/C,GAAIA,EAAS,SAAW,IAAK,MAAO,CAAE,GAAI,GAAO,MAAO,6EAA8E,EACtI,IAAMC,EAAS,MAAMD,EAAS,KAAK,EACnC,MAAI,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B,IAAG,CAAQ4G,GAAU5G,CAAK,GAAG,SAAS,CACnG,CACF,CACF,CC9iBO,SAAS6G,IAAuB,CACrC,GAAI,CACF,GAAI,OAAO,SAAW,OAAQ,OAC9B,IAAMC,EAAO,iBAAiB,OAAO,OAAO,SAAS,IAAI,EACzD,QAAWC,IAAQ,CAAC,kBAAmB,iBAAkB,mBAAoB,kBAAmB,qBAAsB,qBAAsB,oBAAoB,EAAG,CACjK,IAAMC,EAAQF,EAAK,iBAAiBC,CAAI,EAAE,KAAK,EAC3CC,IAAU,IAAI,SAAS,gBAAgB,MAAM,YAAY,SAASD,EAAK,MAAM,CAAC,CAAC,GAAIC,CAAK,CAC9F,CACA,SAAS,gBAAgB,MAAM,YAAY,cAAeF,EAAK,UAAU,CAC3E,MAAQ,CAER,CACF,CCDAG,GAAW,CACT,QAAS,IAAM,CAACC,EAAE,IAAK,CAAE,MAAO,iBAAkB,KAAM,QAAS,EAAGA,EAAE,OAAQ,CAAE,MAAO,SAAU,CAAC,EAAG,eAAU,CAAC,EAChH,KAAMC,GACN,KAAMC,GACN,QAASC,GACT,QAASC,GACT,KAAMC,EACR,CAAC,EAEDC,GAAe,EACfC,EAAO,EACFC,EAAU",
|
|
6
|
-
"names": ["api", "route", "body", "
|
|
4
|
+
"sourcesContent": ["/**\n * @file apps/frontend/src/api.ts\n * @description What the plugin's API sends and takes, and the call to it: see src/setup/setupApi.ts in the plugin.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.1.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DaikinCapabilities, DaikinDevice } from 'daikin-local-control';\n\nimport type { DaikinDeviceExposure } from '../../../src/config.js';\nimport type { DiscoveredDevice, SetupDevice, SetupReplies, SetupReply } from '../../../src/setup/setupApi.js';\n\n// The types are the plugin's own, so the page and the plugin cannot drift apart. They are only types: nothing of the\n// plugin is loaded in the browser. The page has its own words for some of them.\nexport type { FanSpeed, SpecialMode, SwingMode } from 'daikin-local-control';\nexport type { ModeReplacements, SwitchedMode } from '../../../src/config.js';\nexport type { AvailableControls } from '../../../src/controls.js';\nexport type { ProbeResult } from '../../../src/setup/probe.js';\nexport type { SetupState } from '../../../src/setup/setupApi.js';\n\nexport type Capabilities = DaikinCapabilities;\nexport type Adapter = DaikinDevice;\nexport type Exposure = DaikinDeviceExposure;\nexport type StoredDevice = SetupDevice;\nexport type FoundAdapter = DiscoveredDevice;\n\n/** A request the plugin serves, by its method and its path after `api/`. */\nexport type Route = keyof SetupReplies;\n\n/** The reply to a request, with what the plugin sends back when the request worked. */\nexport type Reply<R extends Route> = ({ ok: true } & SetupReplies[R]) | Extract<SetupReply, { ok: false }>;\n\n/**\n * Call the plugin\n *\n * Every request is a GET or a POST, so that every reply has a body that says whether it worked: Matterbridge answers\n * a DELETE with 204 and no body, whatever the plugin returns.\n *\n * @param {R} route The method and the path, such as `POST probe`.\n * @param {unknown} [body] The JSON body.\n * @returns {Promise<Reply<R>>} The reply, with `ok: false` and the reason when the call did not work.\n */\nexport async function api<R extends Route>(route: R, body?: unknown): Promise<Reply<R>> {\n try {\n const [method, path] = route.split(' ');\n const init: RequestInit = { method };\n if (body !== undefined) {\n init.headers = { 'Content-Type': 'application/json' };\n init.body = JSON.stringify(body);\n }\n const response = await fetch(new URL(`api/${path}`, document.baseURI), init);\n if (response.status === 503) return { ok: false, error: 'The plugin is not running. Start it in Matterbridge, then reload this page.' };\n const reply = (await response.json()) as Reply<R> | { error?: string };\n if ('ok' in reply) return reply;\n return { ok: false, error: reply.error ?? `The plugin answered with status ${response.status}` };\n } catch {\n return { ok: false, error: 'Matterbridge did not answer. Check that it is running, then try again.' };\n }\n}\n", "/**\n * @file apps/frontend/src/state.ts\n * @description What the setup page knows at any moment, and what it reads from that.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Adapter, AvailableControls, Capabilities, Exposure, FoundAdapter, ProbeResult, SetupState } from './api.js';\n\n/** One air conditioner on its way through Connect and Options. */\nexport interface Draft extends Exposure {\n adapter: Adapter;\n name: string;\n isNew: boolean;\n localPassword?: string;\n capabilities?: Capabilities;\n /** What the plugin says the unit leaves to choose in Options. */\n controls?: AvailableControls;\n probe?: ProbeResult;\n}\n\nexport type ScreenName = 'loading' | 'home' | 'find' | 'connect' | 'options' | 'done';\n\n/** The state of the page: which screen it shows, what the plugin told it, and the run through Connect and Options. */\nexport const view = {\n screen: 'loading' as ScreenName,\n setup: undefined as SetupState | undefined,\n found: [] as FoundAdapter[],\n selected: new Set<string>(),\n queue: [] as Draft[],\n saved: [] as string[],\n /** The units this run is done with, in the order it went through them. */\n handled: [] as { label: string; isSaved: boolean }[],\n isBusy: false,\n busyText: '',\n error: '',\n /** A note for the user that is no problem, such as what to do after a change. */\n info: '',\n confirmingRemoval: '',\n};\n\n/**\n * Get the air conditioner the run is on\n *\n * @returns {Draft | undefined} The draft, or undefined when no run is on.\n */\nexport function currentDraft(): Draft | undefined {\n return view.queue[0];\n}\n\n/**\n * Get what a unit is called on the page: its name, or its address until it has one\n *\n * @param {Draft} draft The unit.\n * @returns {string} The name or the address.\n */\nexport function draftLabel(draft: Draft): string {\n return draft.name === '' ? draft.adapter.host : draft.name;\n}\n\n/**\n * Tell whether an adapter is that of a stored device, which is known by its MAC address\n *\n * @param {Adapter} adapter The adapter.\n * @returns {boolean} Whether a stored device has it.\n */\nexport function isStored(adapter: Adapter): boolean {\n return (view.setup?.devices ?? []).some((device) => device.macAddress === adapter.macAddress);\n}\n", "/**\n * @file apps/frontend/src/exposure.ts\n * @description How a device appears in Matter: the choices a draft starts with.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Adapter, AvailableControls, Exposure, ModeReplacements, StoredDevice, SwitchedMode } from './api.js';\nimport { type Draft, view } from './state.js';\n\n/**\n * Copy the choices of how a device appears in Matter, and nothing else\n *\n * @param {Exposure} source What holds the choices, such as a draft or a stored device.\n * @returns {Exposure} The choices, with the lists and the replacements copied.\n */\nexport function pickExposure(source: Exposure): Exposure {\n const {\n fanControl,\n fanSpeedWhenHidden,\n swingControl,\n swingAxes,\n swingModeWhenHidden,\n modeControl,\n modeSwitches,\n modeReplacements,\n fanAutoControl,\n hasSeparateFan,\n specialModeSwitches,\n hasOutdoorTemperatureSensor,\n hasSeparateHumiditySensor,\n isComposed,\n } = source;\n return {\n fanControl,\n fanSpeedWhenHidden,\n swingControl,\n swingAxes,\n swingModeWhenHidden,\n modeControl,\n modeSwitches: [...modeSwitches],\n modeReplacements: { ...modeReplacements },\n fanAutoControl,\n hasSeparateFan,\n specialModeSwitches: [...specialModeSwitches],\n hasOutdoorTemperatureSensor,\n hasSeparateHumiditySensor,\n isComposed,\n };\n}\n\n// What a new device holds until the plugin says what its unit can do: it then takes the Apple Home preset. What a\n// stored device without a setting gets is the default of `parseDeviceConfig` in the plugin, which stands for how the\n// plugin behaved before that setting existed: the two may differ.\nconst defaultExposure: Exposure = {\n fanControl: 'steps',\n fanSpeedWhenHidden: 'keep',\n swingControl: 'switches',\n swingAxes: 'both',\n swingModeWhenHidden: 'keep',\n modeControl: 'native',\n modeSwitches: [],\n modeReplacements: {},\n fanAutoControl: 'native',\n hasSeparateFan: false,\n specialModeSwitches: [],\n hasOutdoorTemperatureSensor: false,\n hasSeparateHumiditySensor: false,\n isComposed: true,\n};\n\n/** The longest name Matter takes. */\nconst maxNameLength = 32;\n\n/**\n * Get a name no device has yet: the name the adapter tells, or that name with a number after it, such as \"Bedroom 2\"\n *\n * @param {string} base The name the adapter tells, or an empty string when it has not told one.\n * @param {ReadonlySet<string>} taken The names that are taken.\n * @returns {string} The name, of at most 32 characters, or the empty string it was given.\n */\nexport function uniqueName(base: string, taken: ReadonlySet<string>): string {\n if (base === '' || !taken.has(base)) return base;\n for (let count = 2; ; count++) {\n const suffix = ` ${count}`;\n const name = `${base.slice(0, maxNameLength - suffix.length).trimEnd()}${suffix}`;\n if (!taken.has(name)) return name;\n }\n}\n\n/**\n * Get the names a draft cannot take: those of the stored devices but its own, and those of the other drafts of the run\n *\n * @param {Draft} draft The draft.\n * @returns {Set<string>} The names.\n */\nexport function takenNames(draft: Draft): Set<string> {\n const stored = (view.setup?.devices ?? []).filter((device) => device.macAddress !== draft.adapter.macAddress).map((device) => device.name);\n const queued = view.queue.filter((other) => other !== draft).map((other) => other.name);\n return new Set([...stored, ...queued].filter((name) => name !== ''));\n}\n\n/**\n * Create the drafts of the adapters picked in the Find step, each named after its adapter\n *\n * Adapters can share a name, so each draft gets one no stored device and no draft before it has.\n *\n * @param {readonly Adapter[]} adapters The adapters.\n * @returns {Draft[]} The drafts, new, with the default choices until the plugin says what each unit can do.\n */\nexport function draftsFromAdapters(adapters: readonly Adapter[]): Draft[] {\n const taken = new Set((view.setup?.devices ?? []).map((device) => device.name));\n return adapters.map((adapter) => {\n const name = uniqueName(adapter.name ?? '', taken);\n if (name !== '') taken.add(name);\n return { adapter, name, isNew: true, ...pickExposure(defaultExposure) };\n });\n}\n\n/**\n * Create the draft of a stored device, for its options or for reconnecting it\n *\n * @param {StoredDevice} device The stored device.\n * @returns {Draft} The draft, with the choices the device is stored with.\n */\nexport function draftFromStored(device: StoredDevice): Draft {\n const { capabilities, controls, name, macAddress, host, protocol, requiresRegistration, usesHttps, requiresLocalPassword } = device;\n // The stored name is the one given in the setup page: the check in Connect reads the adapter's own.\n const adapter: Adapter = { host, protocol, macAddress, requiresRegistration, usesHttps, requiresLocalPassword };\n return { adapter, name, isNew: false, capabilities, controls, ...pickExposure(device) };\n}\n\n/** What a unit the plugin told nothing about can have: no control and no switch. */\nexport const noControls: AvailableControls = {\n fanSteps: [],\n hasFanAuto: false,\n hasSwing: false,\n swingModes: [],\n swingsOnBothAxes: false,\n switchableModes: [],\n lackingModes: [],\n specialModes: [],\n};\n\n/**\n * Tell whether a mode of the unit can be shown as a thermostat mode, given what its other modes are shown as\n *\n * It is as `getModeReplacements` in the plugin keeps it: only as a mode the unit lacks, no two as the same one, and as\n * Auto only on a thermostat that both cools and heats, counting the replacements, because Matter has Auto only with both.\n *\n * @param {SwitchedMode} mode The mode of the unit.\n * @param {SwitchedMode} replacement The thermostat mode to show it as.\n * @param {ModeReplacements} replacements What the other modes are shown as.\n * @param {AvailableControls} controls What the unit can do.\n * @returns {boolean} Whether the mode can be shown as that thermostat mode.\n */\nexport function canReplace(mode: SwitchedMode, replacement: SwitchedMode, replacements: ModeReplacements, controls: AvailableControls): boolean {\n if (!controls.switchableModes.includes(mode) || !controls.lackingModes.includes(replacement)) return false;\n const others = controls.switchableModes.filter((other) => other !== mode).map((other) => replacements[other]);\n if (others.includes(replacement)) return false;\n if (replacement !== 'auto') return true;\n const modes = new Set([...controls.switchableModes, ...others]);\n return modes.has('cool') && modes.has('heat');\n}\n\n/**\n * Keep the replacements the plugin keeps for a unit: those it can take\n *\n * @param {ModeReplacements} replacements The replacements chosen.\n * @param {AvailableControls} controls What the unit can do.\n * @returns {ModeReplacements} The replacements the unit can take.\n */\nexport function fitModeReplacements(replacements: ModeReplacements, controls: AvailableControls): ModeReplacements {\n const fitted: ModeReplacements = {};\n for (const mode of controls.switchableModes) {\n const replacement = replacements[mode];\n if (replacement !== undefined && canReplace(mode, replacement, replacements, controls)) fitted[mode] = replacement;\n }\n return fitted;\n}\n", "/**\n * @file apps/frontend/src/presets.ts\n * @description The presets of the Options step: each fills in the choices of how a device appears in Matter.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { AvailableControls, Exposure } from './api.js';\nimport { fitModeReplacements, pickExposure } from './exposure.js';\nimport type { Draft } from './state.js';\n\nexport type PresetName = 'apple' | 'google' | 'matter';\n\n/** The presets the Options step offers, each with its title and what it does. */\nexport const presets: Record<PresetName, { title: string; text: string }> = {\n apple: {\n title: 'Apple Home',\n text: 'Fan speed as a percentage, the swing as the rocking of the fan on one axis, the humidity on a sensor of its own too, and a switch for auto fan and for each of dry and fan, each a device of its own.',\n },\n google: {\n title: 'Google Home',\n text: 'Fan speed as steps, the swing as the rocking of the fan on one axis, the humidity on a sensor of its own too, and a switch for auto fan and for each of dry and fan, each a device of its own.',\n },\n matter: {\n title: 'Full Matter support',\n text: 'For apps that show every Matter control: fan speed as steps with its auto mode, the swing as the rocking of the fan, a switch for each special mode and the outdoor temperature, all as one device.',\n },\n};\n\n/**\n * Get the choices a preset makes for a unit: never a switch or a control the unit has no use for\n *\n * The Apple Home and the Google Home presets make the switches, a fan of its own and a humidity sensor of its own\n * devices of their own, and the Full Matter support preset makes them parts of the air conditioner.\n *\n * @param {PresetName} name The preset.\n * @param {AvailableControls} controls What the unit can do.\n * @returns {Exposure} The choices.\n */\nexport function presetExposure(name: PresetName, controls: AvailableControls): Exposure {\n const isMatter = name === 'matter';\n // An app that shows every Matter control gets the rocking of the fan control on every axis, or its switches on a unit\n // without a fan control. Home shows the rocking as a single Oscillate on/off, so it gets one axis alone, left and right\n // where the unit swings on both, and Google Home gets the same. Both leave the swing as it is on a unit without a fan\n // control, rather than add a switch for each axis.\n const hasRocking = controls.hasSwing && (isMatter || controls.fanSteps.length > 0);\n const swingControl: Exposure['swingControl'] = hasRocking ? 'native' : 'hidden';\n // Home and Google Home are reported to offer off, cool, heat and auto alone, so dry and fan get a switch each where\n // the unit has them.\n const modeSwitches = isMatter ? [] : controls.switchableModes.filter((mode) => mode === 'dehumidify' || mode === 'fan');\n return {\n fanControl: controls.fanSteps.length === 0 ? 'hidden' : name === 'apple' ? 'percent' : 'steps',\n fanSpeedWhenHidden: 'keep',\n swingControl,\n swingAxes: !isMatter && hasRocking && controls.swingsOnBothAxes ? 'horizontal' : 'both',\n swingModeWhenHidden: 'keep',\n // An app that shows every Matter control has dry and fan among the modes of the thermostat.\n modeControl: modeSwitches.length > 0 ? 'switches' : 'native',\n modeSwitches,\n modeReplacements: {},\n // Neither Home nor Google Home is known to show the auto fan mode, which the switch is beside.\n fanAutoControl: !isMatter && controls.hasFanAuto ? 'switch' : 'native',\n // No preset takes the fan off the air conditioner: that is for an app that shows no fan speed there.\n hasSeparateFan: false,\n // Matter has nothing for the special modes, so a switch is the one way to them.\n specialModeSwitches: isMatter ? [...controls.specialModes] : [],\n // An app may show the outdoor temperature as that of the room it puts the sensor in, until the sensor is moved.\n hasOutdoorTemperatureSensor: isMatter,\n // Home is reported to show a humidity on a sensor of its own only, and Google Home lists the humidity sensor among\n // what it supports but not the Room Air Conditioner. The humidity stays on the air conditioner too.\n hasSeparateHumiditySensor: !isMatter,\n // Home shows the parts of a composed device without their names. Google lists neither composed devices nor the\n // Room Air Conditioner among what Google Home supports, but says every device behind a bridge appears as normal.\n isComposed: isMatter,\n };\n}\n\n/**\n * Tell whether the choices in a draft are exactly those of a preset, leaving aside what the unit has no use for\n *\n * @param {Draft} draft The draft.\n * @param {PresetName} name The preset.\n * @param {AvailableControls} controls What the unit can do.\n * @returns {boolean} Whether the choices are those of the preset.\n */\nexport function matchesPreset(draft: Draft, name: PresetName, controls: AvailableControls): boolean {\n const chosen = pickExposure(draft);\n if (controls.fanSteps.length === 0) Object.assign(chosen, { fanControl: 'hidden', fanSpeedWhenHidden: 'keep' });\n // The choice shows nowhere while the fan is hidden.\n if (chosen.fanControl === 'hidden') chosen.hasSeparateFan = false;\n // Nor does the auto fan speed on a unit without one, a step of a hidden fan, or a switch beside a fixed fan speed.\n const isAutoStep = chosen.fanAutoControl === 'firstStep' || chosen.fanAutoControl === 'lastStep';\n const hasFixedFanSpeed = chosen.fanControl === 'hidden' && chosen.fanSpeedWhenHidden !== 'keep';\n if (!controls.hasFanAuto || (isAutoStep && chosen.fanControl === 'hidden') || hasFixedFanSpeed) chosen.fanAutoControl = 'native';\n if (!controls.hasSwing) Object.assign(chosen, { swingControl: 'hidden', swingModeWhenHidden: 'keep' });\n // Without a fan control, the rocking is the switches.\n if (chosen.fanControl === 'hidden' && chosen.swingControl === 'switches') chosen.swingControl = 'native';\n // The axes show only for the rocking or the switches of a unit that swings on both axes.\n if ((chosen.swingControl !== 'native' && chosen.swingControl !== 'switches') || !controls.swingsOnBothAxes) chosen.swingAxes = 'both';\n // The switches are a choice only while they are chosen, and both they and the replacements only for what the unit\n // has. A mode select shows nothing more than the thermostat on a unit without a dry or a fan mode.\n chosen.modeSwitches = chosen.modeControl === 'switches' ? controls.switchableModes.filter((mode) => chosen.modeSwitches.includes(mode)) : [];\n chosen.modeReplacements = fitModeReplacements(chosen.modeReplacements, controls);\n const isOfUse: Record<Exposure['modeControl'], boolean> = {\n native: true,\n select: controls.switchableModes.includes('dehumidify') || controls.switchableModes.includes('fan'),\n switches: chosen.modeSwitches.length > 0,\n };\n if (!isOfUse[chosen.modeControl]) chosen.modeControl = 'native';\n chosen.specialModeSwitches = controls.specialModes.filter((mode) => chosen.specialModeSwitches.includes(mode));\n return JSON.stringify(chosen) === JSON.stringify(presetExposure(name, controls));\n}\n", "/**\n * @file apps/frontend/src/render.ts\n * @description Draws the screen the setup page is on. The screens are handed in by app.ts, so that they and the\n * actions can call for a redraw without this file depending on them.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Child } from './dom.js';\nimport { currentDraft, type ScreenName, view } from './state.js';\n\nexport type Screens = Record<ScreenName, () => Child[]>;\n\nlet screens: Screens | undefined;\n\n/**\n * Tell the page what each screen draws\n *\n * @param {Screens} all What each screen draws, by its name.\n * @returns {void}\n */\nexport function setScreens(all: Screens): void {\n screens = all;\n}\n\n/**\n * Draw the current screen again, keeping what is being typed and where, when the same form redraws around it\n *\n * @returns {void}\n */\nexport function render(): void {\n const root = document.getElementById('app');\n if (root === null || screens === undefined) return;\n // Keep what the user is typing when the same form redraws around it, and never carry it over to another form.\n const form = `${view.screen}:${currentDraft()?.adapter.host ?? ''}`;\n const isSameForm = root.dataset.form === form;\n const active = document.activeElement;\n const activeId = active instanceof HTMLElement ? active.id : '';\n // Where the caret is in the field being typed in, so that a redraw while typing does not move it to the end.\n const caret =\n active instanceof HTMLInputElement && (active.type === 'text' || active.type === 'password') ? { start: active.selectionStart, end: active.selectionEnd } : undefined;\n const typed = new Map<string, string>();\n for (const input of root.querySelectorAll<HTMLInputElement>('input[type=text], input[type=password]')) {\n if (input.id !== '') typed.set(input.id, input.value);\n }\n root.replaceChildren(...screens[view.screen]().filter((child): child is Node | string => child !== false && child !== null && child !== undefined));\n root.dataset.form = form;\n if (!isSameForm) return;\n for (const [id, value] of typed) {\n const input = document.getElementById(id);\n if (input instanceof HTMLInputElement) input.value = value;\n }\n if (activeId === '') return;\n const focused = document.getElementById(activeId);\n focused?.focus();\n if (caret !== undefined && focused instanceof HTMLInputElement) focused.setSelectionRange(caret.start, caret.end);\n}\n", "/**\n * @file apps/frontend/src/actions.ts\n * @description What the setup page does: each action calls the plugin, changes the state of the page and redraws it.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.2.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { api, type StoredDevice } from './api.js';\nimport { pickExposure, takenNames, uniqueName } from './exposure.js';\nimport { presetExposure } from './presets.js';\nimport { render } from './render.js';\nimport { currentDraft, type Draft, draftLabel, isStored, view } from './state.js';\n\n/**\n * Run a call while the page shows that it is working\n *\n * @param {string} text What the page says meanwhile.\n * @param {() => Promise<T>} task The call.\n * @returns {Promise<T>} What the call returned.\n */\nasync function busy<T>(text: string, task: () => Promise<T>): Promise<T> {\n view.isBusy = true;\n view.busyText = text;\n view.error = '';\n view.info = '';\n render();\n try {\n return await task();\n } finally {\n view.isBusy = false;\n render();\n }\n}\n\n/**\n * Read the stored devices from the plugin and show the home screen, or go straight to the search when none is set up yet\n *\n * @returns {Promise<void>} Resolves once the page is drawn.\n */\nexport async function loadState(): Promise<void> {\n const reply = await api('GET state');\n if (!reply.ok) {\n view.error = reply.error;\n view.screen = 'home';\n render();\n return;\n }\n view.setup = reply.state;\n // With nothing set up yet, the page goes straight to finding the air conditioners.\n if (reply.state.devices.length === 0) {\n await search();\n return;\n }\n view.screen = 'home';\n render();\n}\n\n/**\n * Read the stored devices from the plugin again, keeping those the page has when the plugin does not answer\n *\n * @returns {Promise<void>} Resolves once the state is read.\n */\nasync function refreshState(): Promise<void> {\n const reply = await api('GET state');\n if (reply.ok) view.setup = reply.state;\n}\n\n/**\n * Go back to the home screen, dropping the run in progress, and read the stored devices again\n *\n * @returns {void}\n */\nexport function goHome(): void {\n view.queue = [];\n view.saved = [];\n view.handled = [];\n view.error = '';\n view.info = '';\n view.screen = 'home';\n void refreshState().then(render);\n render();\n}\n\n/**\n * Search the network for adapters and show them in the Find step, with the new ones selected\n *\n * @returns {Promise<void>} Resolves once the adapters are shown.\n */\nexport async function search(): Promise<void> {\n view.screen = 'find';\n const reply = await busy('Searching your network. This takes about three seconds\u2026', async () => api('POST discover'));\n if (!reply.ok) {\n view.error = `The search did not run: ${reply.error}`;\n render();\n return;\n }\n // Keep the adapters added by address: a search does not find them. One of them may have been set up since.\n await refreshState();\n const byAddress = view.found\n .filter((adapter) => !reply.devices.some((device) => device.host === adapter.host) && view.selected.has(adapter.host))\n .map((adapter) => ({ ...adapter, isConfigured: isStored(adapter) }));\n view.found = [...reply.devices, ...byAddress];\n for (const adapter of reply.devices) {\n if (!adapter.isConfigured) view.selected.add(adapter.host);\n }\n render();\n}\n\n/**\n * Look up an adapter by its address and add it to the Find step, selected unless it is set up already\n *\n * @param {string} host The IP address or the host name of the adapter.\n * @returns {Promise<void>} Resolves once the adapter is shown, or the reason it was not.\n */\nexport async function lookUp(host: string): Promise<void> {\n const reply = await busy(`Looking for an adapter at ${host}\u2026`, async () => api('POST identify', { host }));\n if (!reply.ok) {\n view.error = reply.error;\n render();\n return;\n }\n const isConfigured = isStored(reply.device);\n // Whether the adapter knows this plugin already shows in the Connect step: an address alone does not tell.\n const needsRegistration = reply.device.requiresRegistration === true;\n view.found = [...view.found.filter((adapter) => adapter.host !== reply.device.host), { ...reply.device, isConfigured, needsRegistration }];\n if (!isConfigured) view.selected.add(reply.device.host);\n render();\n}\n\n/**\n * Start a run through Connect and Options for one or more air conditioners\n *\n * @param {Draft[]} drafts The air conditioners, in the order the run takes them.\n * @returns {void}\n */\nexport function startQueue(drafts: Draft[]): void {\n view.queue = drafts;\n view.saved = [];\n view.handled = [];\n void enterConnect();\n}\n\n/**\n * Show the Connect step for the next air conditioner of the run, or end the run when there is none left\n *\n * @returns {Promise<void>} Resolves once the next step is shown.\n */\nasync function enterConnect(): Promise<void> {\n const draft = currentDraft();\n if (draft === undefined) {\n view.screen = view.saved.length > 0 ? 'done' : 'home';\n await refreshState();\n render();\n return;\n }\n view.screen = 'connect';\n view.error = '';\n view.info = '';\n draft.probe = undefined;\n render();\n await check(draft);\n}\n\n/**\n * Check that the adapter of an air conditioner answers, registering with it when a KEY is given, and go on to the\n * Options step once it is ready\n *\n * @param {Draft} draft The air conditioner.\n * @param {string} [key] The KEY printed on the adapter, for an adapter that asks for a registration.\n * @returns {Promise<void>} Resolves once the answer is shown.\n */\nexport async function check(draft: Draft, key?: string): Promise<void> {\n // The adapter as it announced itself: an adapter whose name is not known yet is asked for it.\n const body = { device: draft.adapter, localPassword: draft.localPassword, key };\n const text = key === undefined ? `Checking ${draftLabel(draft)}\u2026` : `Registering with ${draftLabel(draft)}\u2026`;\n const reply = await busy(text, async () => api(key === undefined ? 'POST probe' : 'POST register', body));\n if (!reply.ok) {\n view.error = reply.error;\n render();\n return;\n }\n draft.probe = reply.result;\n draft.adapter = reply.result.device;\n if (reply.result.status === 'ready') {\n const isFirstReading = draft.controls === undefined;\n draft.capabilities = reply.result.capabilities;\n draft.controls = reply.result.controls;\n // A new unit starts with the Apple Home preset, once what it can do is known. A later check, such as after a\n // registration, keeps what was chosen since.\n if (draft.isNew && isFirstReading && draft.controls !== undefined) Object.assign(draft, presetExposure('apple', draft.controls));\n // A unit that has no name yet starts with the one its adapter tells, which is its own from then on.\n const told = reply.result.device.name ?? '';\n if (draft.name === '' && told !== '') draft.name = uniqueName(told, takenNames(draft));\n view.screen = 'options';\n }\n render();\n}\n\n/**\n * Leave the current air conditioner of the run out and go on to the next\n *\n * @returns {void}\n */\nexport function skipDraft(): void {\n const skipped = view.queue.shift();\n if (skipped !== undefined) view.handled.push({ label: draftLabel(skipped), isSaved: false });\n void enterConnect();\n}\n\n/**\n * Store an air conditioner with its options and go on to the next of the run\n *\n * @param {Draft} draft The air conditioner, with its name and its options chosen.\n * @returns {Promise<void>} Resolves once the next step is shown, or the reason the device was not stored.\n */\nexport async function saveDraft(draft: Draft): Promise<void> {\n const name = draft.name.trim();\n const problem = checkName(draft, name);\n if (problem !== '') {\n view.error = problem;\n render();\n return;\n }\n const { adapter, localPassword } = draft;\n const device = { ...adapter, name, localPassword, ...pickExposure(draft) };\n const reply = await busy(`Saving ${name}\u2026`, async () => api('POST device', { device }));\n if (!reply.ok) {\n view.error = reply.error;\n render();\n return;\n }\n view.setup = reply.state;\n view.saved.push(name);\n view.handled.push({ label: name, isSaved: true });\n view.queue.shift();\n await enterConnect();\n}\n\n/**\n * Get what is wrong with the name of a draft: the plugin refuses a name another device has\n *\n * @param {Draft} draft The air conditioner.\n * @param {string} name The name, trimmed.\n * @returns {string} What is wrong, in words the page can show, or nothing.\n */\nfunction checkName(draft: Draft, name: string): string {\n if (name === '') return 'Give the air conditioner a name: it is the name it gets in Matter.';\n const isTaken = (view.setup?.devices ?? []).some((device) => device.name === name && device.macAddress !== draft.adapter.macAddress);\n return isTaken ? `\"${name}\" is already the name of another air conditioner. Pick a different one.` : '';\n}\n\n/** Matterbridge does not tell its own page when a plugin adds or removes a device, so its device list waits for a reload. */\nexport const reloadNote = \"Matterbridge's own list of devices shows the change once you reload its page.\";\n\n/** A change of how an air conditioner appears in Matter waits for a restart, which the plugin asks Matterbridge for as well. */\nexport const restartNote = 'Restart Matterbridge to apply the new options in Matter: until then the air conditioner keeps its current controls.';\n\n/**\n * Remove a stored air conditioner from the plugin and from Matter\n *\n * @param {StoredDevice} device The air conditioner.\n * @returns {Promise<void>} Resolves once the result is shown.\n */\nexport async function removeDevice(device: StoredDevice): Promise<void> {\n const reply = await busy(`Removing ${device.name}\u2026`, async () => api('POST remove-device', { macAddress: device.macAddress }));\n view.confirmingRemoval = '';\n if (reply.ok) view.info = `${device.name} is removed. ${reloadNote}`;\n else view.error = reply.error;\n await refreshState();\n render();\n}\n", "/**\n * @file apps/frontend/src/dom.ts\n * @description The one helper the setup page builds its elements with.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type Child = Node | string | false | null | undefined;\n\n/**\n * Create an element\n *\n * @param {K} tag The tag name.\n * @param {Record<string, unknown>} [props] `class`, `on<event>` listeners, and anything else as a property when the element has it, else an attribute.\n * @param {...Child} children Nodes or text; false, null and undefined are skipped.\n * @returns {HTMLElementTagNameMap[K]} The element.\n */\nexport function h<K extends keyof HTMLElementTagNameMap>(tag: K, props: Record<string, unknown> = {}, ...children: Child[]): HTMLElementTagNameMap[K] {\n const element = document.createElement(tag);\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined || value === false) continue;\n if (key === 'class') element.className = String(value);\n else if (key === 'html') element.innerHTML = String(value);\n else if (key.startsWith('on') && typeof value === 'function') element.addEventListener(key.slice(2), value as EventListener);\n else if (key in element) (element as unknown as Record<string, unknown>)[key] = value;\n else element.setAttribute(key, String(value));\n }\n for (const child of children) {\n if (child !== false && child !== null && child !== undefined) element.append(child);\n }\n return element;\n}\n", "/**\n * @file apps/frontend/src/components.ts\n * @description The pieces more than one screen of the setup page is made of.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Child, h } from './dom.js';\nimport { currentDraft, type Draft, draftLabel, type ScreenName, view } from './state.js';\n\n/**\n * Create a button, disabled while the page is busy\n *\n * @param {string} label What the button says.\n * @param {() => void} onclick What a click does.\n * @param {'primary' | 'quiet' | 'danger'} [kind] How the button looks: `quiet` unless given.\n * @param {boolean} [disabled] Whether the button is disabled besides.\n * @returns {HTMLButtonElement} The button.\n */\nexport function button(label: string, onclick: () => void, kind: 'primary' | 'quiet' | 'danger' = 'quiet', disabled = false): HTMLButtonElement {\n return h('button', { type: 'button', class: `button ${kind}`, onclick, disabled: disabled || view.isBusy }, label);\n}\n\n/**\n * Create the notice of the page: what it is busy with, else the problem, else the note for the user\n *\n * @returns {Child} The notice, or nothing when there is none.\n */\nexport function notice(): Child {\n if (view.isBusy) return h('p', { class: 'notice working', role: 'status' }, h('span', { class: 'spinner' }), view.busyText);\n if (view.error !== '') return h('p', { class: 'notice problem', role: 'alert' }, view.error);\n if (view.info !== '') return h('p', { class: 'notice', role: 'status' }, view.info);\n return null;\n}\n\n/**\n * Create the strip of the units of this run, with the one the page is on marked: shown when a run sets up more than\n * one, so that it is plain which unit the Connect and Options steps are about\n *\n * @returns {Child} The strip, or nothing for a run of one unit or of a stored one.\n */\nexport function unitStrip(): Child {\n const current = currentDraft();\n if (current === undefined || !current.isNew || view.handled.length + view.queue.length < 2) return null;\n const doing = view.screen === 'connect' ? 'Connecting' : 'Choosing options';\n return h(\n 'ol',\n { 'class': 'units', 'aria-label': 'Air conditioners in this setup' },\n ...view.handled.map((unit) =>\n h('li', { class: unit.isSaved ? 'done' : 'skipped' }, h('strong', {}, unit.label), h('span', { class: 'meta' }, unit.isSaved ? 'Added' : 'Skipped')),\n ),\n ...view.queue.map((draft, index) =>\n h(\n 'li',\n { 'class': index === 0 ? 'current' : 'ahead', 'aria-current': index === 0 ? 'true' : undefined },\n h('strong', {}, draftLabel(draft)),\n h('span', { class: 'meta' }, index === 0 ? doing : 'Waiting'),\n ),\n ),\n );\n}\n\n/**\n * Create the heading of a step that is about one unit: the unit first, then what the step does with it\n *\n * @param {Draft} draft The unit.\n * @param {string} text What the step does with it.\n * @returns {HTMLElement} The heading.\n */\nexport function unitHeader(draft: Draft, text: string): HTMLElement {\n return h('header', { class: 'unit-header' }, h('h1', {}, draftLabel(draft)), h('p', { class: 'meta' }, text));\n}\n\n/**\n * Create the list of the steps of adding air conditioners, with the current one marked\n *\n * @returns {Child} The list, or nothing for a run that is about stored units alone.\n */\nexport function steps(): Child {\n if (view.queue.length > 0 && !view.queue.some((draft) => draft.isNew)) return null;\n const names = ['Find', 'Connect', 'Options'];\n const screens: ScreenName[] = ['find', 'connect', 'options'];\n const current = screens.indexOf(view.screen);\n return h(\n 'ol',\n { class: 'steps' },\n ...names.map((name, index) => {\n let state = 'ahead';\n if (index < current) state = 'done';\n else if (index === current) state = 'current';\n return h('li', { 'class': state, 'aria-current': index === current ? 'step' : undefined }, name);\n }),\n );\n}\n", "/**\n * @file apps/frontend/src/screens/connect.ts\n * @description The Connect step: the page checks an adapter and asks for what the adapter wants before it answers.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { check, goHome, skipDraft } from '../actions.js';\nimport { button, notice, steps, unitHeader, unitStrip } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { currentDraft, type Draft, view } from '../state.js';\n\nfunction lockCodeForm(draft: Draft, isRejected: boolean): HTMLElement {\n const code = h('input', { type: 'password', id: 'lock-code', inputMode: 'numeric', autocomplete: 'off', maxLength: 64 });\n return h(\n 'div',\n { class: 'field' },\n h('label', { for: 'lock-code' }, 'Child lock code'),\n h('p', { class: 'help' }, 'The 4-digit code set under Child lock in the Daikin app the adapter was set up with. It is not printed on the adapter.'),\n isRejected ? h('p', { class: 'problem-text' }, 'The adapter did not accept that code.') : null,\n h(\n 'div',\n { class: 'inline-form' },\n code,\n button(\n 'Check the code',\n () => {\n if (code.value === '') return;\n draft.localPassword = code.value;\n void check(draft);\n },\n 'primary',\n ),\n ),\n );\n}\n\nfunction keyForm(draft: Draft, isRejected: boolean): HTMLElement {\n const key = h('input', { type: 'text', id: 'adapter-key', autocomplete: 'off', spellcheck: false, maxLength: 64 });\n return h(\n 'div',\n { class: 'field' },\n h('label', { for: 'adapter-key' }, 'KEY on the adapter'),\n h(\n 'p',\n { class: 'help' },\n 'This adapter only answers apps it has registered. The KEY is printed on its label, next to the SSID, and in the operation manual. It is used once and not stored.',\n ),\n isRejected ? h('p', { class: 'problem-text' }, 'The adapter did not accept that KEY.') : null,\n h(\n 'div',\n { class: 'inline-form' },\n key,\n button(\n 'Register',\n () => {\n if (key.value.trim() !== '') void check(draft, key.value.trim());\n },\n 'primary',\n ),\n ),\n );\n}\n\n/**\n * Create the form for what the adapter wants before the page can go on, or the notice of why the page cannot\n *\n * @param {Draft} draft The unit being connected.\n * @returns {Child} The form or the notice, or nothing while the check has no answer.\n */\nfunction credentialForm(draft: Draft): Child {\n const status = draft.probe?.status;\n if (status === 'localPasswordRequired' || status === 'localPasswordRejected') return lockCodeForm(draft, status === 'localPasswordRejected');\n if (status === 'registrationRequired' || status === 'registrationRejected') return keyForm(draft, status === 'registrationRejected');\n if (status === 'unreachable') {\n return h(\n 'p',\n { class: 'notice problem', role: 'alert' },\n `${draft.name} did not answer at ${draft.adapter.host}. Check that it has power and is on the network, then try again.`,\n );\n }\n if (status === 'failed') return h('p', { class: 'notice problem', role: 'alert' }, `${draft.name} answered with an error: ${draft.probe?.message ?? 'unknown'}`);\n return null;\n}\n\n/**\n * Draw the Connect step: the check of the adapter of the current unit, and what it asks for\n *\n * @returns {Child[]} The contents of the screen.\n */\nexport function connectScreen(): Child[] {\n const draft = currentDraft();\n if (draft === undefined) return [notice()];\n const canRetry = draft.probe?.status === 'unreachable' || draft.probe?.status === 'failed' || view.error !== '';\n return [\n steps(),\n unitStrip(),\n unitHeader(draft, `Connecting to its adapter at ${draft.adapter.host}.`),\n notice(),\n view.isBusy ? null : credentialForm(draft),\n h(\n 'div',\n { class: 'footer' },\n canRetry ? button('Try again', () => void check(draft)) : null,\n button(draft.isNew && view.queue.length > 1 ? 'Skip this one' : 'Cancel', draft.isNew && view.queue.length > 1 ? skipDraft : goHome),\n ),\n ];\n}\n", "/**\n * @file apps/frontend/src/screens/done.ts\n * @description The screen a run ends on: what it set up.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.1.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { goHome, reloadNote, restartNote } from '../actions.js';\nimport { button } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { view } from '../state.js';\n\n/**\n * Draw the Done step: which air conditioners the run set up, and what to do next\n *\n * @returns {Child[]} The contents of the screen.\n */\nexport function doneScreen(): Child[] {\n const names = view.saved;\n const needsRestart = (view.setup?.devices ?? []).some((device) => names.includes(device.name) && device.needsRestart);\n return [\n h('header', {}, h('h1', {}, names.length === 1 ? `${names[0]} is set up` : `${names.length} air conditioners are set up`)),\n h('p', { class: 'lead' }, 'They now appear in the Matter apps paired with Matterbridge. If Matterbridge is not paired yet, pair it from its home page.'),\n needsRestart ? h('p', { class: 'help' }, h('strong', {}, restartNote)) : null,\n h('p', { class: 'help' }, reloadNote),\n h('div', { class: 'footer' }, button('Done', goHome, 'primary')),\n ];\n}\n", "/**\n * @file apps/frontend/src/screens/find.ts\n * @description The Find step: the adapters a search found or an address led to, and which of them to set up.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { goHome, lookUp, search, startQueue } from '../actions.js';\nimport type { FoundAdapter } from '../api.js';\nimport { button, notice, steps } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { draftsFromAdapters } from '../exposure.js';\nimport { render } from '../render.js';\nimport { view } from '../state.js';\n\nfunction foundRow(adapter: FoundAdapter): HTMLElement {\n const isSelectable = !adapter.isConfigured;\n const notes: string[] = [];\n if (adapter.isConfigured) notes.push('Already set up.');\n if (adapter.name === undefined) notes.push('It has not told its name yet: you will name it in its options.');\n if (isSelectable && adapter.needsRegistration) notes.push('Asks for the KEY printed on its label.');\n else if (isSelectable && adapter.requiresRegistration) notes.push('Already registered with this plugin, so it will not ask for its KEY.');\n if (isSelectable && adapter.requiresLocalPassword) notes.push('Asks for its child lock code.');\n const checkbox = h('input', {\n type: 'checkbox',\n id: `found-${adapter.host}`,\n checked: isSelectable && view.selected.has(adapter.host),\n disabled: !isSelectable,\n onchange: () => {\n if (checkbox.checked) view.selected.add(adapter.host);\n else view.selected.delete(adapter.host);\n render();\n },\n });\n return h(\n 'li',\n { class: isSelectable ? 'found' : 'found unavailable' },\n h(\n 'label',\n { for: `found-${adapter.host}` },\n checkbox,\n h(\n 'span',\n {},\n h('strong', {}, adapter.name ?? 'Unnamed adapter'),\n h('span', { class: 'meta' }, ` ${adapter.host}`),\n ...notes.map((note) => h('span', { class: 'meta note' }, note)),\n ),\n ),\n );\n}\n\n/**\n * Draw the Find step: the adapters found on the network, and a field to add one by its address\n *\n * @returns {Child[]} The contents of the screen.\n */\nexport function findScreen(): Child[] {\n const chosen = view.found.filter((adapter) => view.selected.has(adapter.host) && !adapter.isConfigured);\n const host = h('input', { type: 'text', id: 'host', placeholder: '192.168.1.50', spellcheck: false, autocomplete: 'off' });\n const lookUpHost = (): void => {\n if (host.value.trim() !== '') void lookUp(host.value.trim());\n };\n host.addEventListener('keydown', (event) => {\n if (event.key === 'Enter') lookUpHost();\n });\n const continueLabel = chosen.length === 1 ? 'Set up 1 air conditioner' : `Set up ${chosen.length} air conditioners`;\n return [\n steps(),\n h('header', {}, h('h1', {}, 'Find your air conditioners')),\n notice(),\n view.found.length > 0 ? h('ul', { class: 'found-list' }, ...view.found.map(foundRow)) : null,\n !view.isBusy && view.found.length === 0\n ? h('p', { class: 'empty' }, 'No adapter answered. A search only reaches adapters on the same network segment as Matterbridge: add the others by address below.')\n : null,\n h(\n 'details',\n { class: 'manual', open: !view.isBusy && view.found.length === 0 },\n h('summary', {}, \"Can't see your air conditioner?\"),\n h(\n 'p',\n { class: 'help' },\n 'Enter the address of its adapter. The plugin reads the name of the adapter there and follows it to a new address like any other, as long as a search can reach it. An adapter on another subnet or VLAN keeps this address.',\n ),\n h('div', { class: 'inline-form' }, h('label', { for: 'host', class: 'visually-hidden' }, 'Adapter address'), host, button('Look it up', lookUpHost)),\n ),\n h(\n 'div',\n { class: 'footer' },\n button('Search again', () => void search()),\n button('Cancel', goHome),\n button(continueLabel, () => startQueue(draftsFromAdapters(chosen)), 'primary', chosen.length === 0),\n ),\n ];\n}\n", "/**\n * @file apps/frontend/src/screens/home.ts\n * @description The home screen: the air conditioners that are set up, and the way to add more.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.1.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadState, removeDevice, search, startQueue } from '../actions.js';\nimport type { StoredDevice, SwitchedMode } from '../api.js';\nimport { button, notice } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { draftFromStored } from '../exposure.js';\nimport { render } from '../render.js';\nimport { view } from '../state.js';\n\nconst modeNames: Record<SwitchedMode, string> = { auto: 'auto mode', cool: 'cool mode', heat: 'heat mode', dehumidify: 'dry mode', fan: 'fan mode' };\n\nfunction describeExposure(device: StoredDevice): string {\n // What the unit cannot do is left out, whatever is stored for it. A unit the plugin has not asked yet is described as stored.\n const hasFan = device.controls === undefined || device.controls.fanSteps.length > 0;\n const hasSwing = device.controls === undefined || device.controls.hasSwing;\n const fanPlace = device.hasSeparateFan ? ' on a fan of its own' : '';\n const autoStep = { native: '', switch: '', firstStep: ' with auto first', lastStep: ' with auto last' }[device.fanAutoControl];\n const fan = device.fanControl === 'hidden' ? 'fan speed not shown' : `fan speed as ${device.fanControl === 'steps' ? 'steps' : 'a percentage'}${autoStep}${fanPlace}`;\n const swingAxes = { both: '', vertical: ' up and down', horizontal: ' left and right' }[device.swingAxes];\n const swing = { native: `swing as native rocking${swingAxes}`, switches: `swing as switches${swingAxes}`, select: 'swing as a mode select', hidden: 'swing not shown' }[\n device.swingControl\n ];\n const controls = [hasFan ? fan : '', hasSwing ? swing : ''].filter((text) => text !== '').join(', ');\n const modeSwitches = device.modeControl === 'switches' ? device.modeSwitches.map((mode) => modeNames[mode]) : [];\n // Such as \"dry mode as heat\".\n const replacements = (Object.keys(modeNames) as SwitchedMode[]).flatMap((mode) => {\n const replacement = device.modeReplacements[mode];\n return replacement === undefined ? [] : [`${modeNames[mode]} as ${modeNames[replacement].replace(' mode', '')}`];\n });\n const switches = [...modeSwitches, device.fanAutoControl === 'switch' ? 'auto fan' : '', ...device.specialModeSwitches].filter((name) => name !== '');\n const extra = [switches.length === 0 ? '' : `a switch for ${switches.join(', ')}`, device.modeControl === 'select' ? 'a mode select' : '', replacements.join(' and ')]\n .filter((text) => text !== '')\n .join(' and ');\n const place = device.isComposed ? ', all as one device' : '';\n if (controls === '') return `${extra === '' ? 'power, mode and temperature' : extra}${place}`;\n return `${extra === '' ? controls : `${controls}, and ${extra}`}${place}`;\n}\n\nfunction deviceRow(device: StoredDevice): HTMLElement {\n const statusText = { online: 'Online', offline: 'Not answering', stopped: 'Not started' }[device.status];\n const isConfirming = view.confirmingRemoval === device.macAddress;\n return h(\n 'li',\n { class: 'device' },\n h(\n 'div',\n { class: 'device-main' },\n h('h3', {}, device.name),\n h('p', { class: 'meta' }, h('span', { class: `status ${device.status}` }, statusText), ` at ${device.host}. In Matter: ${describeExposure(device)}.`),\n device.status !== 'online' && device.error ? h('p', { class: 'meta problem-text' }, device.error) : null,\n device.needsRestart\n ? h('p', { class: 'meta' }, h('strong', {}, 'Restart Matterbridge'), ' to apply the new options in Matter. Until then it keeps its current controls.')\n : null,\n ),\n isConfirming\n ? h(\n 'div',\n { class: 'actions' },\n h('span', { class: 'meta' }, 'Remove it from Matter too?'),\n button('Remove', () => void removeDevice(device), 'danger'),\n button('Keep', () => {\n view.confirmingRemoval = '';\n render();\n }),\n )\n : h(\n 'div',\n { class: 'actions' },\n // Either way the unit is asked first what it accepts now, so the options offered are the ones it has today.\n button(device.status === 'online' ? 'Options' : 'Reconnect', () => startQueue([draftFromStored(device)])),\n button('Remove', () => {\n view.confirmingRemoval = device.macAddress;\n render();\n }),\n ),\n );\n}\n\n/**\n * Draw the home screen: the stored air conditioners, each with how it is doing and how it appears in Matter\n *\n * @returns {Child[]} The contents of the screen.\n */\nexport function homeScreen(): Child[] {\n const devices = view.setup?.devices ?? [];\n return [\n h('header', {}, h('h1', {}, 'Daikin air conditioners'), view.setup ? button('Add air conditioners', () => void search(), 'primary') : null),\n notice(),\n devices.length === 0 && view.setup\n ? h('p', { class: 'empty' }, 'No air conditioner is set up yet. Add one to control it from Matter.')\n : h('ul', { class: 'devices' }, ...devices.map(deviceRow)),\n view.setup ? null : button('Try again', () => void loadState(), 'primary'),\n ];\n}\n", "/**\n * @file apps/frontend/src/screens/options.ts\n * @description The Options step: how the fan, the swing, the modes and the readings of a unit appear in Matter, one section each, and whether as one device.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { goHome, saveDraft } from '../actions.js';\nimport type { AvailableControls, Exposure, FanSpeed, ModeReplacements, SpecialMode, SwingMode, SwitchedMode } from '../api.js';\nimport { button, notice, steps, unitHeader, unitStrip } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { canReplace, fitModeReplacements, noControls } from '../exposure.js';\nimport { matchesPreset, presetExposure, type PresetName, presets } from '../presets.js';\nimport { render } from '../render.js';\nimport { currentDraft, type Draft } from '../state.js';\n\nconst fanSpeedLabels: Record<FanSpeed, string> = {\n auto: 'Auto',\n silent: 'Silent',\n level1: 'Level 1',\n level2: 'Level 2',\n level3: 'Level 3',\n level4: 'Level 4',\n level5: 'Level 5',\n};\n\nconst swingModeLabels: Record<SwingMode, string> = {\n off: 'No swing',\n vertical: 'Up and down',\n horizontal: 'Left and right',\n both: '3D swing',\n};\n\nconst modeLabels: Record<SwitchedMode, string> = { auto: 'Auto', cool: 'Cool', heat: 'Heat', dehumidify: 'Dry', fan: 'Fan' };\n\nconst specialModeTexts: Record<SpecialMode, { title: string; text: string }> = {\n powerful: { title: 'Powerful', text: 'Runs the unit at full power for a while.' },\n econo: { title: 'Econo', text: 'Limits how much power the unit draws.' },\n streamer: { title: 'Streamer', text: 'Runs the air purifying of the unit.' },\n heatPlus: { title: 'Heat Plus', text: 'The Heat Plus mode of the unit, which it takes in heat alone.' },\n};\n\n// Static drawings, so innerHTML is safe for them. Everything that comes from the network goes through text nodes.\nconst glyphs = {\n steps:\n '<svg viewBox=\"0 0 48 28\" aria-hidden=\"true\"><rect x=\"2\" y=\"20\" width=\"8\" height=\"6\"/><rect x=\"14\" y=\"14\" width=\"8\" height=\"12\"/><rect x=\"26\" y=\"8\" width=\"8\" height=\"18\"/><rect x=\"38\" y=\"2\" width=\"8\" height=\"24\"/></svg>',\n percent: '<svg viewBox=\"0 0 48 28\" aria-hidden=\"true\"><path d=\"M2 26 L46 2 L46 26 Z\"/></svg>',\n hidden: '<svg viewBox=\"0 0 48 28\" aria-hidden=\"true\"><path class=\"stroke\" d=\"M6 14 H42\" stroke-dasharray=\"3 5\"/></svg>',\n switches:\n '<svg viewBox=\"0 0 48 28\" aria-hidden=\"true\"><path class=\"stroke\" d=\"M12 4 V24 M7 9 L12 4 L17 9 M7 19 L12 24 L17 19\"/><path class=\"stroke\" d=\"M26 14 H46 M31 9 L26 14 L31 19 M41 9 L46 14 L41 19\"/></svg>',\n select: '<svg viewBox=\"0 0 48 28\" aria-hidden=\"true\"><rect class=\"stroke\" x=\"3\" y=\"5\" width=\"42\" height=\"18\" rx=\"4\"/><path class=\"stroke\" d=\"M31 12 L35 16 L39 12\"/></svg>',\n rocking: '<svg viewBox=\"0 0 48 28\" aria-hidden=\"true\"><path class=\"stroke\" d=\"M8 20 Q24 0 40 20\"/><path class=\"stroke\" d=\"M8 13 V20 H15 M40 13 V20 H33\"/></svg>',\n};\n\n// Home Assistant is the one app known to show a mode select.\nconst selectSupport = 'Few apps show a mode select: Home Assistant does, Apple Home does not.';\n\n// A part of the air conditioner has no name of its own in Matter: a switch or a mode select is tagged with what it is.\nfunction placement(draft: Draft, label: string, isTagged: boolean): string {\n if (!draft.isComposed) return `It appears as \"${draft.name} ${label}\"`;\n return isTagged ? `It appears as a part of \"${draft.name}\", tagged \"${label}\"` : `It appears as a part of \"${draft.name}\"`;\n}\n\nfunction update(draft: Draft, change: Partial<Exposure>): void {\n Object.assign(draft, change);\n render();\n}\n\nfunction choice<T extends string>(group: string, value: T, current: T, title: string, text: string, glyph: string, onpick: (value: T) => void): HTMLElement {\n const id = `${group}-${value}`;\n const input = h('input', { type: 'radio', name: group, id, checked: value === current, onchange: () => onpick(value) });\n return h(\n 'label',\n { class: 'choice pictured', for: id },\n input,\n h('span', { class: 'glyph', html: glyph }),\n h('span', {}, h('strong', {}, title), h('span', { class: 'meta' }, text)),\n );\n}\n\nfunction radio<T extends string>(group: string, value: T, current: T, title: string, text: string, onpick: (value: T) => void): HTMLElement {\n const id = `${group}-${value}`;\n const input = h('input', { type: 'radio', name: group, id, checked: value === current, onchange: () => onpick(value) });\n return h('label', { class: 'choice', for: id }, input, h('span', {}, h('strong', {}, title), h('span', { class: 'meta' }, text)));\n}\n\nfunction toggle(id: string, isOn: boolean, title: string, text: string, onpick: (isOn: boolean) => void): HTMLElement {\n const input = h('input', { type: 'checkbox', id, checked: isOn, onchange: () => onpick(input.checked) });\n return h('label', { class: 'choice', for: id }, input, h('span', {}, h('strong', {}, title), h('span', { class: 'meta' }, text)));\n}\n\n// A compact multi-select, one chip for each value: for a list that full sized choices would make too long.\nfunction chips<T extends string>(group: string, label: string, values: readonly T[], picked: readonly T[], labels: Record<T, string>, onpick: (picked: T[]) => void): HTMLElement {\n return h(\n 'div',\n { 'class': 'chips', 'role': 'group', 'aria-label': label },\n ...values.map((value) => {\n const id = `${group}-${value}`;\n const input = h('input', {\n type: 'checkbox',\n id,\n checked: picked.includes(value),\n onchange: () => onpick(values.filter((other) => (other === value ? input.checked : picked.includes(other)))),\n });\n return h('label', { class: 'chip', for: id }, input, labels[value]);\n }),\n );\n}\n\n// The air conditioner as its adapter tells it apart from the others: by the name of its Daikin app, then by its address.\nfunction adapterText(draft: Draft): string {\n const told = draft.adapter.name;\n const address = `at ${draft.adapter.host}`;\n return told === undefined || told === '' ? `the air conditioner ${address}` : `the air conditioner named \"${told}\" in its Daikin app, ${address}`;\n}\n\n// Redrawn as it is typed, so that the texts that name the device follow. A redraw when the field is left instead would\n// replace the button the click leaving it is on, and lose that click.\nfunction nameSection(draft: Draft): HTMLElement {\n const input = h('input', { type: 'text', id: 'device-name', value: draft.name, maxLength: 32, autocomplete: 'off', spellcheck: false });\n input.addEventListener('input', (event) => {\n draft.name = input.value.trim();\n // A redraw in the middle of a composition, such as of Japanese text, would end it.\n if (!(event as InputEvent).isComposing) render();\n });\n const told = draft.adapter.name;\n const toldText = told === undefined || told === '' ? 'Its adapter has no name of its own.' : `Its adapter is named \"${told}\" in its Daikin app, which other adapters can share.`;\n return h(\n 'section',\n {},\n h('h2', {}, h('label', { for: 'device-name' }, 'Name in Matter')),\n h(\n 'p',\n { class: 'help' },\n `${toldText} The name here is what your Matter apps show, up to 32 characters, and no two air conditioners of this plugin share one. A new name of the adapter does not change it.`,\n ),\n h('div', { class: 'inline-form' }, input),\n );\n}\n\nfunction presetSection(draft: Draft, controls: AvailableControls): HTMLElement {\n return h(\n 'section',\n { class: 'presets' },\n h('h2', {}, 'Start from a preset'),\n h(\n 'div',\n { class: 'preset-list' },\n ...(Object.keys(presets) as PresetName[]).map((name) =>\n h(\n 'button',\n { 'type': 'button', 'class': 'preset', 'aria-pressed': String(matchesPreset(draft, name, controls)), 'onclick': () => update(draft, presetExposure(name, controls)) },\n h('strong', {}, presets[name].title),\n h('span', { class: 'meta' }, presets[name].text),\n ),\n ),\n ),\n h('p', { class: 'help' }, 'A preset fills in the choices below for what this unit can do. Change any of them afterwards.'),\n );\n}\n\n// Such as \"Silent, Level 1 and Level 2\".\nfunction listSpeeds(speeds: readonly FanSpeed[]): string {\n const labels = speeds.map((speed) => fanSpeedLabels[speed]);\n return labels.length === 1 ? labels[0] : `${labels.slice(0, -1).join(', ')} and ${labels[labels.length - 1]}`;\n}\n\ntype FanAutoControl = Exposure['fanAutoControl'];\n\nfunction fanAutoSection(draft: Draft, controls: AvailableControls, current: FanAutoControl): Child {\n // A fixed fan speed is sent with every command, so auto would not hold.\n if (!controls.hasFanAuto || (draft.fanControl === 'hidden' && draft.fanSpeedWhenHidden !== 'keep')) return null;\n const pick = (fanAutoControl: FanAutoControl): void => update(draft, { fanAutoControl });\n const isFanHidden = draft.fanControl === 'hidden';\n const switchText = `${placement(draft, 'Auto Fan', true)}. On sets the fan to auto, off puts it back at the speed it last ran at.`;\n const slowest = fanSpeedLabels[controls.fanSteps[0]];\n const fastest = fanSpeedLabels[controls.fanSteps[controls.fanSteps.length - 1]];\n const choices = isFanHidden\n ? [\n radio('fan-auto', 'native', current, 'Not shown in Matter', 'Without a fan speed in Matter, auto has no place there either.', pick),\n radio('fan-auto', 'switch', current, 'A switch', switchText, pick),\n ]\n : [\n radio('fan-auto', 'native', current, 'Native fan mode only', 'Auto is a mode of the fan speed, beside its speeds, as Matter has it.', pick),\n radio('fan-auto', 'switch', current, 'A switch', `${switchText} Auto stays a fan mode as well.`, pick),\n radio('fan-auto', 'firstStep', current, 'The first step', `Auto comes below ${slowest}: step 1, or the bottom of the slider.`, pick),\n radio('fan-auto', 'lastStep', current, 'The last step', `Auto comes above ${fastest}: the top step, or 100 %.`, pick),\n ];\n return h(\n 'div',\n { class: 'field' },\n h('h3', { id: 'fan-auto-title' }, 'Auto fan speed'),\n isFanHidden ? null : h('p', { class: 'help' }, 'Matter has auto as a fan mode, which not every app shows. A switch makes it reachable there too, and a step takes its place.'),\n h('div', { 'class': 'choices', 'role': 'radiogroup', 'aria-labelledby': 'fan-auto-title' }, ...choices),\n );\n}\n\nfunction fanSection(draft: Draft, controls: AvailableControls): HTMLElement {\n const fanSpeeds = draft.capabilities?.fanSpeeds ?? [];\n const stepCount = controls.fanSteps.length;\n if (stepCount === 0)\n return h('section', {}, h('h2', {}, 'Fan speed'), h('p', { class: 'help' }, 'This unit does not let apps set its fan speed, so there is nothing to choose.'));\n const isFanHidden = draft.fanControl === 'hidden';\n // Auto is a step only of a fan control that is shown, and the step takes the place of the switch.\n const hasAutoStep = controls.hasFanAuto && !isFanHidden && (draft.fanAutoControl === 'firstStep' || draft.fanAutoControl === 'lastStep');\n const hasAutoSwitch = controls.hasFanAuto && draft.fanAutoControl === 'switch';\n let positions = controls.fanSteps;\n if (hasAutoStep) positions = draft.fanAutoControl === 'firstStep' ? ['auto', ...controls.fanSteps] : [...controls.fanSteps, 'auto'];\n // A step takes the place of the fan mode Auto.\n const hasAutoMode = controls.hasFanAuto && !hasAutoStep;\n const autoMode = hasAutoMode ? ' Auto is not among them: it is a fan mode of its own.' : '';\n // Such as \"6 speeds, slowest first: Silent, Level 1 \u2026 and Level 5. Auto is not among them: it is a fan mode of its own.\"\n const speedList = `${positions.length} ${positions.length === 1 ? 'speed' : 'speeds'}, ${hasAutoStep ? 'in order' : 'slowest first'}: ${listSpeeds(positions)}.${autoMode}`;\n return h(\n 'section',\n {},\n h('h2', {}, 'Fan speed'),\n h(\n 'div',\n { class: 'choices' },\n choice('fan', 'steps', draft.fanControl, 'Steps', speedList, glyphs.steps, (fanControl) => update(draft, { fanControl })),\n choice('fan', 'percent', draft.fanControl, 'Percentage', `A slider from 0 to 100, which the plugin rounds to the nearest of ${speedList}`, glyphs.percent, (fanControl) =>\n update(draft, { fanControl }),\n ),\n choice('fan', 'hidden', draft.fanControl, 'Not shown in Matter', 'No fan control. Pick below what the plugin does with the fan speed instead.', glyphs.hidden, (fanControl) =>\n update(draft, { fanControl }),\n ),\n ),\n draft.fanControl === 'hidden'\n ? h(\n 'div',\n { class: 'field' },\n h('label', { for: 'fan-fixed' }, 'When the plugin sends a command, the fan speed'),\n h(\n 'select',\n { id: 'fan-fixed', onchange: (event: Event) => update(draft, { fanSpeedWhenHidden: (event.target as HTMLSelectElement).value as Exposure['fanSpeedWhenHidden'] }) },\n h('option', { value: 'keep', selected: draft.fanSpeedWhenHidden === 'keep' }, 'stays as it is'),\n ...fanSpeeds.map((speed) => h('option', { value: speed, selected: draft.fanSpeedWhenHidden === speed }, `is set to ${fanSpeedLabels[speed]}`)),\n ),\n )\n : null,\n draft.fanControl === 'hidden'\n ? null\n : toggle(\n 'separate-fan',\n draft.hasSeparateFan,\n 'Show the fan as a device of its own',\n `${placement(draft, 'Fan', false)}, and the air conditioner has no fan speed of its own. For apps that show no fan speed on an air conditioner, or do not show it well. It always shows the speed the unit holds, also while the unit is off.`,\n (hasSeparateFan) => update(draft, { hasSeparateFan }),\n ),\n // A step of a fan that is hidden is no step.\n fanAutoSection(draft, controls, isFanHidden && !hasAutoSwitch ? 'native' : draft.fanAutoControl),\n );\n}\n\n// The swing is natively the rocking of the fan control, which a unit whose fan speed is not shown has none of.\nfunction swingSection(draft: Draft, controls: AvailableControls): HTMLElement {\n const { swingModes } = controls;\n if (swingModes.length === 0)\n return h('section', {}, h('h2', {}, 'Swing'), h('p', { class: 'help' }, 'This unit does not let apps move its louvers, so there is nothing to choose.'));\n const hasVertical = swingModes.includes('vertical');\n const hasHorizontal = swingModes.includes('horizontal');\n const hasRocking = draft.fanControl !== 'hidden' && controls.fanSteps.length > 0;\n const current = draft.swingControl === 'native' && !hasRocking ? 'switches' : draft.swingControl;\n const insteadOfRocking = hasRocking ? ' The fan control then has no rocking.' : '';\n let switchText = 'One switch, for the up and down swing.';\n if (hasVertical && hasHorizontal) switchText = 'Two switches: one for the up and down swing, one for left and right.';\n else if (hasHorizontal) switchText = 'One switch, for the left and right swing.';\n return h(\n 'section',\n {},\n h('h2', {}, 'Swing'),\n h(\n 'div',\n { class: 'choices' },\n hasRocking\n ? choice(\n 'swing',\n 'native',\n current,\n 'Native rocking',\n 'The rocking of the fan control, as Matter has it: up and down for the vertical swing, left and right for the horizontal. Not every app shows it, and Apple Home shows it as a single Oscillate on/off.',\n glyphs.rocking,\n (swingControl) => update(draft, { swingControl }),\n )\n : null,\n choice('swing', 'switches', current, 'Switches', `${switchText}${insteadOfRocking}`, glyphs.switches, (swingControl) => update(draft, { swingControl })),\n choice(\n 'swing',\n 'select',\n current,\n 'A mode select',\n `${placement(draft, 'Swing', true)}, and picks one of: ${swingModes.map((mode) => (mode === 'both' ? swingModeLabels[mode] : swingModeLabels[mode].toLowerCase())).join(', ')}.${insteadOfRocking} ${selectSupport}`,\n glyphs.select,\n (swingControl) => update(draft, { swingControl }),\n ),\n choice('swing', 'hidden', current, 'Not shown in Matter', 'No swing control. Pick below what the plugin does with the swing instead.', glyphs.hidden, (swingControl) =>\n update(draft, { swingControl }),\n ),\n ),\n // A switch is for an axis the unit swings on alone, and the rocking also for one it swings on with the other.\n (current === 'native' && controls.swingsOnBothAxes) || (current === 'switches' && hasVertical && hasHorizontal) ? swingAxesField(draft, current === 'native') : null,\n draft.swingControl === 'hidden'\n ? h(\n 'div',\n { class: 'field' },\n h('label', { for: 'swing-fixed' }, 'When the plugin sends a command, the swing'),\n h(\n 'select',\n { id: 'swing-fixed', onchange: (event: Event) => update(draft, { swingModeWhenHidden: (event.target as HTMLSelectElement).value as Exposure['swingModeWhenHidden'] }) },\n h('option', { value: 'keep', selected: draft.swingModeWhenHidden === 'keep' }, 'stays as it is'),\n ...swingModes.map((mode) => h('option', { value: mode, selected: draft.swingModeWhenHidden === mode }, `is set to: ${swingModeLabels[mode]}`)),\n ),\n )\n : null,\n );\n}\n\n// Apple Home shows the rocking as one Oscillate on/off, so one axis alone is what it turns on and off. One switch alone\n// is for whoever wants one axis in Matter and not the other.\nfunction swingAxesField(draft: Draft, isRocking: boolean): HTMLElement {\n const pick = (swingAxes: Exposure['swingAxes']): void => update(draft, { swingAxes });\n const otherAxis = 'The other axis has no control in Matter, and stays as it is.';\n const help = isRocking\n ? 'Some apps, such as Apple Home, show the rocking as a single Oscillate on/off. One axis alone makes that switch swing the louvers on it.'\n : 'One switch alone, for the axis picked, instead of a switch for each axis.';\n return h(\n 'div',\n { class: 'field' },\n h('h3', { id: 'swing-axes-title' }, isRocking ? 'Rocking axes' : 'Switch axes'),\n h('p', { class: 'help' }, help),\n h(\n 'div',\n { 'class': 'choices', 'role': 'radiogroup', 'aria-labelledby': 'swing-axes-title' },\n radio(\n 'swing-axes',\n 'both',\n draft.swingAxes,\n 'Both axes',\n isRocking ? 'Up and down, and left and right, each rocking on its own.' : 'A switch for up and down, and one for left and right.',\n pick,\n ),\n radio('swing-axes', 'vertical', draft.swingAxes, 'Up and down alone', otherAxis, pick),\n radio('swing-axes', 'horizontal', draft.swingAxes, 'Left and right alone', otherAxis, pick),\n ),\n );\n}\n\n// One row for each thermostat mode the unit lacks: which of its modes, if any, an app picking that mode runs.\nfunction replacementFields(draft: Draft, controls: AvailableControls): HTMLElement {\n const replacements = fitModeReplacements(draft.modeReplacements, controls);\n return h(\n 'div',\n { class: 'replacements' },\n ...controls.lackingModes.flatMap((shown) => {\n const id = `mode-replacement-${shown}`;\n const current = controls.switchableModes.find((mode) => replacements[mode] === shown);\n // What the other rows hold, which this one picks among.\n const others: ModeReplacements = Object.fromEntries(Object.entries(replacements).filter(([, replacement]) => replacement !== shown));\n const onchange = (event: Event): void => {\n const value = (event.target as HTMLSelectElement).value as SwitchedMode | '';\n const next: ModeReplacements = { ...others };\n if (value !== '') next[value] = shown;\n update(draft, { modeReplacements: fitModeReplacements(next, controls) });\n };\n return [\n h('label', { for: id }, modeLabels[shown]),\n h(\n 'select',\n { id, onchange },\n h('option', { value: '', selected: current === undefined }, 'is not offered'),\n ...controls.switchableModes.map((mode) =>\n h(\n 'option',\n { value: mode, selected: current === mode, disabled: others[mode] !== undefined || !canReplace(mode, shown, others, controls) },\n `runs ${modeLabels[mode].toLowerCase()}`,\n ),\n ),\n ),\n ];\n }),\n );\n}\n\nfunction modeSection(draft: Draft, controls: AvailableControls): Child {\n const { switchableModes, lackingModes } = controls;\n if (switchableModes.length === 0) return null;\n const modeSwitches = switchableModes.filter((mode) => draft.modeSwitches.includes(mode));\n const extraModes = switchableModes.filter((mode) => mode === 'dehumidify' || mode === 'fan');\n const hasSelect = extraModes.length > 0;\n // A mode select is only of use for a dry or a fan mode.\n const current = draft.modeControl === 'select' && !hasSelect ? 'native' : draft.modeControl;\n // Switches with none picked would add nothing, so picking them starts with one for each of dry and fan.\n const pick = (modeControl: Exposure['modeControl']): void => {\n if (modeControl === 'switches' && modeSwitches.length === 0) update(draft, { modeControl, modeSwitches: hasSelect ? extraModes : [...switchableModes] });\n else update(draft, { modeControl });\n };\n const fallback = switchableModes.includes('cool') ? 'cool' : 'heat';\n const extra = extraModes.map((mode) => modeLabels[mode].toLowerCase()).join(' and ');\n const switchOff = hasSelect ? `Off turns the unit off, or from ${extra} puts it back in ${fallback}.` : 'Off turns the unit off.';\n const example = `${modeLabels[modeSwitches.length > 0 ? modeSwitches[0] : switchableModes[0]]} Mode`;\n const switchPlace = draft.isComposed\n ? `Each appears as a part of \"${draft.name}\", tagged with its mode, such as \"${example}\".`\n : `Each appears as \"${draft.name} ${example}\", and so on.`;\n // Such as \"auto, dry or heat\".\n const lackingLabels = lackingModes.map((mode) => modeLabels[mode].toLowerCase());\n const lacking = lackingLabels.length === 1 ? lackingLabels[0] : `${lackingLabels.slice(0, -1).join(', ')} or ${lackingLabels[lackingLabels.length - 1]}`;\n return h(\n 'section',\n {},\n h('h2', {}, 'Modes'),\n h(\n 'p',\n { class: 'help' },\n 'Every mode of the unit is a mode of the air conditioner in Matter, but some apps, such as Apple Home and Google Home, only offer off, cool, heat and auto.',\n ),\n h(\n 'div',\n { 'class': 'choices', 'role': 'radiogroup', 'aria-label': 'Modes' },\n radio('mode-control', 'native', current, 'Native modes only', 'The modes of the unit are those of the air conditioner, as Matter has them, and nothing more is added.', pick),\n hasSelect\n ? radio(\n 'mode-control',\n 'select',\n current,\n 'A mode select',\n `${placement(draft, 'Mode', true)}, with Off and every mode of the unit, as the air conditioner has them. Picking a mode turns the unit on in it. ${selectSupport}`,\n pick,\n )\n : null,\n radio('mode-control', 'switches', current, 'Switches', `A switch for each mode picked below. On turns the unit on in that mode. ${switchOff}`, pick),\n current === 'switches'\n ? h(\n 'div',\n { class: 'sub' },\n chips('mode-switch', 'Modes that get a switch', switchableModes, modeSwitches, modeLabels, (picked) => update(draft, { modeSwitches: picked })),\n h('p', { class: 'help' }, switchPlace),\n )\n : null,\n ),\n // The replacements are on the thermostat, so they go with any of the choices above.\n lackingModes.length > 0\n ? h(\n 'div',\n { class: 'field' },\n h('h3', {}, 'Modes the unit lacks'),\n h(\n 'p',\n { class: 'help' },\n `This unit has no ${lacking}. Each can run one of its modes instead, such as heat running dry on a unit that only cools: an app then reaches that mode from the modes it offers, and nothing is added to Matter. The air conditioner shows the mode picked while the unit is in it, with its setpoint. Auto is offered once the air conditioner both cools and heats, counting these.`,\n ),\n replacementFields(draft, controls),\n )\n : null,\n );\n}\n\nfunction specialSection(draft: Draft, controls: AvailableControls): Child {\n if (controls.specialModes.length === 0) return null;\n return h(\n 'section',\n {},\n h('h2', {}, 'Special modes'),\n h(\n 'p',\n { class: 'help' },\n 'Matter has no control for these, so each can get a switch of its own. A switch only takes effect in the modes this unit offers that special mode in.',\n ),\n h(\n 'div',\n { class: 'choices' },\n ...controls.specialModes.map((mode) =>\n toggle(`special-${mode}`, draft.specialModeSwitches.includes(mode), `Add a switch for ${specialModeTexts[mode].title}`, specialModeTexts[mode].text, (isOn) =>\n update(draft, { specialModeSwitches: controls.specialModes.filter((other) => (other === mode ? isOn : draft.specialModeSwitches.includes(other))) }),\n ),\n ),\n ),\n );\n}\n\nfunction sensorSection(draft: Draft): HTMLElement {\n return h(\n 'section',\n {},\n h('h2', {}, 'Humidity and outdoor temperature'),\n h(\n 'p',\n { class: 'help' },\n 'No adapter says which readings its unit has, so each of these takes effect once the unit gives that reading. The room temperature and the humidity are always on the air conditioner.',\n ),\n h(\n 'div',\n { class: 'choices' },\n toggle(\n 'separate-humidity',\n draft.hasSeparateHumiditySensor,\n 'Also show the humidity on a sensor of its own',\n `${placement(draft, 'Humidity', false)}, and the air conditioner keeps its humidity. For apps that show no humidity on an air conditioner, which Apple Home is reported to be.`,\n (hasSeparateHumiditySensor) => update(draft, { hasSeparateHumiditySensor }),\n ),\n toggle(\n 'outdoor-sensor',\n draft.hasOutdoorTemperatureSensor,\n 'Add a sensor for the outdoor temperature',\n `It appears as \"${draft.name} Outdoor Temperature\". It is a device of its own, which you can put in another room, such as outside. Until you do, a Matter app may show the outdoor temperature as that of the room it put the sensor in. Some units give no outdoor temperature while they are idle: the sensor then shows no value.`,\n (hasOutdoorTemperatureSensor) => update(draft, { hasOutdoorTemperatureSensor }),\n ),\n ),\n );\n}\n\nfunction composedSection(draft: Draft): HTMLElement {\n return h(\n 'section',\n {},\n h('h2', {}, 'One device or several'),\n h(\n 'p',\n { class: 'help' },\n 'The switches, a fan of its own and a humidity sensor of its own can be parts of the air conditioner in Matter, or devices of their own beside it. The outdoor temperature sensor is always a device of its own, so that you can put it in another room than the air conditioner.',\n ),\n h(\n 'div',\n { class: 'choices' },\n toggle(\n 'composed',\n draft.isComposed,\n 'Make them parts of the air conditioner',\n `Your Matter app has one device, \"${draft.name}\", and they move between rooms with it. A part has no name of its own in Matter, so an app may show the switches as numbered outlets, and an app that shows no parts shows the air conditioner alone. Turned off, each is a device of its own with its own name, which your app puts in a room by itself.`,\n (isComposed) => update(draft, { isComposed }),\n ),\n ),\n );\n}\n\n/**\n * Draw the Options step: the name of the current unit and how it appears in Matter\n *\n * @returns {Child[]} The contents of the screen.\n */\nexport function optionsScreen(): Child[] {\n const draft = currentDraft();\n if (draft === undefined) return [notice()];\n const controls = draft.controls ?? noControls;\n return [\n steps(),\n unitStrip(),\n unitHeader(draft, `Options for ${adapterText(draft)}. Power, mode and temperature always appear in Matter: choose how the rest appears.`),\n nameSection(draft),\n presetSection(draft, controls),\n fanSection(draft, controls),\n swingSection(draft, controls),\n modeSection(draft, controls),\n specialSection(draft, controls),\n sensorSection(draft),\n composedSection(draft),\n draft.isNew\n ? null\n : h(\n 'p',\n { class: 'help' },\n 'A change of any of these applies at the next restart of Matterbridge. A switch or a sensor you add is new in your Matter app, in its default room, and one you remove is gone.',\n ),\n notice(),\n h(\n 'div',\n { class: 'footer' },\n button('Cancel', goHome),\n button(draft.isNew ? `Add ${draft.name}` : 'Save options', () => void saveDraft(draft), 'primary'),\n ),\n ];\n}\n", "/**\n * @file apps/frontend/src/theme.ts\n * @description Makes the setup page look like the Matterbridge page it is shown in.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Take the colours and the font of the Matterbridge page this one is shown in\n *\n * Edge cases:\n * - opened on its own or from another origin -> the page keeps its own colours\n *\n * @returns {void}\n */\nexport function adoptHostTheme(): void {\n try {\n if (window.parent === window) return;\n const host = getComputedStyle(window.parent.document.body);\n for (const name of ['--primary-color', '--div-bg-color', '--div-text-color', '--main-bg-color', '--main-label-color', '--div-border-color', '--main-light-color']) {\n const value = host.getPropertyValue(name).trim();\n if (value !== '') document.documentElement.style.setProperty(`--host${name.slice(1)}`, value);\n }\n document.documentElement.style.setProperty('--host-font', host.fontFamily);\n } catch {\n // Opened on its own or from another origin: the page keeps its own colours.\n }\n}\n", "/**\n * @file apps/frontend/src/app.ts\n * @description The guided setup page of the Matterbridge Daikin Local plugin. Matterbridge serves it at\n * /plugins/matterbridge-daikin-local/ and it talks to the plugin through api/<path> below that address.\n * This file starts the page: the rest is in the files next to it.\n * @author Calvin Che\n * @created 2026-10-13\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadState } from './actions.js';\nimport { h } from './dom.js';\nimport { render, setScreens } from './render.js';\nimport { connectScreen } from './screens/connect.js';\nimport { doneScreen } from './screens/done.js';\nimport { findScreen } from './screens/find.js';\nimport { homeScreen } from './screens/home.js';\nimport { optionsScreen } from './screens/options.js';\nimport { adoptHostTheme } from './theme.js';\n\nsetScreens({\n loading: () => [h('p', { class: 'notice working', role: 'status' }, h('span', { class: 'spinner' }), 'Loading\u2026')],\n home: homeScreen,\n find: findScreen,\n connect: connectScreen,\n options: optionsScreen,\n done: doneScreen,\n});\n\nadoptHostTheme();\nrender();\nvoid loadState();\n"],
|
|
5
|
+
"mappings": "AA0DA,eAAsBA,EAAqBC,EAAUC,EAAmC,CACtF,GAAI,CACF,GAAM,CAACC,EAAQC,CAAI,EAAIH,EAAM,MAAM,GAAG,EAChCI,EAAoB,CAAE,OAAAF,CAAO,EAC/BD,IAAS,SACXG,EAAK,QAAU,CAAE,eAAgB,kBAAmB,EACpDA,EAAK,KAAO,KAAK,UAAUH,CAAI,GAEjC,IAAMI,EAAW,MAAM,MAAM,IAAI,IAAI,OAAOF,CAAI,GAAI,SAAS,OAAO,EAAGC,CAAI,EAC3E,GAAIC,EAAS,SAAW,IAAK,MAAO,CAAE,GAAI,GAAO,MAAO,6EAA8E,EACtI,IAAMC,EAAS,MAAMD,EAAS,KAAK,EACnC,MAAI,OAAQC,EAAcA,EACnB,CAAE,GAAI,GAAO,MAAOA,EAAM,OAAS,mCAAmCD,EAAS,MAAM,EAAG,CACjG,MAAQ,CACN,MAAO,CAAE,GAAI,GAAO,MAAO,wEAAyE,CACtG,CACF,CClCO,IAAME,EAAO,CAClB,OAAQ,UACR,MAAO,OACP,MAAO,CAAC,EACR,SAAU,IAAI,IACd,MAAO,CAAC,EACR,MAAO,CAAC,EAER,QAAS,CAAC,EACV,OAAQ,GACR,SAAU,GACV,MAAO,GAEP,KAAM,GACN,kBAAmB,EACrB,EAOO,SAASC,GAAkC,CAChD,OAAOD,EAAK,MAAM,CAAC,CACrB,CAQO,SAASE,EAAWC,EAAsB,CAC/C,OAAOA,EAAM,OAAS,GAAKA,EAAM,QAAQ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CACF,CCRAG,GAAW,CACT,QAAS,IAAM,CAACC,EAAE,IAAK,CAAE,MAAO,iBAAkB,KAAM,QAAS,EAAGA,EAAE,OAAQ,CAAE,MAAO,SAAU,CAAC,EAAG,eAAU,CAAC,EAChH,KAAMC,GACN,KAAMC,GACN,QAASC,GACT,QAASC,GACT,KAAMC,EACR,CAAC,EAEDC,GAAe,EACfC,EAAO,EACFC,EAAU",
|
|
6
|
+
"names": ["api", "route", "body", "method", "path", "init", "response", "reply", "view", "currentDraft", "draftLabel", "draft", "isStored", "adapter", "device", "pickExposure", "source", "fanControl", "fanSpeedWhenHidden", "swingControl", "swingAxes", "swingModeWhenHidden", "modeControl", "modeSwitches", "modeReplacements", "fanAutoControl", "hasSeparateFan", "specialModeSwitches", "hasOutdoorTemperatureSensor", "hasSeparateHumiditySensor", "isComposed", "defaultExposure", "maxNameLength", "uniqueName", "base", "taken", "count", "suffix", "name", "takenNames", "draft", "stored", "view", "device", "queued", "other", "draftsFromAdapters", "adapters", "adapter", "draftFromStored", "capabilities", "controls", "macAddress", "host", "protocol", "requiresRegistration", "usesHttps", "requiresLocalPassword", "noControls", "canReplace", "mode", "replacement", "replacements", "others", "modes", "fitModeReplacements", "fitted", "presets", "presetExposure", "name", "controls", "isMatter", "hasRocking", "swingControl", "modeSwitches", "mode", "matchesPreset", "draft", "chosen", "pickExposure", "isAutoStep", "hasFixedFanSpeed", "fitModeReplacements", "screens", "setScreens", "all", "render", "root", "form", "view", "currentDraft", "isSameForm", "active", "activeId", "caret", "typed", "input", "child", "id", "value", "focused", "busy", "text", "task", "view", "render", "loadState", "reply", "api", "search", "refreshState", "goHome", "byAddress", "adapter", "device", "isStored", "lookUp", "host", "isConfigured", "needsRegistration", "startQueue", "drafts", "enterConnect", "draft", "currentDraft", "check", "key", "body", "draftLabel", "isFirstReading", "presetExposure", "told", "uniqueName", "takenNames", "skipDraft", "skipped", "saveDraft", "name", "problem", "checkName", "localPassword", "pickExposure", "reloadNote", "restartNote", "removeDevice", "h", "tag", "props", "children", "element", "key", "value", "child", "button", "label", "onclick", "kind", "disabled", "h", "view", "notice", "unitStrip", "current", "currentDraft", "doing", "unit", "draft", "index", "draftLabel", "unitHeader", "text", "steps", "names", "name", "state", "lockCodeForm", "draft", "isRejected", "code", "h", "button", "check", "keyForm", "key", "credentialForm", "status", "connectScreen", "currentDraft", "notice", "canRetry", "view", "steps", "unitStrip", "unitHeader", "skipDraft", "goHome", "doneScreen", "names", "view", "needsRestart", "device", "h", "restartNote", "reloadNote", "button", "goHome", "foundRow", "adapter", "isSelectable", "notes", "checkbox", "h", "view", "render", "note", "findScreen", "chosen", "host", "lookUpHost", "lookUp", "event", "continueLabel", "steps", "notice", "button", "search", "goHome", "startQueue", "draftsFromAdapters", "modeNames", "describeExposure", "device", "hasFan", "hasSwing", "fanPlace", "autoStep", "fan", "swingAxes", "swing", "controls", "text", "modeSwitches", "mode", "replacements", "replacement", "switches", "name", "extra", "place", "deviceRow", "statusText", "isConfirming", "view", "h", "button", "removeDevice", "render", "startQueue", "draftFromStored", "homeScreen", "devices", "search", "notice", "loadState", "fanSpeedLabels", "swingModeLabels", "modeLabels", "specialModeTexts", "glyphs", "selectSupport", "placement", "draft", "label", "isTagged", "update", "change", "render", "choice", "group", "value", "current", "title", "text", "glyph", "onpick", "id", "input", "h", "radio", "toggle", "isOn", "chips", "values", "picked", "labels", "other", "adapterText", "told", "address", "nameSection", "event", "toldText", "presetSection", "controls", "presets", "name", "matchesPreset", "presetExposure", "listSpeeds", "speeds", "speed", "fanAutoSection", "pick", "fanAutoControl", "isFanHidden", "switchText", "slowest", "fastest", "choices", "fanSection", "fanSpeeds", "hasAutoStep", "hasAutoSwitch", "positions", "autoMode", "speedList", "fanControl", "hasSeparateFan", "swingSection", "swingModes", "hasVertical", "hasHorizontal", "hasRocking", "insteadOfRocking", "swingControl", "mode", "swingAxesField", "isRocking", "swingAxes", "otherAxis", "help", "replacementFields", "replacements", "fitModeReplacements", "shown", "others", "replacement", "onchange", "next", "canReplace", "modeSection", "switchableModes", "lackingModes", "modeSwitches", "extraModes", "hasSelect", "modeControl", "fallback", "extra", "switchOff", "example", "switchPlace", "lackingLabels", "lacking", "specialSection", "sensorSection", "hasSeparateHumiditySensor", "hasOutdoorTemperatureSensor", "composedSection", "isComposed", "optionsScreen", "currentDraft", "notice", "noControls", "steps", "unitStrip", "unitHeader", "button", "goHome", "saveDraft", "adoptHostTheme", "host", "name", "value", "setScreens", "h", "homeScreen", "findScreen", "connectScreen", "optionsScreen", "doneScreen", "adoptHostTheme", "render", "loadState"]
|
|
7
7
|
}
|
package/dist/module.js
CHANGED
|
@@ -102,8 +102,8 @@ export class DaikinPlatform extends MatterbridgeDynamicPlatform {
|
|
|
102
102
|
if (revision !== this.revisions.current || config.terminalUuid !== this.terminalUuid)
|
|
103
103
|
this.storeConfig();
|
|
104
104
|
}
|
|
105
|
-
async onFetch(method, path,
|
|
106
|
-
return handleSetupRequest(this, method, path,
|
|
105
|
+
async onFetch(method, path, _query, body) {
|
|
106
|
+
return handleSetupRequest(this, method, path, body);
|
|
107
107
|
}
|
|
108
108
|
getTerminalUuid() {
|
|
109
109
|
if (this.terminalUuid !== undefined)
|
package/dist/setup/setupApi.js
CHANGED
|
@@ -53,20 +53,20 @@ async function handlePost(platform, path, body) {
|
|
|
53
53
|
await platform.saveDevice(device);
|
|
54
54
|
return { ok: true, state: await platform.getSetupState() };
|
|
55
55
|
}
|
|
56
|
+
if (path === 'remove-device') {
|
|
57
|
+
const macAddress = normalizeMacAddress(body.macAddress);
|
|
58
|
+
if (macAddress === undefined)
|
|
59
|
+
return fail('Give the MAC address of the adapter of the device to remove');
|
|
60
|
+
return (await platform.removeDevice(macAddress)) ? { ok: true } : fail(`No device has the adapter ${macAddress}`);
|
|
61
|
+
}
|
|
56
62
|
return undefined;
|
|
57
63
|
}
|
|
58
|
-
export async function handleSetupRequest(platform, method, path,
|
|
64
|
+
export async function handleSetupRequest(platform, method, path, body) {
|
|
59
65
|
try {
|
|
60
66
|
if (method === 'GET' && path === 'state')
|
|
61
67
|
return { ok: true, state: await platform.getSetupState() };
|
|
62
68
|
if (method === 'POST' && path !== undefined)
|
|
63
69
|
return await handlePost(platform, path, toRecord(body));
|
|
64
|
-
if (method === 'DELETE' && path === 'device') {
|
|
65
|
-
const macAddress = normalizeMacAddress(query?.macAddress);
|
|
66
|
-
if (macAddress === undefined)
|
|
67
|
-
return fail('Give the MAC address of the adapter of the device to remove');
|
|
68
|
-
return (await platform.removeDevice(macAddress)) ? { ok: true } : fail(`No device has the adapter ${macAddress}`);
|
|
69
|
-
}
|
|
70
70
|
return undefined;
|
|
71
71
|
}
|
|
72
72
|
catch (error) {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "matterbridge-daikin-local",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "matterbridge-daikin-local",
|
|
9
|
-
"version": "0.12.
|
|
9
|
+
"version": "0.12.1",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"daikin-local-control": "0.7.0",
|