matterbridge-daikin-local 0.8.0 → 0.9.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 +16 -0
- package/README.md +18 -17
- package/apps/frontend/build/app.js +1 -1
- package/apps/frontend/build/app.js.map +3 -3
- package/dist/accessory/daikinAccessory.js +24 -1
- package/dist/accessory/endpoints.js +15 -12
- package/dist/accessory/layout.js +4 -0
- package/dist/accessory/matterState.js +8 -3
- package/dist/config.js +1 -1
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,22 @@ 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.9.1] - 2026-10-19
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- [setup]: The Google Home preset shows no swing again and keeps it as it is, as the Apple Home preset does, instead of the rocking of the fan, or the switches on a unit whose fan speed cannot be set. The Full Matter support preset keeps the rocking.
|
|
12
|
+
|
|
13
|
+
## [0.9.0] - 2026-10-19
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- [devices]: Add the swing as the rocking of the fan control, a new choice named Native rocking beside the switches, the mode select and not shown: up and down for the vertical swing and left and right for the horizontal one, on the axes the unit swings on. The switches and the select take its place, so the fan control has no rocking beside them, as Apple Home is reported not to handle it well. The Google Home and the Full Matter support presets show the rocking, where they showed no swing and a mode select, or the switches on a unit whose fan speed cannot be set.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- [devices]: Write the state of the unit again after a factory reset of the Matter node once the node is back online, instead of as each endpoint comes back. A unit that answered at once held the thermostat as the node went online, which failed the reset and left Matterbridge stuck.
|
|
22
|
+
|
|
7
23
|
## [0.8.0] - 2026-10-19
|
|
8
24
|
|
|
9
25
|
### Changed
|
package/README.md
CHANGED
|
@@ -118,8 +118,8 @@ Matter describes a device as endpoints. Each endpoint has one or more device typ
|
|
|
118
118
|
flowchart TD
|
|
119
119
|
bridge["Matterbridge<br/>Aggregator"]
|
|
120
120
|
subgraph device["One device in a Matter app"]
|
|
121
|
-
ac["<b>Living Room</b><br/>Room Air Conditioner, Bridged Node, Power Source<br/>On/Off, Thermostat<br/>Fan Control when it is
|
|
122
|
-
fan["Fan<br/>Fan Control"]
|
|
121
|
+
ac["<b>Living Room</b><br/>Room Air Conditioner, Bridged Node, Power Source<br/>On/Off, Thermostat<br/>Fan Control unless the fan speed is hidden or on a fan of its own, with Rocking for the swing when it is chosen, and Relative Humidity once the unit gives it"]
|
|
122
|
+
fan["Fan<br/>Fan Control, with Rocking for the swing when it is chosen"]
|
|
123
123
|
switches["On/Off Plug-in Unit, one for each switch<br/>tagged 1 Vertical Swing, 2 Horizontal Swing and so on<br/>On/Off"]
|
|
124
124
|
selects["Mode Select, one for the mode and one for the swing<br/>tagged 1 Mode, 2 Swing<br/>Mode Select"]
|
|
125
125
|
humidity["Humidity Sensor<br/>Relative Humidity"]
|
|
@@ -192,13 +192,14 @@ A switch or a step is for Matter apps that show no Auto fan mode. A step takes t
|
|
|
192
192
|
|
|
193
193
|
### Swing
|
|
194
194
|
|
|
195
|
-
| Option
|
|
196
|
-
|
|
|
197
|
-
|
|
|
198
|
-
|
|
|
199
|
-
|
|
|
195
|
+
| Option | In Matter |
|
|
196
|
+
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
197
|
+
| 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 one, and both for 3D, on the axes the unit swings on. Not every app shows it, and Apple Home is reported not to handle it well |
|
|
198
|
+
| Switches | One on/off switch for each axis the unit swings on, named `<name> Vertical Swing` and `<name> Horizontal Swing`. A unit that swings on one axis gets one switch. They appear as outlets, the on/off device type every Matter app supports |
|
|
199
|
+
| Mode select | One mode select named `<name> Swing`, with Off, Vertical, Horizontal and 3D for the swing modes the unit has. Few Matter apps show it: see [Mode selects](#mode-selects) |
|
|
200
|
+
| Not shown | No swing control. The swing either stays as it is, or is set to the mode you pick each time the plugin sends a command |
|
|
200
201
|
|
|
201
|
-
Fixed louver positions are not controlled from Matter.
|
|
202
|
+
The switches and the select are for the Matter apps that show no rocking, or do not handle it well: they take its place, so the fan control has no rocking beside them. A unit whose fan speed is not shown has no fan control, and so no rocking: native rocking falls back to the switches. Fixed louver positions are not controlled from Matter.
|
|
202
203
|
|
|
203
204
|
### Modes
|
|
204
205
|
|
|
@@ -232,7 +233,7 @@ Each Matter mode the unit lacks can run one of its modes instead, as you pick, s
|
|
|
232
233
|
|
|
233
234
|
### Mode selects
|
|
234
235
|
|
|
235
|
-
A mode select is the Matter device type that picks one value from a list, as a drop-down does. The setup can add one for the mode, named `<name> Mode`, on a unit with a dry or a fan mode, and one for the swing, named `<name> Swing`, as a choice under [Swing](#swing). Each lists only what the unit has, and is chosen instead of the switches: the mode select under [Modes](#modes), the swing select under [Swing](#swing)
|
|
236
|
+
A mode select is the Matter device type that picks one value from a list, as a drop-down does. The setup can add one for the mode, named `<name> Mode`, on a unit with a dry or a fan mode, and one for the swing, named `<name> Swing`, as a choice under [Swing](#swing). Each lists only what the unit has, and is chosen instead of the switches: the mode select under [Modes](#modes), and the swing select under [Swing](#swing), instead of the rocking of the fan control as well. No preset adds either.
|
|
236
237
|
|
|
237
238
|
| Mode select | Lists | Picking a value |
|
|
238
239
|
| ----------- | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -254,11 +255,11 @@ Matter has no control for Powerful, Econo and Streamer, so the setup can add a s
|
|
|
254
255
|
|
|
255
256
|
In the Options step, a preset fills in every choice above for what the unit can do. You can change any of them afterwards. A new air conditioner starts with the Apple Home preset, and one already set up keeps its own choices.
|
|
256
257
|
|
|
257
|
-
| Preset | Fan speed | Swing
|
|
258
|
-
| ------------------- | ---------- |
|
|
259
|
-
| Apple Home | Percentage | Not shown
|
|
260
|
-
| Google Home | Steps | Not shown
|
|
261
|
-
| Full Matter support | Steps |
|
|
258
|
+
| Preset | Fan speed | Swing | Modes | Auto fan | Special mode switches | Humidity | Outdoor sensor | Parts of the air conditioner |
|
|
259
|
+
| ------------------- | ---------- | -------------- | -------------------- | -------- | --------------------- | --------------------------- | -------------- | ---------------------------- |
|
|
260
|
+
| Apple Home | Percentage | Not shown | Dry and fan switches | Switch | None | Also on a sensor of its own | No | No |
|
|
261
|
+
| Google Home | Steps | Not shown | Dry and fan switches | Switch | None | Also on a sensor of its own | No | No |
|
|
262
|
+
| Full Matter support | Steps | Native rocking | Native modes only | Native | All | On the air conditioner | Yes | Yes |
|
|
262
263
|
|
|
263
264
|
### One device or several
|
|
264
265
|
|
|
@@ -267,8 +268,8 @@ The switches, the mode selects, a fan of its own and a humidity sensor of its ow
|
|
|
267
268
|
```mermaid
|
|
268
269
|
flowchart TD
|
|
269
270
|
bridge["Matterbridge<br/>Aggregator"]
|
|
270
|
-
ac["<b>Living Room</b><br/>Room Air Conditioner<br/>On/Off, Thermostat<br/>Fan Control when it is
|
|
271
|
-
fan["<b>Living Room Fan</b><br/>Fan<br/>Fan Control"]
|
|
271
|
+
ac["<b>Living Room</b><br/>Room Air Conditioner<br/>On/Off, Thermostat<br/>Fan Control unless the fan speed is hidden or on a fan of its own, with Rocking for the swing when it is chosen, and Relative Humidity once the unit gives it"]
|
|
272
|
+
fan["<b>Living Room Fan</b><br/>Fan<br/>Fan Control, with Rocking for the swing when it is chosen"]
|
|
272
273
|
switches["<b>Living Room Vertical Swing</b>, and the other switches<br/>On/Off Plug-in Unit, one for each switch<br/>On/Off"]
|
|
273
274
|
selects["<b>Living Room Mode</b> and <b>Living Room Swing</b><br/>Mode Select, one for each<br/>Mode Select"]
|
|
274
275
|
humidity["<b>Living Room Humidity</b><br/>Humidity Sensor<br/>Relative Humidity"]
|
|
@@ -310,7 +311,7 @@ This plugin is the only one of the four that finds the adapters itself, that spe
|
|
|
310
311
|
| Thermostat modes | Off, Cool, Heat, Auto, Dry and Fan only, and an optional switch for each mode, a mode select, or the modes the unit lacks running others | Off, Cool, Heat, Auto, Dry and Fan only | Off, Cool, Heat, Auto, Dry and Fan only, and a mode select that also has humidify | Off, Cool, Heat, Auto, Dry and Fan only |
|
|
311
312
|
| Controls | Built from the modes, fan speeds, swing and temperature limits each unit reports | The same for every unit, with fixed temperature limits | Built for its two tested models | Modes and temperature limits from the cloud |
|
|
312
313
|
| Fan speed | Steps, a percentage or not shown, on the air conditioner or on a fan of its own, and an optional switch for the auto speed | No | Low, Medium, High and Auto, a percentage, or a mode select | A fan device |
|
|
313
|
-
| Swing |
|
|
314
|
+
| Swing | The rocking of the fan control, a switch for each axis, a mode select, or not shown with the mode you fix | No | The airflow direction of each axis, through a mode select | No |
|
|
314
315
|
| Powerful, Econo and Streamer | An optional switch for each | No | No | A switch for Powerful |
|
|
315
316
|
| Humidity | On the air conditioner, and on a sensor of its own if you add one, when the unit gives it | No | Target humidity and ventilation as fans, and a humidity sensor | A humidity sensor, on units that report it |
|
|
316
317
|
| Outdoor temperature | A sensor you turn on, when the unit gives it | No | On the air conditioner and on a sensor | A sensor you can turn off |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
async function x(e,t,n){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}${n===void 0?"":`?${n}`}`,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 v(){return i.queue[0]}function A(e){return e.name===""?e.adapter.host:e.name}function V(e){return(i.setup?.devices??[]).some(t=>t.macAddress===e.macAddress)}function $(e){let{fanControl:t,fanSpeedWhenHidden:n,swingControl:s,swingModeWhenHidden:a,modeControl:r,modeSwitches:c,modeReplacements:d,fanAutoControl:l,hasSeparateFan:f,specialModeSwitches:w,hasOutdoorTemperatureSensor:u,hasSeparateHumiditySensor:k,isComposed:g}=e;return{fanControl:t,fanSpeedWhenHidden:n,swingControl:s,swingModeWhenHidden:a,modeControl:r,modeSwitches:[...c],modeReplacements:{...d},fanAutoControl:l,hasSeparateFan:f,specialModeSwitches:[...w],hasOutdoorTemperatureSensor:u,hasSeparateHumiditySensor:k,isComposed:g}}var ve={fanControl:"steps",fanSpeedWhenHidden:"keep",swingControl:"switches",swingModeWhenHidden:"keep",modeControl:"native",modeSwitches:[],modeReplacements:{},fanAutoControl:"native",hasSeparateFan:!1,specialModeSwitches:[],hasOutdoorTemperatureSensor:!1,hasSeparateHumiditySensor:!1,isComposed:!0},Se=32;function z(e,t){if(e===""||!t.has(e))return e;for(let n=2;;n++){let s=` ${n}`,a=`${e.slice(0,Se-s.length).trimEnd()}${s}`;if(!t.has(a))return a}}function ee(e){let t=(i.setup?.devices??[]).filter(s=>s.macAddress!==e.adapter.macAddress).map(s=>s.name),n=i.queue.filter(s=>s!==e).map(s=>s.name);return new Set([...t,...n].filter(s=>s!==""))}function te(e){let t=new Set((i.setup?.devices??[]).map(n=>n.name));return e.map(n=>{let s=z(n.name??"",t);return s!==""&&t.add(s),{adapter:n,name:s,isNew:!0,...$(ve)}})}function oe(e){let{capabilities:t,controls:n,name:s,macAddress:a,host:r,protocol:c,requiresRegistration:d,usesHttps:l,requiresLocalPassword:f}=e;return{adapter:{host:r,protocol:c,macAddress:a,requiresRegistration:d,usesHttps:l,requiresLocalPassword:f},name:s,isNew:!1,capabilities:t,controls:n,...$(e)}}var ne={fanSteps:[],hasFanAuto:!1,hasSwing:!1,switchableModes:[],lackingModes:[],specialModes:[]};function J(e,t,n,s){if(!s.switchableModes.includes(e)||!s.lackingModes.includes(t))return!1;let a=s.switchableModes.filter(c=>c!==e).map(c=>n[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 H(e,t){let n={};for(let s of t.switchableModes){let a=e[s];a!==void 0&&J(s,a,e,t)&&(n[s]=a)}return n}var q={apple:{title:"Apple Home",text:"Fan speed as a percentage, 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. The swing is not shown and stays as it is."},google:{title:"Google Home",text:"Fan speed as steps, 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. The swing is not shown and stays as it is."},matter:{title:"Full Matter support",text:"For apps that show every Matter control: fan speed as steps with its auto mode, the swing as a mode select, a switch for each special mode and the outdoor temperature, all as one device."}};function L(e,t){let n=e==="matter",s=n&&t.hasSwing?"select":"hidden",a=n?[]:t.switchableModes.filter(r=>r==="dehumidify"||r==="fan");return{fanControl:t.fanSteps.length===0?"hidden":e==="apple"?"percent":"steps",fanSpeedWhenHidden:"keep",swingControl:s,swingModeWhenHidden:"keep",modeControl:a.length>0?"switches":"native",modeSwitches:a,modeReplacements:{},fanAutoControl:!n&&t.hasFanAuto?"switch":"native",hasSeparateFan:!1,specialModeSwitches:n?[...t.specialModes]:[],hasOutdoorTemperatureSensor:n,hasSeparateHumiditySensor:!n,isComposed:n}}function se(e,t,n){let s=$(e);n.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(!n.hasFanAuto||a&&s.fanControl==="hidden"||r)&&(s.fanAutoControl="native"),n.hasSwing||Object.assign(s,{swingControl:"hidden",swingModeWhenHidden:"keep"}),s.modeSwitches=s.modeControl==="switches"?n.switchableModes.filter(d=>s.modeSwitches.includes(d)):[],s.modeReplacements=H(s.modeReplacements,n),{native:!0,select:n.switchableModes.includes("dehumidify")||n.switchableModes.includes("fan"),switches:s.modeSwitches.length>0}[s.modeControl]||(s.modeControl="native"),s.specialModeSwitches=n.specialModes.filter(d=>s.specialModeSwitches.includes(d)),JSON.stringify(s)===JSON.stringify(L(t,n))}var Q;function ie(e){Q=e}function p(){let e=document.getElementById("app");if(e===null||Q===void 0)return;let t=`${i.screen}:${v()?.adapter.host??""}`,n=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(...Q[i.screen]().filter(l=>l!==!1&&l!==null&&l!==void 0)),e.dataset.form=t,!n)return;for(let[l,f]of c){let w=document.getElementById(l);w instanceof HTMLInputElement&&(w.value=f)}if(a==="")return;let d=document.getElementById(a);d?.focus(),r!==void 0&&d instanceof HTMLInputElement&&d.setSelectionRange(r.start,r.end)}async function F(e,t){i.isBusy=!0,i.busyText=e,i.error="",i.info="",p();try{return await t()}finally{i.isBusy=!1,p()}}async function I(){let e=await x("GET state");if(!e.ok){i.error=e.error,i.screen="home",p();return}if(i.setup=e.state,e.state.devices.length===0){await N();return}i.screen="home",p()}async function W(){let e=await x("GET state");e.ok&&(i.setup=e.state)}function C(){i.queue=[],i.saved=[],i.handled=[],i.error="",i.info="",i.screen="home",W().then(p),p()}async function N(){i.screen="find";let e=await F("Searching your network. This takes about three seconds\u2026",async()=>x("POST discover"));if(!e.ok){i.error=`The search did not run: ${e.error}`,p();return}await W();let t=i.found.filter(n=>!e.devices.some(s=>s.host===n.host)&&i.selected.has(n.host)).map(n=>({...n,isConfigured:V(n)}));i.found=[...e.devices,...t];for(let n of e.devices)n.isConfigured||i.selected.add(n.host);p()}async function ae(e){let t=await F(`Looking for an adapter at ${e}\u2026`,async()=>x("POST identify",{host:e}));if(!t.ok){i.error=t.error,p();return}let n=V(t.device),s=t.device.requiresRegistration===!0;i.found=[...i.found.filter(a=>a.host!==t.device.host),{...t.device,isConfigured:n,needsRegistration:s}],n||i.selected.add(t.device.host),p()}function B(e){i.queue=e,i.saved=[],i.handled=[],Z()}async function Z(){let e=v();if(e===void 0){i.screen=i.saved.length>0?"done":"home",await W(),p();return}i.screen="connect",i.error="",i.info="",e.probe=void 0,p(),await P(e)}async function P(e,t){let n={device:e.adapter,localPassword:e.localPassword,key:t},s=t===void 0?`Checking ${A(e)}\u2026`:`Registering with ${A(e)}\u2026`,a=await F(s,async()=>x(t===void 0?"POST probe":"POST register",n));if(!a.ok){i.error=a.error,p();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=z(c,ee(e))),i.screen="options"}p()}function re(){let e=i.queue.shift();e!==void 0&&i.handled.push({label:A(e),isSaved:!1}),Z()}async function ce(e){let t=e.name.trim(),n=be(e,t);if(n!==""){i.error=n,p();return}let{adapter:s,localPassword:a}=e,r={...s,name:t,localPassword:a,...$(e)},c=await F(`Saving ${t}\u2026`,async()=>x("POST device",{device:r}));if(!c.ok){i.error=c.error,p();return}i.setup=c.state,i.saved.push(t),i.handled.push({label:t,isSaved:!0}),i.queue.shift(),await Z()}function be(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 X="Matterbridge's own list of devices shows the change once you reload its page.";async function de(e){let t=await F(`Removing ${e.name}\u2026`,async()=>x("DELETE device",void 0,`macAddress=${encodeURIComponent(e.macAddress)}`));i.confirmingRemoval="",t.ok?i.info=`${e.name} is removed. ${X}`:i.error=t.error,await W(),p()}function o(e,t={},...n){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 n)a!==!1&&a!==null&&a!==void 0&&s.append(a);return s}function h(e,t,n="quiet",s=!1){return o("button",{type:"button",class:`button ${n}`,onclick:t,disabled:s||i.isBusy},e)}function S(){return i.isBusy?o("p",{class:"notice working",role:"status"},o("span",{class:"spinner"}),i.busyText):i.error!==""?o("p",{class:"notice problem",role:"alert"},i.error):i.info!==""?o("p",{class:"notice",role:"status"},i.info):null}function U(){let e=v();if(e===void 0||!e.isNew||i.handled.length+i.queue.length<2)return null;let t=i.screen==="connect"?"Connecting":"Choosing options";return o("ol",{class:"units","aria-label":"Air conditioners in this setup"},...i.handled.map(n=>o("li",{class:n.isSaved?"done":"skipped"},o("strong",{},n.label),o("span",{class:"meta"},n.isSaved?"Added":"Skipped"))),...i.queue.map((n,s)=>o("li",{class:s===0?"current":"ahead","aria-current":s===0?"true":void 0},o("strong",{},A(n)),o("span",{class:"meta"},s===0?t:"Waiting"))))}function K(e,t){return o("header",{class:"unit-header"},o("h1",{},A(e)),o("p",{class:"meta"},t))}function T(){if(i.queue.length>0&&!i.queue.some(s=>s.isNew))return null;let e=["Find","Connect","Options"],n=["find","connect","options"].indexOf(i.screen);return o("ol",{class:"steps"},...e.map((s,a)=>{let r="ahead";return a<n?r="done":a===n&&(r="current"),o("li",{class:r,"aria-current":a===n?"step":void 0},s)}))}function Me(e,t){let n=o("input",{type:"password",id:"lock-code",inputMode:"numeric",autocomplete:"off",maxLength:64});return o("div",{class:"field"},o("label",{for:"lock-code"},"Child lock code"),o("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?o("p",{class:"problem-text"},"The adapter did not accept that code."):null,o("div",{class:"inline-form"},n,h("Check the code",()=>{n.value!==""&&(e.localPassword=n.value,P(e))},"primary")))}function xe(e,t){let n=o("input",{type:"text",id:"adapter-key",autocomplete:"off",spellcheck:!1,maxLength:64});return o("div",{class:"field"},o("label",{for:"adapter-key"},"KEY on the adapter"),o("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?o("p",{class:"problem-text"},"The adapter did not accept that KEY."):null,o("div",{class:"inline-form"},n,h("Register",()=>{n.value.trim()!==""&&P(e,n.value.trim())},"primary")))}function Ce(e){let t=e.probe?.status;return t==="localPasswordRequired"||t==="localPasswordRejected"?Me(e,t==="localPasswordRejected"):t==="registrationRequired"||t==="registrationRejected"?xe(e,t==="registrationRejected"):t==="unreachable"?o("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"?o("p",{class:"notice problem",role:"alert"},`${e.name} answered with an error: ${e.probe?.message??"unknown"}`):null}function le(){let e=v();if(e===void 0)return[S()];let t=e.probe?.status==="unreachable"||e.probe?.status==="failed"||i.error!=="";return[T(),U(),K(e,`Connecting to its adapter at ${e.adapter.host}.`),S(),i.isBusy?null:Ce(e),o("div",{class:"footer"},t?h("Try again",()=>{P(e)}):null,h(e.isNew&&i.queue.length>1?"Skip this one":"Cancel",e.isNew&&i.queue.length>1?re:C))]}function pe(){let e=i.saved;return[o("header",{},o("h1",{},e.length===1?`${e[0]} is set up`:`${e.length} air conditioners are set up`)),o("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."),o("p",{class:"help"},X),o("div",{class:"footer"},h("Done",C,"primary"))]}function ke(e){let t=!e.isConfigured,n=[];e.isConfigured&&n.push("Already set up."),e.name===void 0&&n.push("It has not told its name yet: you will name it in its options."),t&&e.needsRegistration?n.push("Asks for the KEY printed on its label."):t&&e.requiresRegistration&&n.push("Already registered with this plugin, so it will not ask for its KEY."),t&&e.requiresLocalPassword&&n.push("Asks for its child lock code.");let s=o("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),p()}});return o("li",{class:t?"found":"found unavailable"},o("label",{for:`found-${e.host}`},s,o("span",{},o("strong",{},e.name??"Unnamed adapter"),o("span",{class:"meta"},` ${e.host}`),...n.map(a=>o("span",{class:"meta note"},a)))))}function ue(){let e=i.found.filter(a=>i.selected.has(a.host)&&!a.isConfigured),t=o("input",{type:"text",id:"host",placeholder:"192.168.1.50",spellcheck:!1,autocomplete:"off"}),n=()=>{t.value.trim()!==""&&ae(t.value.trim())};t.addEventListener("keydown",a=>{a.key==="Enter"&&n()});let s=e.length===1?"Set up 1 air conditioner":`Set up ${e.length} air conditioners`;return[T(),o("header",{},o("h1",{},"Find your air conditioners")),S(),i.found.length>0?o("ul",{class:"found-list"},...i.found.map(ke)):null,!i.isBusy&&i.found.length===0?o("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,o("details",{class:"manual",open:!i.isBusy&&i.found.length===0},o("summary",{},"Can't see your air conditioner?"),o("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."),o("div",{class:"inline-form"},o("label",{for:"host",class:"visually-hidden"},"Adapter address"),t,h("Look it up",n))),o("div",{class:"footer"},h("Search again",()=>{N()}),h("Cancel",C),h(s,()=>B(te(e)),"primary",e.length===0))]}var Y={auto:"auto mode",cool:"cool mode",heat:"heat mode",dehumidify:"dry mode",fan:"fan mode"};function Ae(e){let t=e.controls===void 0||e.controls.fanSteps.length>0,n=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={switches:"swing as switches",select:"swing as a mode select",hidden:"swing not shown"}[e.swingControl],d=[t?r:"",n?c:""].filter(g=>g!=="").join(", "),l=e.modeControl==="switches"?e.modeSwitches.map(g=>Y[g]):[],f=Object.keys(Y).flatMap(g=>{let M=e.modeReplacements[g];return M===void 0?[]:[`${Y[g]} as ${Y[M].replace(" mode","")}`]}),w=[...l,e.fanAutoControl==="switch"?"auto fan":"",...e.specialModeSwitches].filter(g=>g!==""),u=[w.length===0?"":`a switch for ${w.join(", ")}`,e.modeControl==="select"?"a mode select":"",f.join(" and ")].filter(g=>g!=="").join(" and "),k=e.isComposed?", all as one device":"";return d===""?`${u===""?"power, mode and temperature":u}${k}`:`${u===""?d:`${d}, and ${u}`}${k}`}function $e(e){let t={online:"Online",offline:"Not answering",stopped:"Not started"}[e.status],n=i.confirmingRemoval===e.macAddress;return o("li",{class:"device"},o("div",{class:"device-main"},o("h3",{},e.name),o("p",{class:"meta"},o("span",{class:`status ${e.status}`},t),` at ${e.host}. In Matter: ${Ae(e)}.`),e.status!=="online"&&e.error?o("p",{class:"meta problem-text"},e.error):null),n?o("div",{class:"actions"},o("span",{class:"meta"},"Remove it from Matter too?"),h("Remove",()=>{de(e)},"danger"),h("Keep",()=>{i.confirmingRemoval="",p()})):o("div",{class:"actions"},h(e.status==="online"?"Options":"Reconnect",()=>B([oe(e)])),h("Remove",()=>{i.confirmingRemoval=e.macAddress,p()})))}function he(){let e=i.setup?.devices??[];return[o("header",{},o("h1",{},"Daikin air conditioners"),i.setup?h("Add air conditioners",()=>{N()},"primary"):null),S(),e.length===0&&i.setup?o("p",{class:"empty"},"No air conditioner is set up yet. Add one to control it from Matter."):o("ul",{class:"devices"},...e.map($e)),i.setup?null:h("Try again",()=>{I()},"primary")]}var G={auto:"Auto",silent:"Silent",level1:"Level 1",level2:"Level 2",level3:"Level 3",level4:"Level 4",level5:"Level 5"},_={off:"No swing",vertical:"Up and down",horizontal:"Left and right",both:"3D swing"},R={auto:"Auto",cool:"Cool",heat:"Heat",dehumidify:"Dry",fan:"Fan"},fe={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."}},E={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>'},me="Few apps show a mode select: Home Assistant does, Apple Home does not.";function j(e,t,n){return e.isComposed?n?`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 m(e,t){Object.assign(e,t),p()}function D(e,t,n,s,a,r,c){let d=`${e}-${t}`,l=o("input",{type:"radio",name:e,id:d,checked:t===n,onchange:()=>c(t)});return o("label",{class:"choice pictured",for:d},l,o("span",{class:"glyph",html:r}),o("span",{},o("strong",{},s),o("span",{class:"meta"},a)))}function b(e,t,n,s,a,r){let c=`${e}-${t}`,d=o("input",{type:"radio",name:e,id:c,checked:t===n,onchange:()=>r(t)});return o("label",{class:"choice",for:c},d,o("span",{},o("strong",{},s),o("span",{class:"meta"},a)))}function O(e,t,n,s,a){let r=o("input",{type:"checkbox",id:e,checked:t,onchange:()=>a(r.checked)});return o("label",{class:"choice",for:e},r,o("span",{},o("strong",{},n),o("span",{class:"meta"},s)))}function Te(e,t,n,s,a,r){return o("div",{class:"chips",role:"group","aria-label":t},...n.map(c=>{let d=`${e}-${c}`,l=o("input",{type:"checkbox",id:d,checked:s.includes(c),onchange:()=>r(n.filter(f=>f===c?l.checked:s.includes(f)))});return o("label",{class:"chip",for:d},l,a[c])}))}function Re(e){let t=e.adapter.name,n=`at ${e.adapter.host}`;return t===void 0||t===""?`the air conditioner ${n}`:`the air conditioner named "${t}" in its Daikin app, ${n}`}function Ee(e){let t=o("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||p()});let n=e.adapter.name,s=n===void 0||n===""?"Its adapter has no name of its own.":`Its adapter is named "${n}" in its Daikin app, which other adapters can share.`;return o("section",{},o("h2",{},o("label",{for:"device-name"},"Name in Matter")),o("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.`),o("div",{class:"inline-form"},t))}function De(e,t){return o("section",{class:"presets"},o("h2",{},"Start from a preset"),o("div",{class:"preset-list"},...Object.keys(q).map(n=>o("button",{type:"button",class:"preset","aria-pressed":String(se(e,n,t)),onclick:()=>m(e,L(n,t))},o("strong",{},q[n].title),o("span",{class:"meta"},q[n].text)))),o("p",{class:"help"},"A preset fills in the choices below for what this unit can do. Change any of them afterwards."))}function He(e){let t=e.map(n=>G[n]);return t.length===1?t[0]:`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function Le(e,t,n){if(!t.hasFanAuto||e.fanControl==="hidden"&&e.fanSpeedWhenHidden!=="keep")return null;let s=f=>m(e,{fanAutoControl:f}),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=G[t.fanSteps[0]],d=G[t.fanSteps[t.fanSteps.length-1]],l=a?[b("fan-auto","native",n,"Not shown in Matter","Without a fan speed in Matter, auto has no place there either.",s),b("fan-auto","switch",n,"A switch",r,s)]:[b("fan-auto","native",n,"Native fan mode only","Auto is a mode of the fan speed, beside its speeds, as Matter has it.",s),b("fan-auto","switch",n,"A switch",`${r} Auto stays a fan mode as well.`,s),b("fan-auto","firstStep",n,"The first step",`Auto comes below ${c}: step 1, or the bottom of the slider.`,s),b("fan-auto","lastStep",n,"The last step",`Auto comes above ${d}: the top step, or 100 %.`,s)];return o("div",{class:"field"},o("h3",{id:"fan-auto-title"},"Auto fan speed"),a?null:o("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."),o("div",{class:"choices",role:"radiogroup","aria-labelledby":"fan-auto-title"},...l))}function Fe(e,t){let n=e.capabilities?.fanSpeeds??[];if(t.fanSteps.length===0)return o("section",{},o("h2",{},"Fan speed"),o("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 f=t.hasFanAuto&&!r?" Auto is not among them: it is a fan mode of its own.":"",w=`${d.length} ${d.length===1?"speed":"speeds"}, ${r?"in order":"slowest first"}: ${He(d)}.${f}`;return o("section",{},o("h2",{},"Fan speed"),o("div",{class:"choices"},D("fan","steps",e.fanControl,"Steps",w,E.steps,u=>m(e,{fanControl:u})),D("fan","percent",e.fanControl,"Percentage",`A slider from 0 to 100, which the plugin rounds to the nearest of ${w}`,E.percent,u=>m(e,{fanControl:u})),D("fan","hidden",e.fanControl,"Not shown in Matter","No fan control. Pick below what the plugin does with the fan speed instead.",E.hidden,u=>m(e,{fanControl:u}))),e.fanControl==="hidden"?o("div",{class:"field"},o("label",{for:"fan-fixed"},"When the plugin sends a command, the fan speed"),o("select",{id:"fan-fixed",onchange:u=>m(e,{fanSpeedWhenHidden:u.target.value})},o("option",{value:"keep",selected:e.fanSpeedWhenHidden==="keep"},"stays as it is"),...n.map(u=>o("option",{value:u,selected:e.fanSpeedWhenHidden===u},`is set to ${G[u]}`)))):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.`,u=>m(e,{hasSeparateFan:u})),Le(e,t,a&&!c?"native":e.fanAutoControl))}function Ne(e){let t=e.capabilities?.swingModes??[];if(t.length===0)return o("section",{},o("h2",{},"Swing"),o("p",{class:"help"},"This unit does not let apps move its louvers, so there is nothing to choose."));let n=t.includes("vertical"),s=t.includes("horizontal"),a="One switch, for the up and down swing.";return n&&s?a="Two switches: one for the up and down swing, one for left and right.":s&&(a="One switch, for the left and right swing."),o("section",{},o("h2",{},"Swing"),o("div",{class:"choices"},D("swing","switches",e.swingControl,"Switches",a,E.switches,r=>m(e,{swingControl:r})),D("swing","select",e.swingControl,"A mode select",`${j(e,"Swing",!0)}, and picks one of: ${t.map(r=>r==="both"?_[r]:_[r].toLowerCase()).join(", ")}. ${me}`,E.select,r=>m(e,{swingControl:r})),D("swing","hidden",e.swingControl,"Not shown in Matter","No swing control. Pick below what the plugin does with the swing instead.",E.hidden,r=>m(e,{swingControl:r}))),e.swingControl==="hidden"?o("div",{class:"field"},o("label",{for:"swing-fixed"},"When the plugin sends a command, the swing"),o("select",{id:"swing-fixed",onchange:r=>m(e,{swingModeWhenHidden:r.target.value})},o("option",{value:"keep",selected:e.swingModeWhenHidden==="keep"},"stays as it is"),...t.map(r=>o("option",{value:r,selected:e.swingModeWhenHidden===r},`is set to: ${_[r]}`)))):null)}function Pe(e,t){let n=H(e.modeReplacements,t);return o("div",{class:"replacements"},...t.lackingModes.flatMap(s=>{let a=`mode-replacement-${s}`,r=t.switchableModes.find(l=>n[l]===s),c=Object.fromEntries(Object.entries(n).filter(([,l])=>l!==s)),d=l=>{let f=l.target.value,w={...c};f!==""&&(w[f]=s),m(e,{modeReplacements:H(w,t)})};return[o("label",{for:a},R[s]),o("select",{id:a,onchange:d},o("option",{value:"",selected:r===void 0},"is not offered"),...t.switchableModes.map(l=>o("option",{value:l,selected:r===l,disabled:c[l]!==void 0||!J(l,s,c,t)},`runs ${R[l].toLowerCase()}`)))]}))}function Oe(e,t){let{switchableModes:n,lackingModes:s}=t;if(n.length===0)return null;let a=n.filter(y=>e.modeSwitches.includes(y)),r=n.filter(y=>y==="dehumidify"||y==="fan"),c=r.length>0,d=e.modeControl==="select"&&!c?"native":e.modeControl,l=y=>{y==="switches"&&a.length===0?m(e,{modeControl:y,modeSwitches:c?r:[...n]}):m(e,{modeControl:y})},f=n.includes("cool")?"cool":"heat",w=r.map(y=>R[y].toLowerCase()).join(" and "),u=c?`Off turns the unit off, or from ${w} puts it back in ${f}.`:"Off turns the unit off.",k=`${R[a.length>0?a[0]:n[0]]} Mode`,g=e.isComposed?`Each appears as a part of "${e.name}", tagged with its mode, such as "${k}".`:`Each appears as "${e.name} ${k}", and so on.`,M=s.map(y=>R[y].toLowerCase()),ye=M.length===1?M[0]:`${M.slice(0,-1).join(", ")} or ${M[M.length-1]}`;return o("section",{},o("h2",{},"Modes"),o("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."),o("div",{class:"choices",role:"radiogroup","aria-label":"Modes"},b("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?b("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. ${me}`,l):null,b("mode-control","switches",d,"Switches",`A switch for each mode picked below. On turns the unit on in that mode. ${u}`,l),d==="switches"?o("div",{class:"sub"},Te("mode-switch","Modes that get a switch",n,a,R,y=>m(e,{modeSwitches:y})),o("p",{class:"help"},g)):null),s.length>0?o("div",{class:"field"},o("h3",{},"Modes the unit lacks"),o("p",{class:"help"},`This unit has no ${ye}. 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.`),Pe(e,t)):null)}function je(e,t){return t.specialModes.length===0?null:o("section",{},o("h2",{},"Special modes"),o("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."),o("div",{class:"choices"},...t.specialModes.map(n=>O(`special-${n}`,e.specialModeSwitches.includes(n),`Add a switch for ${fe[n].title}`,fe[n].text,s=>m(e,{specialModeSwitches:t.specialModes.filter(a=>a===n?s:e.specialModeSwitches.includes(a))})))))}function qe(e){return o("section",{},o("h2",{},"Humidity and outdoor temperature"),o("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."),o("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=>m(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=>m(e,{hasOutdoorTemperatureSensor:t}))))}function Ie(e){return o("section",{},o("h2",{},"One device or several"),o("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."),o("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=>m(e,{isComposed:t}))))}function we(){let e=v();if(e===void 0)return[S()];let t=e.controls??ne;return[T(),U(),K(e,`Options for ${Re(e)}. Power, mode and temperature always appear in Matter: choose how the rest appears.`),Ee(e),De(e,t),Fe(e,t),Ne(e),Oe(e,t),je(e,t),qe(e),Ie(e),e.isNew?null:o("p",{class:"help"},"Changing any of these rebuilds this air conditioner in Matter. Your Matter app may take a moment to show the change."),S(),o("div",{class:"footer"},h("Cancel",C),h(e.isNew?`Add ${e.name}`:"Save options",()=>{ce(e)},"primary"))]}function ge(){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 n=e.getPropertyValue(t).trim();n!==""&&document.documentElement.style.setProperty(`--host${t.slice(1)}`,n)}document.documentElement.style.setProperty("--host-font",e.fontFamily)}catch{}}ie({loading:()=>[o("p",{class:"notice working",role:"status"},o("span",{class:"spinner"}),"Loading\u2026")],home:he,find:ue,connect:le,options:we,done:pe});ge();p();I();
|
|
1
|
+
async function k(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 l=await c.json();return"ok"in l?l:{ok:!1,error:l.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 y(){return i.queue[0]}function A(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,swingModeWhenHidden:a,modeControl:r,modeSwitches:c,modeReplacements:l,fanAutoControl:d,hasSeparateFan:p,specialModeSwitches:w,hasOutdoorTemperatureSensor:u,hasSeparateHumiditySensor:C,isComposed:g}=e;return{fanControl:t,fanSpeedWhenHidden:o,swingControl:s,swingModeWhenHidden:a,modeControl:r,modeSwitches:[...c],modeReplacements:{...l},fanAutoControl:d,hasSeparateFan:p,specialModeSwitches:[...w],hasOutdoorTemperatureSensor:u,hasSeparateHumiditySensor:C,isComposed:g}}var ye={fanControl:"steps",fanSpeedWhenHidden:"keep",swingControl:"switches",swingModeWhenHidden:"keep",modeControl:"native",modeSwitches:[],modeReplacements:{},fanAutoControl:"native",hasSeparateFan:!1,specialModeSwitches:[],hasOutdoorTemperatureSensor:!1,hasSeparateHumiditySensor:!1,isComposed:!0},Se=32;function z(e,t){if(e===""||!t.has(e))return e;for(let o=2;;o++){let s=` ${o}`,a=`${e.slice(0,Se-s.length).trimEnd()}${s}`;if(!t.has(a))return a}}function ee(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 te(e){let t=new Set((i.setup?.devices??[]).map(o=>o.name));return e.map(o=>{let s=z(o.name??"",t);return s!==""&&t.add(s),{adapter:o,name:s,isNew:!0,...R(ye)}})}function ne(e){let{capabilities:t,controls:o,name:s,macAddress:a,host:r,protocol:c,requiresRegistration:l,usesHttps:d,requiresLocalPassword:p}=e;return{adapter:{host:r,protocol:c,macAddress:a,requiresRegistration:l,usesHttps:d,requiresLocalPassword:p},name:s,isNew:!1,capabilities:t,controls:o,...R(e)}}var oe={fanSteps:[],hasFanAuto:!1,hasSwing:!1,switchableModes:[],lackingModes:[],specialModes:[]};function Q(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 H(e,t){let o={};for(let s of t.switchableModes){let a=e[s];a!==void 0&&Q(s,a,e,t)&&(o[s]=a)}return o}var q={apple:{title:"Apple Home",text:"Fan speed as a percentage, 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. The swing is not shown and stays as it is."},google:{title:"Google Home",text:"Fan speed as steps, 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. The swing is not shown and stays as it is."},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=o&&t.hasSwing?"native":"hidden",a=o?[]:t.switchableModes.filter(r=>r==="dehumidify"||r==="fan");return{fanControl:t.fanSteps.length===0?"hidden":e==="apple"?"percent":"steps",fanSpeedWhenHidden:"keep",swingControl:s,swingModeWhenHidden:"keep",modeControl:a.length>0?"switches":"native",modeSwitches:a,modeReplacements:{},fanAutoControl:!o&&t.hasFanAuto?"switch":"native",hasSeparateFan:!1,specialModeSwitches:o?[...t.specialModes]:[],hasOutdoorTemperatureSensor:o,hasSeparateHumiditySensor:!o,isComposed:o}}function se(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.modeSwitches=s.modeControl==="switches"?o.switchableModes.filter(l=>s.modeSwitches.includes(l)):[],s.modeReplacements=H(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(l=>s.specialModeSwitches.includes(l)),JSON.stringify(s)===JSON.stringify(L(t,o))}var J;function ie(e){J=e}function h(){let e=document.getElementById("app");if(e===null||J===void 0)return;let t=`${i.screen}:${y()?.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 d of e.querySelectorAll("input[type=text], input[type=password]"))d.id!==""&&c.set(d.id,d.value);if(e.replaceChildren(...J[i.screen]().filter(d=>d!==!1&&d!==null&&d!==void 0)),e.dataset.form=t,!o)return;for(let[d,p]of c){let w=document.getElementById(d);w instanceof HTMLInputElement&&(w.value=p)}if(a==="")return;let l=document.getElementById(a);l?.focus(),r!==void 0&&l instanceof HTMLInputElement&&l.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 I(){let e=await k("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 k("GET state");e.ok&&(i.setup=e.state)}function x(){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()=>k("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 ae(e){let t=await N(`Looking for an adapter at ${e}\u2026`,async()=>k("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 B(e){i.queue=e,i.saved=[],i.handled=[],Z()}async function Z(){let e=y();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 ${A(e)}\u2026`:`Registering with ${A(e)}\u2026`,a=await N(s,async()=>k(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=z(c,ee(e))),i.screen="options"}h()}function re(){let e=i.queue.shift();e!==void 0&&i.handled.push({label:A(e),isSaved:!1}),Z()}async function ce(e){let t=e.name.trim(),o=be(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()=>k("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 Z()}function be(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 X="Matterbridge's own list of devices shows the change once you reload its page.";async function le(e){let t=await N(`Removing ${e.name}\u2026`,async()=>k("DELETE device",void 0,`macAddress=${encodeURIComponent(e.macAddress)}`));i.confirmingRemoval="",t.ok?i.info=`${e.name} is removed. ${X}`: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 f(e,t,o="quiet",s=!1){return n("button",{type:"button",class:`button ${o}`,onclick:t,disabled:s||i.isBusy},e)}function S(){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 U(){let e=y();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",{},A(o)),n("span",{class:"meta"},s===0?t:"Waiting"))))}function K(e,t){return n("header",{class:"unit-header"},n("h1",{},A(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,f("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,f("Register",()=>{o.value.trim()!==""&&P(e,o.value.trim())},"primary")))}function xe(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 de(){let e=y();if(e===void 0)return[S()];let t=e.probe?.status==="unreachable"||e.probe?.status==="failed"||i.error!=="";return[E(),U(),K(e,`Connecting to its adapter at ${e.adapter.host}.`),S(),i.isBusy?null:xe(e),n("div",{class:"footer"},t?f("Try again",()=>{P(e)}):null,f(e.isNew&&i.queue.length>1?"Skip this one":"Cancel",e.isNew&&i.queue.length>1?re:x))]}function pe(){let e=i.saved;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."),n("p",{class:"help"},X),n("div",{class:"footer"},f("Done",x,"primary"))]}function Ce(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 he(){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()!==""&&ae(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")),S(),i.found.length>0?n("ul",{class:"found-list"},...i.found.map(Ce)):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,f("Look it up",o))),n("div",{class:"footer"},f("Search again",()=>{F()}),f("Cancel",x),f(s,()=>B(te(e)),"primary",e.length===0))]}var Y={auto:"auto mode",cool:"cool mode",heat:"heat mode",dehumidify:"dry mode",fan:"fan mode"};function Ae(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={native:"swing as native rocking",switches:"swing as switches",select:"swing as a mode select",hidden:"swing not shown"}[e.swingControl],l=[t?r:"",o?c:""].filter(g=>g!=="").join(", "),d=e.modeControl==="switches"?e.modeSwitches.map(g=>Y[g]):[],p=Object.keys(Y).flatMap(g=>{let M=e.modeReplacements[g];return M===void 0?[]:[`${Y[g]} as ${Y[M].replace(" mode","")}`]}),w=[...d,e.fanAutoControl==="switch"?"auto fan":"",...e.specialModeSwitches].filter(g=>g!==""),u=[w.length===0?"":`a switch for ${w.join(", ")}`,e.modeControl==="select"?"a mode select":"",p.join(" and ")].filter(g=>g!=="").join(" and "),C=e.isComposed?", all as one device":"";return l===""?`${u===""?"power, mode and temperature":u}${C}`:`${u===""?l:`${l}, and ${u}`}${C}`}function $e(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: ${Ae(e)}.`),e.status!=="online"&&e.error?n("p",{class:"meta problem-text"},e.error):null),o?n("div",{class:"actions"},n("span",{class:"meta"},"Remove it from Matter too?"),f("Remove",()=>{le(e)},"danger"),f("Keep",()=>{i.confirmingRemoval="",h()})):n("div",{class:"actions"},f(e.status==="online"?"Options":"Reconnect",()=>B([ne(e)])),f("Remove",()=>{i.confirmingRemoval=e.macAddress,h()})))}function ue(){let e=i.setup?.devices??[];return[n("header",{},n("h1",{},"Daikin air conditioners"),i.setup?f("Add air conditioners",()=>{F()},"primary"):null),S(),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($e)),i.setup?null:f("Try again",()=>{I()},"primary")]}var V={auto:"Auto",silent:"Silent",level1:"Level 1",level2:"Level 2",level3:"Level 3",level4:"Level 4",level5:"Level 5"},_={off:"No swing",vertical:"Up and down",horizontal:"Left and right",both:"3D swing"},D={auto:"Auto",cool:"Cool",heat:"Heat",dehumidify:"Dry",fan:"Fan"},fe={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."}},$={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>'},me="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 m(e,t){Object.assign(e,t),h()}function T(e,t,o,s,a,r,c){let l=`${e}-${t}`,d=n("input",{type:"radio",name:e,id:l,checked:t===o,onchange:()=>c(t)});return n("label",{class:"choice pictured",for:l},d,n("span",{class:"glyph",html:r}),n("span",{},n("strong",{},s),n("span",{class:"meta"},a)))}function b(e,t,o,s,a,r){let c=`${e}-${t}`,l=n("input",{type:"radio",name:e,id:c,checked:t===o,onchange:()=>r(t)});return n("label",{class:"choice",for:c},l,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 Te(e,t,o,s,a,r){return n("div",{class:"chips",role:"group","aria-label":t},...o.map(c=>{let l=`${e}-${c}`,d=n("input",{type:"checkbox",id:l,checked:s.includes(c),onchange:()=>r(o.filter(p=>p===c?d.checked:s.includes(p)))});return n("label",{class:"chip",for:l},d,a[c])}))}function Re(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 Ee(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(q).map(o=>n("button",{type:"button",class:"preset","aria-pressed":String(se(e,o,t)),onclick:()=>m(e,L(o,t))},n("strong",{},q[o].title),n("span",{class:"meta"},q[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 He(e){let t=e.map(o=>V[o]);return t.length===1?t[0]:`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function Le(e,t,o){if(!t.hasFanAuto||e.fanControl==="hidden"&&e.fanSpeedWhenHidden!=="keep")return null;let s=p=>m(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=V[t.fanSteps[0]],l=V[t.fanSteps[t.fanSteps.length-1]],d=a?[b("fan-auto","native",o,"Not shown in Matter","Without a fan speed in Matter, auto has no place there either.",s),b("fan-auto","switch",o,"A switch",r,s)]:[b("fan-auto","native",o,"Native fan mode only","Auto is a mode of the fan speed, beside its speeds, as Matter has it.",s),b("fan-auto","switch",o,"A switch",`${r} Auto stays a fan mode as well.`,s),b("fan-auto","firstStep",o,"The first step",`Auto comes below ${c}: step 1, or the bottom of the slider.`,s),b("fan-auto","lastStep",o,"The last step",`Auto comes above ${l}: 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"},...d))}function Ne(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",l=t.fanSteps;r&&(l=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.":"",w=`${l.length} ${l.length===1?"speed":"speeds"}, ${r?"in order":"slowest first"}: ${He(l)}.${p}`;return n("section",{},n("h2",{},"Fan speed"),n("div",{class:"choices"},T("fan","steps",e.fanControl,"Steps",w,$.steps,u=>m(e,{fanControl:u})),T("fan","percent",e.fanControl,"Percentage",`A slider from 0 to 100, which the plugin rounds to the nearest of ${w}`,$.percent,u=>m(e,{fanControl:u})),T("fan","hidden",e.fanControl,"Not shown in Matter","No fan control. Pick below what the plugin does with the fan speed instead.",$.hidden,u=>m(e,{fanControl:u}))),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:u=>m(e,{fanSpeedWhenHidden:u.target.value})},n("option",{value:"keep",selected:e.fanSpeedWhenHidden==="keep"},"stays as it is"),...o.map(u=>n("option",{value:u,selected:e.fanSpeedWhenHidden===u},`is set to ${V[u]}`)))):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.`,u=>m(e,{hasSeparateFan:u})),Le(e,t,a&&!c?"native":e.fanAutoControl))}function Fe(e,t){let o=e.capabilities?.swingModes??[];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,l=r?" The fan control then has no rocking.":"",d="One switch, for the up and down swing.";return s&&a?d="Two switches: one for the up and down swing, one for left and right.":a&&(d="One switch, for the left and right swing."),n("section",{},n("h2",{},"Swing"),n("div",{class:"choices"},r?T("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 is reported not to handle it well.",$.rocking,p=>m(e,{swingControl:p})):null,T("swing","switches",c,"Switches",`${d}${l}`,$.switches,p=>m(e,{swingControl:p})),T("swing","select",c,"A mode select",`${j(e,"Swing",!0)}, and picks one of: ${o.map(p=>p==="both"?_[p]:_[p].toLowerCase()).join(", ")}.${l} ${me}`,$.select,p=>m(e,{swingControl:p})),T("swing","hidden",c,"Not shown in Matter","No swing control. Pick below what the plugin does with the swing instead.",$.hidden,p=>m(e,{swingControl:p}))),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=>m(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: ${_[p]}`)))):null)}function Pe(e,t){let o=H(e.modeReplacements,t);return n("div",{class:"replacements"},...t.lackingModes.flatMap(s=>{let a=`mode-replacement-${s}`,r=t.switchableModes.find(d=>o[d]===s),c=Object.fromEntries(Object.entries(o).filter(([,d])=>d!==s)),l=d=>{let p=d.target.value,w={...c};p!==""&&(w[p]=s),m(e,{modeReplacements:H(w,t)})};return[n("label",{for:a},D[s]),n("select",{id:a,onchange:l},n("option",{value:"",selected:r===void 0},"is not offered"),...t.switchableModes.map(d=>n("option",{value:d,selected:r===d,disabled:c[d]!==void 0||!Q(d,s,c,t)},`runs ${D[d].toLowerCase()}`)))]}))}function Oe(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,l=e.modeControl==="select"&&!c?"native":e.modeControl,d=v=>{v==="switches"&&a.length===0?m(e,{modeControl:v,modeSwitches:c?r:[...o]}):m(e,{modeControl:v})},p=o.includes("cool")?"cool":"heat",w=r.map(v=>D[v].toLowerCase()).join(" and "),u=c?`Off turns the unit off, or from ${w} puts it back in ${p}.`:"Off turns the unit off.",C=`${D[a.length>0?a[0]:o[0]]} Mode`,g=e.isComposed?`Each appears as a part of "${e.name}", tagged with its mode, such as "${C}".`:`Each appears as "${e.name} ${C}", and so on.`,M=s.map(v=>D[v].toLowerCase()),ve=M.length===1?M[0]:`${M.slice(0,-1).join(", ")} or ${M[M.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"},b("mode-control","native",l,"Native modes only","The modes of the unit are those of the air conditioner, as Matter has them, and nothing more is added.",d),c?b("mode-control","select",l,"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. ${me}`,d):null,b("mode-control","switches",l,"Switches",`A switch for each mode picked below. On turns the unit on in that mode. ${u}`,d),l==="switches"?n("div",{class:"sub"},Te("mode-switch","Modes that get a switch",o,a,D,v=>m(e,{modeSwitches:v})),n("p",{class:"help"},g)):null),s.length>0?n("div",{class:"field"},n("h3",{},"Modes the unit lacks"),n("p",{class:"help"},`This unit has no ${ve}. 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.`),Pe(e,t)):null)}function je(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 ${fe[o].title}`,fe[o].text,s=>m(e,{specialModeSwitches:t.specialModes.filter(a=>a===o?s:e.specialModeSwitches.includes(a))})))))}function qe(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=>m(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=>m(e,{hasOutdoorTemperatureSensor:t}))))}function Ie(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=>m(e,{isComposed:t}))))}function we(){let e=y();if(e===void 0)return[S()];let t=e.controls??oe;return[E(),U(),K(e,`Options for ${Re(e)}. Power, mode and temperature always appear in Matter: choose how the rest appears.`),Ee(e),De(e,t),Ne(e,t),Fe(e,t),Oe(e,t),je(e,t),qe(e),Ie(e),e.isNew?null:n("p",{class:"help"},"Changing any of these rebuilds this air conditioner in Matter. Your Matter app may take a moment to show the change."),S(),n("div",{class:"footer"},f("Cancel",x),f(e.isNew?`Add ${e.name}`:"Save options",()=>{ce(e)},"primary"))]}function ge(){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{}}ie({loading:()=>[n("p",{class:"notice working",role:"status"},n("span",{class:"spinner"}),"Loading\u2026")],home:ue,find:he,connect:de,options:we,done:pe});ge();h();I();
|
|
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.
|
|
@@ -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 * @license Apache-2.0\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 * @license Apache-2.0\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 * @license Apache-2.0\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 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 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 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 = { fanSteps: [], hasFanAuto: false, hasSwing: false, switchableModes: [], lackingModes: [], specialModes: [] };\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 * @license Apache-2.0\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 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. The swing is not shown and stays as it is.',\n },\n google: {\n title: 'Google Home',\n text: 'Fan speed as steps, 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. The swing is not shown and stays as it is.',\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 a mode select, 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 shows a mode select, which Matter has for what it has no cluster for. The\n // other presets leave the swing as it is, rather than add a switch for each axis.\n const swingControl: Exposure['swingControl'] = isMatter && controls.hasSwing ? 'select' : '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 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 // 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 * @license Apache-2.0\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 = 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 * @license Apache-2.0\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\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 * @license Apache-2.0\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 * @license Apache-2.0\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) => h('li', { class: unit.isSaved ? 'done' : 'skipped' }, h('strong', {}, unit.label), h('span', { class: 'meta' }, unit.isSaved ? 'Added' : 'Skipped'))),\n ...view.queue.map((draft, index) =>\n h('li', { 'class': index === 0 ? 'current' : 'ahead', 'aria-current': index === 0 ? 'true' : undefined }, h('strong', {}, draftLabel(draft)), h('span', { class: 'meta' }, index === 0 ? doing : 'Waiting')),\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 * @license Apache-2.0\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('p', { class: 'notice problem', role: 'alert' }, `${draft.name} did not answer at ${draft.adapter.host}. Check that it has power and is on the network, then try again.`);\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 * @license Apache-2.0\n */\n\nimport { goHome, reloadNote } 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 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 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 * @license Apache-2.0\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('span', {}, h('strong', {}, adapter.name ?? 'Unnamed adapter'), h('span', { class: 'meta' }, ` ${adapter.host}`), ...notes.map((note) => h('span', { class: 'meta note' }, note))),\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('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 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 * @license Apache-2.0\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 swing = { switches: 'swing as switches', select: 'swing as a mode select', hidden: 'swing not shown' }[device.swingControl];\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(\n (name) => name !== '',\n );\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 ),\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 * @license Apache-2.0\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};\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};\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('label', { class: 'choice pictured', for: id }, input, h('span', { class: 'glyph', html: glyph }), h('span', {}, h('strong', {}, title), h('span', { class: 'meta' }, text)));\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', { type: 'checkbox', id, checked: picked.includes(value), onchange: () => onpick(values.filter((other) => (other === value ? input.checked : picked.includes(other)))) });\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('p', { class: 'help' }, `${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 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) 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) => update(draft, { fanControl })),\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\nfunction swingSection(draft: Draft): HTMLElement {\n const swingModes = draft.capabilities?.swingModes ?? [];\n if (swingModes.length === 0) 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 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 choice('swing', 'switches', draft.swingControl, 'Switches', switchText, glyphs.switches, (swingControl) => update(draft, { swingControl })),\n choice(\n 'swing',\n 'select',\n draft.swingControl,\n 'A mode select',\n `${placement(draft, 'Swing', true)}, and picks one of: ${swingModes.map((mode) => (mode === 'both' ? swingModeLabels[mode] : swingModeLabels[mode].toLowerCase())).join(', ')}. ${selectSupport}`,\n glyphs.select,\n (swingControl) => update(draft, { swingControl }),\n ),\n choice('swing', 'hidden', draft.swingControl, '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 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// 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 ? `Each appears as a part of \"${draft.name}\", tagged with its mode, such as \"${example}\".` : `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('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 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('mode-control', 'select', current, 'A mode select', `${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}`, pick)\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('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 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),\n modeSection(draft, controls),\n specialSection(draft, controls),\n sensorSection(draft),\n composedSection(draft),\n draft.isNew ? null : h('p', { class: 'help' }, 'Changing any of these rebuilds this air conditioner in Matter. Your Matter app may take a moment to show the change.'),\n notice(),\n h('div', { class: 'footer' }, button('Cancel', goHome), button(draft.isNew ? `Add ${draft.name}` : 'Save options', () => void saveDraft(draft), 'primary')),\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 * @license Apache-2.0\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 * @license Apache-2.0\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": "AAwCA,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,OAAQC,EAAcA,EACnB,CA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AE,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", "query", "method", "path", "init", "response", "reply", "view", "currentDraft", "draftLabel", "draft", "isStored", "adapter", "device", "pickExposure", "source", "fanControl", "fanSpeedWhenHidden", "swingControl", "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", "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", "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", "h", "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", "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", "swingControl", "mode", "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"]
|
|
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 * @license Apache-2.0\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 * @license Apache-2.0\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 * @license Apache-2.0\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 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 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 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 = { fanSteps: [], hasFanAuto: false, hasSwing: false, switchableModes: [], lackingModes: [], specialModes: [] };\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 * @license Apache-2.0\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 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. The swing is not shown and stays as it is.',\n },\n google: {\n title: 'Google Home',\n text: 'Fan speed as steps, 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. The swing is not shown and stays as it is.',\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, or its switches on a unit without a fan\n // control. Home is reported to upset the rocking, and the other presets leave the swing as it is, rather than add a\n // switch for each axis.\n const swingControl: Exposure['swingControl'] = isMatter && controls.hasSwing ? '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 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 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 * @license Apache-2.0\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 = 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 * @license Apache-2.0\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\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 * @license Apache-2.0\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 * @license Apache-2.0\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) => h('li', { class: unit.isSaved ? 'done' : 'skipped' }, h('strong', {}, unit.label), h('span', { class: 'meta' }, unit.isSaved ? 'Added' : 'Skipped'))),\n ...view.queue.map((draft, index) =>\n h('li', { 'class': index === 0 ? 'current' : 'ahead', 'aria-current': index === 0 ? 'true' : undefined }, h('strong', {}, draftLabel(draft)), h('span', { class: 'meta' }, index === 0 ? doing : 'Waiting')),\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 * @license Apache-2.0\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('p', { class: 'notice problem', role: 'alert' }, `${draft.name} did not answer at ${draft.adapter.host}. Check that it has power and is on the network, then try again.`);\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 * @license Apache-2.0\n */\n\nimport { goHome, reloadNote } 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 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 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 * @license Apache-2.0\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('span', {}, h('strong', {}, adapter.name ?? 'Unnamed adapter'), h('span', { class: 'meta' }, ` ${adapter.host}`), ...notes.map((note) => h('span', { class: 'meta note' }, note))),\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('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 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 * @license Apache-2.0\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 swing = { native: 'swing as native rocking', switches: 'swing as switches', select: 'swing as a mode select', hidden: 'swing not shown' }[device.swingControl];\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(\n (name) => name !== '',\n );\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 ),\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 * @license Apache-2.0\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};\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('label', { class: 'choice pictured', for: id }, input, h('span', { class: 'glyph', html: glyph }), h('span', {}, h('strong', {}, title), h('span', { class: 'meta' }, text)));\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', { type: 'checkbox', id, checked: picked.includes(value), onchange: () => onpick(values.filter((other) => (other === value ? input.checked : picked.includes(other)))) });\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('p', { class: 'help' }, `${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 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) 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) => update(draft, { fanControl })),\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 = draft.capabilities?.swingModes ?? [];\n if (swingModes.length === 0) 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 is reported not to handle it well.',\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 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// 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 ? `Each appears as a part of \"${draft.name}\", tagged with its mode, such as \"${example}\".` : `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('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 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('mode-control', 'select', current, 'A mode select', `${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}`, pick)\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('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 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 ? null : h('p', { class: 'help' }, 'Changing any of these rebuilds this air conditioner in Matter. Your Matter app may take a moment to show the change.'),\n notice(),\n h('div', { class: 'footer' }, button('Cancel', goHome), button(draft.isNew ? `Add ${draft.name}` : 'Save options', () => void saveDraft(draft), 'primary')),\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 * @license Apache-2.0\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 * @license Apache-2.0\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": "AAwCA,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,MA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MAAO,EAAG,sHAAsH,EACrKgF,EAAO,EACPhF,EAAE,MAAO,CAAE,MAAO,QAAS,EAAGqF,EAAO,SAAUC,CAAM,EAAGD,EAAOrG,EAAM,MAAQ,OAAOA,EAAM,IAAI,GAAK,eAAgB,IAAG,CAAQuG,GAAUvG,CAAK,GAAG,SAAS,CAAC,CAC5J,CACF,CC9dO,SAASwG,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", "query", "method", "path", "init", "response", "reply", "view", "currentDraft", "draftLabel", "draft", "isStored", "adapter", "device", "pickExposure", "source", "fanControl", "fanSpeedWhenHidden", "swingControl", "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", "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", "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", "h", "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", "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", "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
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SPECIAL_MODES, } from 'daikin-local-control';
|
|
2
|
+
import { Node } from 'matterbridge/matter';
|
|
2
3
|
import { BridgedDeviceBasicInformation, FanControl, ModeSelect, OnOff, Thermostat } from 'matterbridge/matter/clusters';
|
|
3
4
|
import { SWITCHED_MODES } from '../config.js';
|
|
4
5
|
import { addReportedSensors, getSwitchableSpecialModes, noReportedSensors } from '../controls.js';
|
|
@@ -58,6 +59,7 @@ export class DaikinAccessory {
|
|
|
58
59
|
commandTimer;
|
|
59
60
|
queue = Promise.resolve();
|
|
60
61
|
subscriptions = new Map();
|
|
62
|
+
isAwaitingOnline = false;
|
|
61
63
|
constructor(options) {
|
|
62
64
|
this.config = options.config;
|
|
63
65
|
this.capabilities = options.capabilities;
|
|
@@ -75,7 +77,7 @@ export class DaikinAccessory {
|
|
|
75
77
|
this.fan = this.createFan();
|
|
76
78
|
if (this.layout.hasFan)
|
|
77
79
|
this.subscribeFan(this.fan ?? this.endpoint);
|
|
78
|
-
if (this.
|
|
80
|
+
if (this.layout.hasSwingSwitches) {
|
|
79
81
|
if (this.capabilities.swingModes.includes('vertical'))
|
|
80
82
|
this.verticalSwitch = this.createSwingSwitch('vertical');
|
|
81
83
|
if (this.capabilities.swingModes.includes('horizontal'))
|
|
@@ -212,6 +214,15 @@ export class DaikinAccessory {
|
|
|
212
214
|
again();
|
|
213
215
|
if (endpoint === this.endpoint)
|
|
214
216
|
this.log.info(`"${this.name}" is subscribed again after the Matter node was reset`);
|
|
217
|
+
this.refreshWhenOnline(endpoint);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
refreshWhenOnline(endpoint) {
|
|
221
|
+
if (this.isAwaitingOnline)
|
|
222
|
+
return;
|
|
223
|
+
this.isAwaitingOnline = true;
|
|
224
|
+
Node.forEndpoint(endpoint).lifecycle.online.once(() => {
|
|
225
|
+
this.isAwaitingOnline = false;
|
|
215
226
|
void this.refresh();
|
|
216
227
|
});
|
|
217
228
|
}
|
|
@@ -222,6 +233,18 @@ export class DaikinAccessory {
|
|
|
222
233
|
};
|
|
223
234
|
this.listen(endpoint, () => endpoint.subscribeAttribute(FanControl, 'fanMode', onFanWrite));
|
|
224
235
|
this.listen(endpoint, () => endpoint.subscribeAttribute(FanControl, 'percentSetting', onFanWrite));
|
|
236
|
+
const { vertical, horizontal } = this.layout.rockAxes;
|
|
237
|
+
if (!vertical && !horizontal)
|
|
238
|
+
return;
|
|
239
|
+
this.listen(endpoint, () => endpoint.subscribeAttribute('FanControl', 'rockSetting', (setting, _previous, context) => {
|
|
240
|
+
if (!isControllerWrite(context))
|
|
241
|
+
return;
|
|
242
|
+
if (vertical)
|
|
243
|
+
this.pending.requestSwing('vertical', setting.rockUpDown === true);
|
|
244
|
+
if (horizontal)
|
|
245
|
+
this.pending.requestSwing('horizontal', setting.rockLeftRight === true);
|
|
246
|
+
this.scheduleCommand(`rocking ${JSON.stringify({ vertical: setting.rockUpDown === true, horizontal: setting.rockLeftRight === true })}`);
|
|
247
|
+
}));
|
|
225
248
|
}
|
|
226
249
|
createSwitch(key, code, label, onWrite) {
|
|
227
250
|
const endpoint = createSwitchEndpoint(this.identity, key, code, label, this.parent);
|
|
@@ -5,25 +5,28 @@ import { FanControl } from 'matterbridge/matter/clusters';
|
|
|
5
5
|
import { clampTemperature, composeDeviceName, getFanModeSequence } from '../mapping.js';
|
|
6
6
|
const vendorName = 'Daikin';
|
|
7
7
|
function addFanControl(endpoint, layout) {
|
|
8
|
-
const
|
|
8
|
+
const features = [];
|
|
9
|
+
const state = {
|
|
9
10
|
fanMode: FanControl.FanMode.Off,
|
|
10
11
|
fanModeSequence: getFanModeSequence(layout.fanPositions.length, layout.hasFanAuto),
|
|
11
12
|
percentSetting: 0,
|
|
12
13
|
percentCurrent: 0,
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
if (layout.hasFanSteps) {
|
|
16
|
+
features.push(FanControl.Feature.MultiSpeed);
|
|
17
|
+
Object.assign(state, { speedMax: layout.fanPositions.length, speedSetting: 0, speedCurrent: 0 });
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
if (layout.hasFanAuto)
|
|
20
|
+
features.push(FanControl.Feature.Auto);
|
|
21
|
+
const { vertical, horizontal } = layout.rockAxes;
|
|
22
|
+
if (vertical || horizontal) {
|
|
23
|
+
features.push(FanControl.Feature.Rocking);
|
|
24
|
+
Object.assign(state, {
|
|
25
|
+
rockSupport: { rockLeftRight: horizontal, rockUpDown: vertical, rockRound: false },
|
|
26
|
+
rockSetting: { rockLeftRight: false, rockUpDown: false, rockRound: false },
|
|
27
|
+
});
|
|
26
28
|
}
|
|
29
|
+
endpoint.behaviors.require(MatterbridgeFanControlServer.with(...features), state);
|
|
27
30
|
}
|
|
28
31
|
export function createAirConditionerEndpoint(identity, layout) {
|
|
29
32
|
const endpoint = new MatterbridgeEndpoint([roomAirConditioner, bridgedNode, powerSource], { id: identity.serial })
|
package/dist/accessory/layout.js
CHANGED
|
@@ -13,6 +13,8 @@ export function getAccessoryLayout(config, capabilities, reportedSensors) {
|
|
|
13
13
|
const hasFan = config.fanControl !== 'hidden' && fanSteps.length > 0;
|
|
14
14
|
const hasAutoStep = hasFan && capabilities.fanSpeeds.includes('auto') && (config.fanAutoControl === 'firstStep' || config.fanAutoControl === 'lastStep');
|
|
15
15
|
const hasAutoSwitch = config.fanAutoControl === 'switch' && hasFanAuto(capabilities);
|
|
16
|
+
const swingsOn = (axis) => capabilities.swingModes.includes(axis) || capabilities.swingModes.includes('both');
|
|
17
|
+
const hasRocking = hasFan && config.swingControl === 'native';
|
|
16
18
|
let fanPositions = fanSteps;
|
|
17
19
|
if (hasAutoStep)
|
|
18
20
|
fanPositions = config.fanAutoControl === 'firstStep' ? ['auto', ...fanSteps] : [...fanSteps, 'auto'];
|
|
@@ -23,6 +25,8 @@ export function getAccessoryLayout(config, capabilities, reportedSensors) {
|
|
|
23
25
|
fanPositions,
|
|
24
26
|
hasFan,
|
|
25
27
|
hasSeparateFan: hasFan && config.hasSeparateFan,
|
|
28
|
+
rockAxes: { vertical: hasRocking && swingsOn('vertical'), horizontal: hasRocking && swingsOn('horizontal') },
|
|
29
|
+
hasSwingSwitches: config.swingControl === 'switches' || (config.swingControl === 'native' && !hasFan),
|
|
26
30
|
hasFanAuto: capabilities.fanSpeeds.includes('auto') && !hasAutoStep,
|
|
27
31
|
hasFanAutoStep: hasAutoStep,
|
|
28
32
|
hasFanAutoSwitch: hasAutoSwitch,
|
|
@@ -75,10 +75,15 @@ export async function applyState(endpoints, layout, state, sensors) {
|
|
|
75
75
|
await applySetpoint(endpoint, layout, state.mode, state.targetTemperatureInC);
|
|
76
76
|
await applySensors(endpoints, layout, sensors);
|
|
77
77
|
await endpoint.updateAttribute(Thermostat, 'thermostatRunningState', getRunningState(state, sensors));
|
|
78
|
-
if (layout.hasFan)
|
|
79
|
-
await applyFanSpeed(endpoints.fan ?? endpoint, layout, state.fanSpeed);
|
|
80
|
-
await endpoints.fan?.updateAttribute(OnOff, 'onOff', state.power);
|
|
81
78
|
const axes = getSwingAxes(state.swingMode);
|
|
79
|
+
if (layout.hasFan) {
|
|
80
|
+
const fanControl = endpoints.fan ?? endpoint;
|
|
81
|
+
await applyFanSpeed(fanControl, layout, state.fanSpeed);
|
|
82
|
+
const { vertical, horizontal } = layout.rockAxes;
|
|
83
|
+
if (vertical || horizontal)
|
|
84
|
+
await fanControl.updateAttribute('FanControl', 'rockSetting', { rockLeftRight: horizontal && axes.horizontal, rockUpDown: vertical && axes.vertical, rockRound: false });
|
|
85
|
+
}
|
|
86
|
+
await endpoints.fan?.updateAttribute(OnOff, 'onOff', state.power);
|
|
82
87
|
await endpoints.verticalSwitch?.updateAttribute(OnOff, 'onOff', axes.vertical);
|
|
83
88
|
await endpoints.horizontalSwitch?.updateAttribute(OnOff, 'onOff', axes.horizontal);
|
|
84
89
|
for (const [mode, modeSwitch] of endpoints.modeSwitches)
|
package/dist/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DAIKIN_PROTOCOLS, FAN_SPEEDS, SPECIAL_MODES, SWING_MODES, } from 'daikin-local-control';
|
|
2
2
|
import { isValidBoolean, isValidNumber, isValidObject, isValidString } from 'matterbridge/utils';
|
|
3
3
|
export const FAN_CONTROLS = ['steps', 'percent', 'hidden'];
|
|
4
|
-
export const SWING_CONTROLS = ['switches', 'select', 'hidden'];
|
|
4
|
+
export const SWING_CONTROLS = ['native', 'switches', 'select', 'hidden'];
|
|
5
5
|
export const FAN_AUTO_CONTROLS = ['native', 'switch', 'firstStep', 'lastStep'];
|
|
6
6
|
export const MODE_CONTROLS = ['native', 'select', 'switches'];
|
|
7
7
|
export const THERMOSTAT_MODES = ['auto', 'cool', 'heat', 'dehumidify', 'fan'];
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "matterbridge-daikin-local",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "matterbridge-daikin-local",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.9.1",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"daikin-local-control": "0.6.1",
|
|
@@ -100,9 +100,9 @@
|
|
|
100
100
|
}
|
|
101
101
|
},
|
|
102
102
|
"node_modules/undici": {
|
|
103
|
-
"version": "8.12.
|
|
104
|
-
"resolved": "https://registry.npmjs.org/undici/-/undici-8.12.
|
|
105
|
-
"integrity": "sha512
|
|
103
|
+
"version": "8.12.3",
|
|
104
|
+
"resolved": "https://registry.npmjs.org/undici/-/undici-8.12.3.tgz",
|
|
105
|
+
"integrity": "sha512-+fdndUTwBP86cVjihTp21hZHo7d6oj1c/47XPA3lL8mM0XHs+C4EkcjmgRsFnFk2f/UONGDy9ItBItmXsLOQHw==",
|
|
106
106
|
"license": "MIT",
|
|
107
107
|
"engines": {
|
|
108
108
|
"node": ">=22.19.0"
|