matterbridge-daikin-local 0.11.0 → 0.12.0
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 +14 -0
- package/README.md +25 -25
- package/apps/frontend/build/app.js +1 -1
- package/apps/frontend/build/app.js.map +2 -2
- package/dist/accessory/daikinAccessory.js +6 -2
- package/dist/accessory/layout.js +5 -4
- package/dist/accessory/pendingCommand.js +16 -2
- package/dist/controls.js +14 -5
- package/dist/platform/capabilityStore.js +1 -1
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.12.0] - 2026-10-25
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- [devices]: Add a switch for Heat Plus, beside Powerful, Econo and Streamer, on a unit that reports it. A unit takes it in heat alone.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- [package]: Use daikin-local-control 0.7.0: a search reaches the adapters on each network the machine is on, such as Wi-Fi beside a wired one, instead of those on the network of its default route alone. It adds Heat Plus, and sets the louver of an Airbase unit through its position.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- [airbase]: Swing an Airbase unit up and down, the one axis it swings on. The plugin offered it left and right and 3D swing too, and each swing mode it sent held the louver at a fixed position instead. Stopping the swing holds the louver at the position it last held, or at the first of its five positions when it was never seen at one. A device set up before has its swing controls built again at the next restart of Matterbridge.
|
|
20
|
+
|
|
7
21
|
## [0.11.0] - 2026-10-24
|
|
8
22
|
|
|
9
23
|
### Changed
|
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ It is a [Matterbridge](https://matterbridge.io) plugin built on [daikin-local-co
|
|
|
21
21
|
- **It keeps working when an adapter gets a new IP address.** The plugin finds the adapter again and updates the address by itself, so an adapter on the same network as Matterbridge needs no fixed address on your router. Each air conditioner has the name you give it in the setup page, which a new name of its adapter does not change. The other local plugins know an adapter by the address you enter and by its name: see [How devices are stored](#how-devices-are-stored).
|
|
22
22
|
- **It says when a unit stops answering.** After two reads in a row fail, your Matter app shows the air conditioner as unreachable, and it comes back by itself on the first read that works. A unit that is off when Matterbridge starts is still added, from what the plugin stored. None of the other Daikin plugins reports a unit as unreachable.
|
|
23
23
|
- **Almost nothing needs a restart.** Add, rename, reconnect and remove air conditioners while Matterbridge keeps running. A change of how one appears in Matter applies at the next restart, which the setup page and Matterbridge ask for, so that the Matter apps keep it with its room.
|
|
24
|
-
- **It is more than a thermostat.** Besides power, mode and temperature you get the fan speed, the swing, the dry and fan modes, and Powerful, Econo and
|
|
24
|
+
- **It is more than a thermostat.** Besides power, mode and temperature you get the fan speed, the swing, the dry and fan modes, and Powerful, Econo, Streamer and Heat Plus. The humidity appears by itself on a unit that gives it, and the outdoor temperature on a sensor you turn on.
|
|
25
25
|
- **It fits the Matter app you use.** Matter apps differ in what they show, so you choose how each control appears: the fan speed as steps, as a percentage or on a fan of its own, and a switch for each thing your app has no control for. Presets for Apple Home and Google Home give you a starting point: see [Presets](#presets).
|
|
26
26
|
- **It offers only what your unit can do.** The plugin asks each unit which modes, fan speeds, swing and temperature limits it has, builds its controls from the answer, and checks again after every start.
|
|
27
27
|
- **It is quick.** Each unit is read every 5 seconds unless you set otherwise, so what you change on the remote control shows up in your app within seconds. Several changes an app makes together go to the unit as one command.
|
|
@@ -31,7 +31,7 @@ It is a [Matterbridge](https://matterbridge.io) plugin built on [daikin-local-co
|
|
|
31
31
|
|
|
32
32
|
- Matterbridge 3.10.10 or later.
|
|
33
33
|
- Node.js 22.19 or later (22, 24 or 26). Node.js 20 is not supported, because daikin-local-control needs 22.19.
|
|
34
|
-
- Matterbridge on the same network segment as the adapters, for discovery to find them. Adapters on another subnet or VLAN can be added by address.
|
|
34
|
+
- Matterbridge on the same network segment as the adapters, for discovery to find them. It searches each network its machine is on, such as Wi-Fi beside a wired one. Adapters on another subnet or VLAN can be added by address.
|
|
35
35
|
|
|
36
36
|
## Installation
|
|
37
37
|
|
|
@@ -250,7 +250,7 @@ The thermostat mode of the air conditioner follows the unit, whichever control c
|
|
|
250
250
|
|
|
251
251
|
### Special modes
|
|
252
252
|
|
|
253
|
-
Matter has no control for Powerful, Econo and
|
|
253
|
+
Matter has no control for Powerful, Econo, Streamer and Heat Plus, so the setup can add a switch for each one the unit reports, named `<name> Powerful`, `<name> Econo`, `<name> Streamer` and `<name> Heat Plus`. None is added unless you ask for it. A unit takes Heat Plus in heat alone.
|
|
254
254
|
|
|
255
255
|
- A switch is on while the unit reports that special mode as on, including when the unit turned it on or off by itself.
|
|
256
256
|
- Turning a switch on is ignored, and logged, while the unit is in a mode it does not offer that special mode in.
|
|
@@ -303,27 +303,27 @@ Three other Matterbridge plugins expose Daikin units. Which one fits depends fir
|
|
|
303
303
|
|
|
304
304
|
This plugin is the only one of the four that finds the adapters itself, that speaks to classic, DSIOT (BRP084) and Airbase (BRP15B61) adapters, and that connects to an adapter which wants its KEY or a child lock code. It is also the only local one that follows an adapter to a new address, and the only one of the four that reports a unit which stops answering as unreachable. The others have strengths of their own: matterbridge-daikin-device controls the humidity, the ventilation and an air purifier, and matterbridge-daikin-onecta is the one for a unit that only the Onecta cloud reaches.
|
|
305
305
|
|
|
306
|
-
|
|
|
307
|
-
|
|
|
308
|
-
| Connection
|
|
309
|
-
| Units
|
|
310
|
-
| Built on
|
|
311
|
-
| Adding a unit
|
|
312
|
-
| KEY and child lock code
|
|
313
|
-
| New address or name
|
|
314
|
-
| A unit that stops answering
|
|
315
|
-
| Thermostat modes
|
|
316
|
-
| Controls
|
|
317
|
-
| Fan speed
|
|
318
|
-
| Swing
|
|
319
|
-
| Powerful, Econo and
|
|
320
|
-
| Humidity
|
|
321
|
-
| Outdoor temperature
|
|
322
|
-
| Other devices
|
|
323
|
-
| How often a unit is read
|
|
324
|
-
| Node.js
|
|
325
|
-
| Documentation
|
|
326
|
-
| License
|
|
306
|
+
| | matterbridge-daikin-local (this plugin) | [matterbridge-daikin-ac](https://github.com/andrasg/matterbridge-daikin-ac) | [matterbridge-daikin-device](https://github.com/lltcggie/matterbridge-daikin-device) | [matterbridge-daikin-onecta](https://github.com/mehmetc/matterbridge-daikin-onecta) |
|
|
307
|
+
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- |
|
|
308
|
+
| Connection | Local network, no cloud | Local network, no cloud | Local network, no cloud | Daikin Onecta cloud: needs internet, a Daikin Developer Portal app and a sign-in in a browser |
|
|
309
|
+
| Units | Those with a classic (BRP069, BRP072), DSIOT (BRP084) or Airbase (BRP15B61) adapter, from the DAIKIN Mobile Controller, Daikin Airbase and ONECTA apps | Those with a classic adapter that answers over plain HTTP, which [daikin-controller](https://github.com/Apollon77/daikin-controller) talks to. Not Onecta units | Those with a DSIOT adapter that is a room air conditioner or an air purifier: it turns down any other. Tested on the AN22ZRS air conditioner and the ACK70Z air purifier | Units in the Onecta app: air conditioners and heat pumps |
|
|
310
|
+
| Built on | [daikin-local-control](https://github.com/cheziyi/daikin-local-control), a library by the same author that works on its own | [daikin-controller](https://github.com/Apollon77/daikin-controller) | Its own DSIOT code | [daikin-controller-cloud](https://github.com/Apollon77/daikin-controller-cloud) |
|
|
311
|
+
| Adding a unit | A search of the network and a guided setup page, or by address. No restart | IP addresses in the plugin settings, then a restart | IP addresses in the plugin settings, then a restart | Every unit of the account, with a white list and a black list |
|
|
312
|
+
| KEY and child lock code | Asked for in the setup page, by the adapters that need them | Not supported: it cannot connect to an adapter that wants its KEY or a child lock code | Not supported: it cannot connect to an adapter with a child lock code. DSIOT adapters have no KEY | Neither applies: it signs in to the Daikin cloud |
|
|
313
|
+
| New address or name | Found again by the MAC address of its adapter, so no fixed address is needed. Its name is the one you give it, which a new name of the adapter does not change, and which the Matter apps take without losing the device | The address is changed in the settings. A new name makes a new device in Matter, which is known by its name | The address is changed in the settings, then a restart. A new name makes a new device in Matter, which is known by its name | Neither applies: each unit is known by its cloud ID |
|
|
314
|
+
| A unit that stops answering | Shown as unreachable after two failed reads. One that is off at the start is still added, from what was stored | Not shown. One that does not answer within 90 seconds of the start is left out until the next restart | Not shown. One that does not answer at the start is left out until the next restart | Not shown, even while the cloud reports the unit offline |
|
|
315
|
+
| 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 |
|
|
316
|
+
| 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 |
|
|
317
|
+
| 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 |
|
|
318
|
+
| 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 |
|
|
319
|
+
| Powerful, Econo, Streamer and Heat Plus | An optional switch for each | No | No | A switch for Powerful |
|
|
320
|
+
| 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 |
|
|
321
|
+
| 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 |
|
|
322
|
+
| Other devices | None | None | The ACK70Z air purifier, with its humidifier, its water tank and its air quality sensors. An optional switch that raises or lowers the setpoint by 0.5 °C | None |
|
|
323
|
+
| How often a unit is read | Every 5 seconds, or what you set from 2 to 3600 | Every 3 seconds, or what you set from 2 | Every 6 seconds. No setting | Every 10 minutes by day and 30 by night, or what you set from 5. Daikin allows 200 calls a day |
|
|
324
|
+
| Node.js | 22.19 or later, 24 and 26 | 24 and 26 | 20, 22 and 24 | 20.19 or later, 22.13 or later, 24 and 26 |
|
|
325
|
+
| Documentation | English | English | Japanese | English |
|
|
326
|
+
| License | Apache-2.0 | MIT | Apache-2.0 | Apache-2.0 |
|
|
327
327
|
|
|
328
328
|
The table is read from the README, the settings and the source of matterbridge-daikin-ac 2.0.0 and the daikin-controller library it uses, matterbridge-daikin-device 1.0.2 and matterbridge-daikin-onecta 0.1.1, in October 2026. None of the three was run for it.
|
|
329
329
|
|
|
@@ -362,7 +362,7 @@ A stored device that this version of the plugin cannot read, for example one sto
|
|
|
362
362
|
- **Changing how the fan, the swing, any switch or any sensor appears** takes effect at the next restart of Matterbridge, which the setup page and Matterbridge ask for. Until then the air conditioner keeps its current controls.
|
|
363
363
|
- **The settings and the setup page do not overlap.** The Terminal ID and the poll interval are set in the plugin's settings in Matterbridge, and the air conditioners in the setup page. A save of the settings never changes the air conditioners.
|
|
364
364
|
- **The setup page is as open as Matterbridge itself.** Anyone who can reach the Matterbridge frontend can use it. It never returns a stored child lock code.
|
|
365
|
-
- **A ducted unit on an Airbase adapter** gets the controls of any other unit: power, mode, target temperature, fan speed and swing. Its zones, its fan auto and its airside are not in Matter. A unit with zones reports no auto fan speed and no swing, so it gets neither, and an Airbase adapter asks for no KEY and no child lock code.
|
|
365
|
+
- **A ducted unit on an Airbase adapter** gets the controls of any other unit: power, mode, target temperature, fan speed and swing. It swings up and down alone, and stopping the swing holds its louver at the position it last held, or at the first of its five positions when it was never seen at one. Its zones, its fan auto and its airside are not in Matter. A unit with zones reports no auto fan speed and no swing, so it gets neither, and an Airbase adapter asks for no KEY and no child lock code.
|
|
366
366
|
- **Local HTTPS.** Adapters that speak HTTPS present a certificate from Daikin's own CA, which is not verified: see [Local HTTPS](https://github.com/cheziyi/daikin-local-control#local-https).
|
|
367
367
|
|
|
368
368
|
## Development
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
async function M(e,t,o){try{let[s,a]=e.split(" "),r={method:s};t!==void 0&&(r.headers={"Content-Type":"application/json"},r.body=JSON.stringify(t));let c=await fetch(new URL(`api/${a}${o===void 0?"":`?${o}`}`,document.baseURI),r);if(c.status===204)return{ok:!0};if(c.status===503)return{ok:!1,error:"The plugin is not running. Start it in Matterbridge, then reload this page."};let d=await c.json();return"ok"in d?d:{ok:!1,error:d.error??`The plugin answered with status ${c.status}`}}catch{return{ok:!1,error:"Matterbridge did not answer. Check that it is running, then try again."}}}var i={screen:"loading",setup:void 0,found:[],selected:new Set,queue:[],saved:[],handled:[],isBusy:!1,busyText:"",error:"",info:"",confirmingRemoval:""};function S(){return i.queue[0]}function C(e){return e.name===""?e.adapter.host:e.name}function G(e){return(i.setup?.devices??[]).some(t=>t.macAddress===e.macAddress)}function R(e){let{fanControl:t,fanSpeedWhenHidden:o,swingControl:s,swingAxes:a,swingModeWhenHidden:r,modeControl:c,modeSwitches:d,modeReplacements:l,fanAutoControl:p,hasSeparateFan:w,specialModeSwitches:m,hasOutdoorTemperatureSensor:x,hasSeparateHumiditySensor:T,isComposed:g}=e;return{fanControl:t,fanSpeedWhenHidden:o,swingControl:s,swingAxes:a,swingModeWhenHidden:r,modeControl:c,modeSwitches:[...d],modeReplacements:{...l},fanAutoControl:p,hasSeparateFan:w,specialModeSwitches:[...m],hasOutdoorTemperatureSensor:x,hasSeparateHumiditySensor:T,isComposed:g}}var Se={fanControl:"steps",fanSpeedWhenHidden:"keep",swingControl:"switches",swingAxes:"both",swingModeWhenHidden:"keep",modeControl:"native",modeSwitches:[],modeReplacements:{},fanAutoControl:"native",hasSeparateFan:!1,specialModeSwitches:[],hasOutdoorTemperatureSensor:!1,hasSeparateHumiditySensor:!1,isComposed:!0},be=32;function Q(e,t){if(e===""||!t.has(e))return e;for(let o=2;;o++){let s=` ${o}`,a=`${e.slice(0,be-s.length).trimEnd()}${s}`;if(!t.has(a))return a}}function te(e){let t=(i.setup?.devices??[]).filter(s=>s.macAddress!==e.adapter.macAddress).map(s=>s.name),o=i.queue.filter(s=>s!==e).map(s=>s.name);return new Set([...t,...o].filter(s=>s!==""))}function ne(e){let t=new Set((i.setup?.devices??[]).map(o=>o.name));return e.map(o=>{let s=Q(o.name??"",t);return s!==""&&t.add(s),{adapter:o,name:s,isNew:!0,...R(Se)}})}function oe(e){let{capabilities:t,controls:o,name:s,macAddress:a,host:r,protocol:c,requiresRegistration:d,usesHttps:l,requiresLocalPassword:p}=e;return{adapter:{host:r,protocol:c,macAddress:a,requiresRegistration:d,usesHttps:l,requiresLocalPassword:p},name:s,isNew:!1,capabilities:t,controls:o,...R(e)}}var se={fanSteps:[],hasFanAuto:!1,hasSwing:!1,swingsOnBothAxes:!1,switchableModes:[],lackingModes:[],specialModes:[]};function J(e,t,o,s){if(!s.switchableModes.includes(e)||!s.lackingModes.includes(t))return!1;let a=s.switchableModes.filter(c=>c!==e).map(c=>o[c]);if(a.includes(t))return!1;if(t!=="auto")return!0;let r=new Set([...s.switchableModes,...a]);return r.has("cool")&&r.has("heat")}function D(e,t){let o={};for(let s of t.switchableModes){let a=e[s];a!==void 0&&J(s,a,e,t)&&(o[s]=a)}return o}var I={apple:{title:"Apple Home",text:"Fan speed as a percentage, the swing as the rocking of the fan on one axis, the humidity on a sensor of its own too, and a switch for auto fan and for each of dry and fan, each a device of its own."},google:{title:"Google Home",text:"Fan speed as steps, the swing as the rocking of the fan on one axis, the humidity on a sensor of its own too, and a switch for auto fan and for each of dry and fan, each a device of its own."},matter:{title:"Full Matter support",text:"For apps that show every Matter control: fan speed as steps with its auto mode, the swing as the rocking of the fan, a switch for each special mode and the outdoor temperature, all as one device."}};function L(e,t){let o=e==="matter",s=t.hasSwing&&(o||t.fanSteps.length>0),a=s?"native":"hidden",r=o?[]:t.switchableModes.filter(c=>c==="dehumidify"||c==="fan");return{fanControl:t.fanSteps.length===0?"hidden":e==="apple"?"percent":"steps",fanSpeedWhenHidden:"keep",swingControl:a,swingAxes:!o&&s&&t.swingsOnBothAxes?"horizontal":"both",swingModeWhenHidden:"keep",modeControl:r.length>0?"switches":"native",modeSwitches:r,modeReplacements:{},fanAutoControl:!o&&t.hasFanAuto?"switch":"native",hasSeparateFan:!1,specialModeSwitches:o?[...t.specialModes]:[],hasOutdoorTemperatureSensor:o,hasSeparateHumiditySensor:!o,isComposed:o}}function ie(e,t,o){let s=R(e);o.fanSteps.length===0&&Object.assign(s,{fanControl:"hidden",fanSpeedWhenHidden:"keep"}),s.fanControl==="hidden"&&(s.hasSeparateFan=!1);let a=s.fanAutoControl==="firstStep"||s.fanAutoControl==="lastStep",r=s.fanControl==="hidden"&&s.fanSpeedWhenHidden!=="keep";return(!o.hasFanAuto||a&&s.fanControl==="hidden"||r)&&(s.fanAutoControl="native"),o.hasSwing||Object.assign(s,{swingControl:"hidden",swingModeWhenHidden:"keep"}),s.fanControl==="hidden"&&s.swingControl==="switches"&&(s.swingControl="native"),(s.swingControl!=="native"&&s.swingControl!=="switches"||!o.swingsOnBothAxes)&&(s.swingAxes="both"),s.modeSwitches=s.modeControl==="switches"?o.switchableModes.filter(d=>s.modeSwitches.includes(d)):[],s.modeReplacements=D(s.modeReplacements,o),{native:!0,select:o.switchableModes.includes("dehumidify")||o.switchableModes.includes("fan"),switches:s.modeSwitches.length>0}[s.modeControl]||(s.modeControl="native"),s.specialModeSwitches=o.specialModes.filter(d=>s.specialModeSwitches.includes(d)),JSON.stringify(s)===JSON.stringify(L(t,o))}var Z;function ae(e){Z=e}function h(){let e=document.getElementById("app");if(e===null||Z===void 0)return;let t=`${i.screen}:${S()?.adapter.host??""}`,o=e.dataset.form===t,s=document.activeElement,a=s instanceof HTMLElement?s.id:"",r=s instanceof HTMLInputElement&&(s.type==="text"||s.type==="password")?{start:s.selectionStart,end:s.selectionEnd}:void 0,c=new Map;for(let l of e.querySelectorAll("input[type=text], input[type=password]"))l.id!==""&&c.set(l.id,l.value);if(e.replaceChildren(...Z[i.screen]().filter(l=>l!==!1&&l!==null&&l!==void 0)),e.dataset.form=t,!o)return;for(let[l,p]of c){let w=document.getElementById(l);w instanceof HTMLInputElement&&(w.value=p)}if(a==="")return;let d=document.getElementById(a);d?.focus(),r!==void 0&&d instanceof HTMLInputElement&&d.setSelectionRange(r.start,r.end)}async function N(e,t){i.isBusy=!0,i.busyText=e,i.error="",i.info="",h();try{return await t()}finally{i.isBusy=!1,h()}}async function B(){let e=await M("GET state");if(!e.ok){i.error=e.error,i.screen="home",h();return}if(i.setup=e.state,e.state.devices.length===0){await F();return}i.screen="home",h()}async function W(){let e=await M("GET state");e.ok&&(i.setup=e.state)}function k(){i.queue=[],i.saved=[],i.handled=[],i.error="",i.info="",i.screen="home",W().then(h),h()}async function F(){i.screen="find";let e=await N("Searching your network. This takes about three seconds\u2026",async()=>M("POST discover"));if(!e.ok){i.error=`The search did not run: ${e.error}`,h();return}await W();let t=i.found.filter(o=>!e.devices.some(s=>s.host===o.host)&&i.selected.has(o.host)).map(o=>({...o,isConfigured:G(o)}));i.found=[...e.devices,...t];for(let o of e.devices)o.isConfigured||i.selected.add(o.host);h()}async function re(e){let t=await N(`Looking for an adapter at ${e}\u2026`,async()=>M("POST identify",{host:e}));if(!t.ok){i.error=t.error,h();return}let o=G(t.device),s=t.device.requiresRegistration===!0;i.found=[...i.found.filter(a=>a.host!==t.device.host),{...t.device,isConfigured:o,needsRegistration:s}],o||i.selected.add(t.device.host),h()}function U(e){i.queue=e,i.saved=[],i.handled=[],X()}async function X(){let e=S();if(e===void 0){i.screen=i.saved.length>0?"done":"home",await W(),h();return}i.screen="connect",i.error="",i.info="",e.probe=void 0,h(),await P(e)}async function P(e,t){let o={device:e.adapter,localPassword:e.localPassword,key:t},s=t===void 0?`Checking ${C(e)}\u2026`:`Registering with ${C(e)}\u2026`,a=await N(s,async()=>M(t===void 0?"POST probe":"POST register",o));if(!a.ok){i.error=a.error,h();return}if(e.probe=a.result,e.adapter=a.result.device,a.result.status==="ready"){let r=e.controls===void 0;e.capabilities=a.result.capabilities,e.controls=a.result.controls,e.isNew&&r&&e.controls!==void 0&&Object.assign(e,L("apple",e.controls));let c=a.result.device.name??"";e.name===""&&c!==""&&(e.name=Q(c,te(e))),i.screen="options"}h()}function ce(){let e=i.queue.shift();e!==void 0&&i.handled.push({label:C(e),isSaved:!1}),X()}async function le(e){let t=e.name.trim(),o=xe(e,t);if(o!==""){i.error=o,h();return}let{adapter:s,localPassword:a}=e,r={...s,name:t,localPassword:a,...R(e)},c=await N(`Saving ${t}\u2026`,async()=>M("POST device",{device:r}));if(!c.ok){i.error=c.error,h();return}i.setup=c.state,i.saved.push(t),i.handled.push({label:t,isSaved:!0}),i.queue.shift(),await X()}function xe(e,t){return t===""?"Give the air conditioner a name: it is the name it gets in Matter.":(i.setup?.devices??[]).some(s=>s.name===t&&s.macAddress!==e.adapter.macAddress)?`"${t}" is already the name of another air conditioner. Pick a different one.`:""}var _="Matterbridge's own list of devices shows the change once you reload its page.",de="Restart Matterbridge to apply the new options in Matter: until then the air conditioner keeps its current controls.";async function pe(e){let t=await N(`Removing ${e.name}\u2026`,async()=>M("DELETE device",void 0,`macAddress=${encodeURIComponent(e.macAddress)}`));i.confirmingRemoval="",t.ok?i.info=`${e.name} is removed. ${_}`:i.error=t.error,await W(),h()}function n(e,t={},...o){let s=document.createElement(e);for(let[a,r]of Object.entries(t))r===void 0||r===!1||(a==="class"?s.className=String(r):a==="html"?s.innerHTML=String(r):a.startsWith("on")&&typeof r=="function"?s.addEventListener(a.slice(2),r):a in s?s[a]=r:s.setAttribute(a,String(r)));for(let a of o)a!==!1&&a!==null&&a!==void 0&&s.append(a);return s}function u(e,t,o="quiet",s=!1){return n("button",{type:"button",class:`button ${o}`,onclick:t,disabled:s||i.isBusy},e)}function b(){return i.isBusy?n("p",{class:"notice working",role:"status"},n("span",{class:"spinner"}),i.busyText):i.error!==""?n("p",{class:"notice problem",role:"alert"},i.error):i.info!==""?n("p",{class:"notice",role:"status"},i.info):null}function K(){let e=S();if(e===void 0||!e.isNew||i.handled.length+i.queue.length<2)return null;let t=i.screen==="connect"?"Connecting":"Choosing options";return n("ol",{class:"units","aria-label":"Air conditioners in this setup"},...i.handled.map(o=>n("li",{class:o.isSaved?"done":"skipped"},n("strong",{},o.label),n("span",{class:"meta"},o.isSaved?"Added":"Skipped"))),...i.queue.map((o,s)=>n("li",{class:s===0?"current":"ahead","aria-current":s===0?"true":void 0},n("strong",{},C(o)),n("span",{class:"meta"},s===0?t:"Waiting"))))}function z(e,t){return n("header",{class:"unit-header"},n("h1",{},C(e)),n("p",{class:"meta"},t))}function E(){if(i.queue.length>0&&!i.queue.some(s=>s.isNew))return null;let e=["Find","Connect","Options"],o=["find","connect","options"].indexOf(i.screen);return n("ol",{class:"steps"},...e.map((s,a)=>{let r="ahead";return a<o?r="done":a===o&&(r="current"),n("li",{class:r,"aria-current":a===o?"step":void 0},s)}))}function Me(e,t){let o=n("input",{type:"password",id:"lock-code",inputMode:"numeric",autocomplete:"off",maxLength:64});return n("div",{class:"field"},n("label",{for:"lock-code"},"Child lock code"),n("p",{class:"help"},"The 4-digit code set under Child lock in the Daikin app the adapter was set up with. It is not printed on the adapter."),t?n("p",{class:"problem-text"},"The adapter did not accept that code."):null,n("div",{class:"inline-form"},o,u("Check the code",()=>{o.value!==""&&(e.localPassword=o.value,P(e))},"primary")))}function ke(e,t){let o=n("input",{type:"text",id:"adapter-key",autocomplete:"off",spellcheck:!1,maxLength:64});return n("div",{class:"field"},n("label",{for:"adapter-key"},"KEY on the adapter"),n("p",{class:"help"},"This adapter only answers apps it has registered. The KEY is printed on its label, next to the SSID, and in the operation manual. It is used once and not stored."),t?n("p",{class:"problem-text"},"The adapter did not accept that KEY."):null,n("div",{class:"inline-form"},o,u("Register",()=>{o.value.trim()!==""&&P(e,o.value.trim())},"primary")))}function Ce(e){let t=e.probe?.status;return t==="localPasswordRequired"||t==="localPasswordRejected"?Me(e,t==="localPasswordRejected"):t==="registrationRequired"||t==="registrationRejected"?ke(e,t==="registrationRejected"):t==="unreachable"?n("p",{class:"notice problem",role:"alert"},`${e.name} did not answer at ${e.adapter.host}. Check that it has power and is on the network, then try again.`):t==="failed"?n("p",{class:"notice problem",role:"alert"},`${e.name} answered with an error: ${e.probe?.message??"unknown"}`):null}function he(){let e=S();if(e===void 0)return[b()];let t=e.probe?.status==="unreachable"||e.probe?.status==="failed"||i.error!=="";return[E(),K(),z(e,`Connecting to its adapter at ${e.adapter.host}.`),b(),i.isBusy?null:Ce(e),n("div",{class:"footer"},t?u("Try again",()=>{P(e)}):null,u(e.isNew&&i.queue.length>1?"Skip this one":"Cancel",e.isNew&&i.queue.length>1?ce:k))]}function ue(){let e=i.saved,t=(i.setup?.devices??[]).some(o=>e.includes(o.name)&&o.needsRestart);return[n("header",{},n("h1",{},e.length===1?`${e[0]} is set up`:`${e.length} air conditioners are set up`)),n("p",{class:"lead"},"They now appear in the Matter apps paired with Matterbridge. If Matterbridge is not paired yet, pair it from its home page."),t?n("p",{class:"help"},n("strong",{},de)):null,n("p",{class:"help"},_),n("div",{class:"footer"},u("Done",k,"primary"))]}function Ae(e){let t=!e.isConfigured,o=[];e.isConfigured&&o.push("Already set up."),e.name===void 0&&o.push("It has not told its name yet: you will name it in its options."),t&&e.needsRegistration?o.push("Asks for the KEY printed on its label."):t&&e.requiresRegistration&&o.push("Already registered with this plugin, so it will not ask for its KEY."),t&&e.requiresLocalPassword&&o.push("Asks for its child lock code.");let s=n("input",{type:"checkbox",id:`found-${e.host}`,checked:t&&i.selected.has(e.host),disabled:!t,onchange:()=>{s.checked?i.selected.add(e.host):i.selected.delete(e.host),h()}});return n("li",{class:t?"found":"found unavailable"},n("label",{for:`found-${e.host}`},s,n("span",{},n("strong",{},e.name??"Unnamed adapter"),n("span",{class:"meta"},` ${e.host}`),...o.map(a=>n("span",{class:"meta note"},a)))))}function fe(){let e=i.found.filter(a=>i.selected.has(a.host)&&!a.isConfigured),t=n("input",{type:"text",id:"host",placeholder:"192.168.1.50",spellcheck:!1,autocomplete:"off"}),o=()=>{t.value.trim()!==""&&re(t.value.trim())};t.addEventListener("keydown",a=>{a.key==="Enter"&&o()});let s=e.length===1?"Set up 1 air conditioner":`Set up ${e.length} air conditioners`;return[E(),n("header",{},n("h1",{},"Find your air conditioners")),b(),i.found.length>0?n("ul",{class:"found-list"},...i.found.map(Ae)):null,!i.isBusy&&i.found.length===0?n("p",{class:"empty"},"No adapter answered. A search only reaches adapters on the same network segment as Matterbridge: add the others by address below."):null,n("details",{class:"manual",open:!i.isBusy&&i.found.length===0},n("summary",{},"Can't see your air conditioner?"),n("p",{class:"help"},"Enter the address of its adapter. The plugin reads the name of the adapter there and follows it to a new address like any other, as long as a search can reach it. An adapter on another subnet or VLAN keeps this address."),n("div",{class:"inline-form"},n("label",{for:"host",class:"visually-hidden"},"Adapter address"),t,u("Look it up",o))),n("div",{class:"footer"},u("Search again",()=>{F()}),u("Cancel",k),u(s,()=>U(ne(e)),"primary",e.length===0))]}var V={auto:"auto mode",cool:"cool mode",heat:"heat mode",dehumidify:"dry mode",fan:"fan mode"};function $e(e){let t=e.controls===void 0||e.controls.fanSteps.length>0,o=e.controls===void 0||e.controls.hasSwing,s=e.hasSeparateFan?" on a fan of its own":"",a={native:"",switch:"",firstStep:" with auto first",lastStep:" with auto last"}[e.fanAutoControl],r=e.fanControl==="hidden"?"fan speed not shown":`fan speed as ${e.fanControl==="steps"?"steps":"a percentage"}${a}${s}`,c={both:"",vertical:" up and down",horizontal:" left and right"}[e.swingAxes],d={native:`swing as native rocking${c}`,switches:`swing as switches${c}`,select:"swing as a mode select",hidden:"swing not shown"}[e.swingControl],l=[t?r:"",o?d:""].filter(g=>g!=="").join(", "),p=e.modeControl==="switches"?e.modeSwitches.map(g=>V[g]):[],w=Object.keys(V).flatMap(g=>{let q=e.modeReplacements[g];return q===void 0?[]:[`${V[g]} as ${V[q].replace(" mode","")}`]}),m=[...p,e.fanAutoControl==="switch"?"auto fan":"",...e.specialModeSwitches].filter(g=>g!==""),x=[m.length===0?"":`a switch for ${m.join(", ")}`,e.modeControl==="select"?"a mode select":"",w.join(" and ")].filter(g=>g!=="").join(" and "),T=e.isComposed?", all as one device":"";return l===""?`${x===""?"power, mode and temperature":x}${T}`:`${x===""?l:`${l}, and ${x}`}${T}`}function Te(e){let t={online:"Online",offline:"Not answering",stopped:"Not started"}[e.status],o=i.confirmingRemoval===e.macAddress;return n("li",{class:"device"},n("div",{class:"device-main"},n("h3",{},e.name),n("p",{class:"meta"},n("span",{class:`status ${e.status}`},t),` at ${e.host}. In Matter: ${$e(e)}.`),e.status!=="online"&&e.error?n("p",{class:"meta problem-text"},e.error):null,e.needsRestart?n("p",{class:"meta"},n("strong",{},"Restart Matterbridge")," to apply the new options in Matter. Until then it keeps its current controls."):null),o?n("div",{class:"actions"},n("span",{class:"meta"},"Remove it from Matter too?"),u("Remove",()=>{pe(e)},"danger"),u("Keep",()=>{i.confirmingRemoval="",h()})):n("div",{class:"actions"},u(e.status==="online"?"Options":"Reconnect",()=>U([oe(e)])),u("Remove",()=>{i.confirmingRemoval=e.macAddress,h()})))}function me(){let e=i.setup?.devices??[];return[n("header",{},n("h1",{},"Daikin air conditioners"),i.setup?u("Add air conditioners",()=>{F()},"primary"):null),b(),e.length===0&&i.setup?n("p",{class:"empty"},"No air conditioner is set up yet. Add one to control it from Matter."):n("ul",{class:"devices"},...e.map(Te)),i.setup?null:u("Try again",()=>{B()},"primary")]}var Y={auto:"Auto",silent:"Silent",level1:"Level 1",level2:"Level 2",level3:"Level 3",level4:"Level 4",level5:"Level 5"},ee={off:"No swing",vertical:"Up and down",horizontal:"Left and right",both:"3D swing"},H={auto:"Auto",cool:"Cool",heat:"Heat",dehumidify:"Dry",fan:"Fan"},ge={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."}},A={steps:'<svg viewBox="0 0 48 28" aria-hidden="true"><rect x="2" y="20" width="8" height="6"/><rect x="14" y="14" width="8" height="12"/><rect x="26" y="8" width="8" height="18"/><rect x="38" y="2" width="8" height="24"/></svg>',percent:'<svg viewBox="0 0 48 28" aria-hidden="true"><path d="M2 26 L46 2 L46 26 Z"/></svg>',hidden:'<svg viewBox="0 0 48 28" aria-hidden="true"><path class="stroke" d="M6 14 H42" stroke-dasharray="3 5"/></svg>',switches:'<svg viewBox="0 0 48 28" aria-hidden="true"><path class="stroke" d="M12 4 V24 M7 9 L12 4 L17 9 M7 19 L12 24 L17 19"/><path class="stroke" d="M26 14 H46 M31 9 L26 14 L31 19 M41 9 L46 14 L41 19"/></svg>',select:'<svg viewBox="0 0 48 28" aria-hidden="true"><rect class="stroke" x="3" y="5" width="42" height="18" rx="4"/><path class="stroke" d="M31 12 L35 16 L39 12"/></svg>',rocking:'<svg viewBox="0 0 48 28" aria-hidden="true"><path class="stroke" d="M8 20 Q24 0 40 20"/><path class="stroke" d="M8 13 V20 H15 M40 13 V20 H33"/></svg>'},we="Few apps show a mode select: Home Assistant does, Apple Home does not.";function j(e,t,o){return e.isComposed?o?`It appears as a part of "${e.name}", tagged "${t}"`:`It appears as a part of "${e.name}"`:`It appears as "${e.name} ${t}"`}function f(e,t){Object.assign(e,t),h()}function $(e,t,o,s,a,r,c){let d=`${e}-${t}`,l=n("input",{type:"radio",name:e,id:d,checked:t===o,onchange:()=>c(t)});return n("label",{class:"choice pictured",for:d},l,n("span",{class:"glyph",html:r}),n("span",{},n("strong",{},s),n("span",{class:"meta"},a)))}function y(e,t,o,s,a,r){let c=`${e}-${t}`,d=n("input",{type:"radio",name:e,id:c,checked:t===o,onchange:()=>r(t)});return n("label",{class:"choice",for:c},d,n("span",{},n("strong",{},s),n("span",{class:"meta"},a)))}function O(e,t,o,s,a){let r=n("input",{type:"checkbox",id:e,checked:t,onchange:()=>a(r.checked)});return n("label",{class:"choice",for:e},r,n("span",{},n("strong",{},o),n("span",{class:"meta"},s)))}function Re(e,t,o,s,a,r){return n("div",{class:"chips",role:"group","aria-label":t},...o.map(c=>{let d=`${e}-${c}`,l=n("input",{type:"checkbox",id:d,checked:s.includes(c),onchange:()=>r(o.filter(p=>p===c?l.checked:s.includes(p)))});return n("label",{class:"chip",for:d},l,a[c])}))}function Ee(e){let t=e.adapter.name,o=`at ${e.adapter.host}`;return t===void 0||t===""?`the air conditioner ${o}`:`the air conditioner named "${t}" in its Daikin app, ${o}`}function He(e){let t=n("input",{type:"text",id:"device-name",value:e.name,maxLength:32,autocomplete:"off",spellcheck:!1});t.addEventListener("input",a=>{e.name=t.value.trim(),a.isComposing||h()});let o=e.adapter.name,s=o===void 0||o===""?"Its adapter has no name of its own.":`Its adapter is named "${o}" in its Daikin app, which other adapters can share.`;return n("section",{},n("h2",{},n("label",{for:"device-name"},"Name in Matter")),n("p",{class:"help"},`${s} The name here is what your Matter apps show, up to 32 characters, and no two air conditioners of this plugin share one. A new name of the adapter does not change it.`),n("div",{class:"inline-form"},t))}function De(e,t){return n("section",{class:"presets"},n("h2",{},"Start from a preset"),n("div",{class:"preset-list"},...Object.keys(I).map(o=>n("button",{type:"button",class:"preset","aria-pressed":String(ie(e,o,t)),onclick:()=>f(e,L(o,t))},n("strong",{},I[o].title),n("span",{class:"meta"},I[o].text)))),n("p",{class:"help"},"A preset fills in the choices below for what this unit can do. Change any of them afterwards."))}function Le(e){let t=e.map(o=>Y[o]);return t.length===1?t[0]:`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function Ne(e,t,o){if(!t.hasFanAuto||e.fanControl==="hidden"&&e.fanSpeedWhenHidden!=="keep")return null;let s=p=>f(e,{fanAutoControl:p}),a=e.fanControl==="hidden",r=`${j(e,"Auto Fan",!0)}. On sets the fan to auto, off puts it back at the speed it last ran at.`,c=Y[t.fanSteps[0]],d=Y[t.fanSteps[t.fanSteps.length-1]],l=a?[y("fan-auto","native",o,"Not shown in Matter","Without a fan speed in Matter, auto has no place there either.",s),y("fan-auto","switch",o,"A switch",r,s)]:[y("fan-auto","native",o,"Native fan mode only","Auto is a mode of the fan speed, beside its speeds, as Matter has it.",s),y("fan-auto","switch",o,"A switch",`${r} Auto stays a fan mode as well.`,s),y("fan-auto","firstStep",o,"The first step",`Auto comes below ${c}: step 1, or the bottom of the slider.`,s),y("fan-auto","lastStep",o,"The last step",`Auto comes above ${d}: the top step, or 100 %.`,s)];return n("div",{class:"field"},n("h3",{id:"fan-auto-title"},"Auto fan speed"),a?null:n("p",{class:"help"},"Matter has auto as a fan mode, which not every app shows. A switch makes it reachable there too, and a step takes its place."),n("div",{class:"choices",role:"radiogroup","aria-labelledby":"fan-auto-title"},...l))}function Fe(e,t){let o=e.capabilities?.fanSpeeds??[];if(t.fanSteps.length===0)return n("section",{},n("h2",{},"Fan speed"),n("p",{class:"help"},"This unit does not let apps set its fan speed, so there is nothing to choose."));let a=e.fanControl==="hidden",r=t.hasFanAuto&&!a&&(e.fanAutoControl==="firstStep"||e.fanAutoControl==="lastStep"),c=t.hasFanAuto&&e.fanAutoControl==="switch",d=t.fanSteps;r&&(d=e.fanAutoControl==="firstStep"?["auto",...t.fanSteps]:[...t.fanSteps,"auto"]);let p=t.hasFanAuto&&!r?" Auto is not among them: it is a fan mode of its own.":"",w=`${d.length} ${d.length===1?"speed":"speeds"}, ${r?"in order":"slowest first"}: ${Le(d)}.${p}`;return n("section",{},n("h2",{},"Fan speed"),n("div",{class:"choices"},$("fan","steps",e.fanControl,"Steps",w,A.steps,m=>f(e,{fanControl:m})),$("fan","percent",e.fanControl,"Percentage",`A slider from 0 to 100, which the plugin rounds to the nearest of ${w}`,A.percent,m=>f(e,{fanControl:m})),$("fan","hidden",e.fanControl,"Not shown in Matter","No fan control. Pick below what the plugin does with the fan speed instead.",A.hidden,m=>f(e,{fanControl:m}))),e.fanControl==="hidden"?n("div",{class:"field"},n("label",{for:"fan-fixed"},"When the plugin sends a command, the fan speed"),n("select",{id:"fan-fixed",onchange:m=>f(e,{fanSpeedWhenHidden:m.target.value})},n("option",{value:"keep",selected:e.fanSpeedWhenHidden==="keep"},"stays as it is"),...o.map(m=>n("option",{value:m,selected:e.fanSpeedWhenHidden===m},`is set to ${Y[m]}`)))):null,e.fanControl==="hidden"?null:O("separate-fan",e.hasSeparateFan,"Show the fan as a device of its own",`${j(e,"Fan",!1)}, and the air conditioner has no fan speed of its own. For apps that show no fan speed on an air conditioner, or do not show it well. It always shows the speed the unit holds, also while the unit is off.`,m=>f(e,{hasSeparateFan:m})),Ne(e,t,a&&!c?"native":e.fanAutoControl))}function Pe(e,t){let 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,d=r?" The fan control then has no rocking.":"",l="One switch, for the up and down swing.";return s&&a?l="Two switches: one for the up and down swing, one for left and right.":a&&(l="One switch, for the left and right swing."),n("section",{},n("h2",{},"Swing"),n("div",{class:"choices"},r?$("swing","native",c,"Native rocking","The rocking of the fan control, as Matter has it: up and down for the vertical swing, left and right for the horizontal. Not every app shows it, and Apple Home shows it as a single Oscillate on/off.",A.rocking,p=>f(e,{swingControl:p})):null,$("swing","switches",c,"Switches",`${l}${d}`,A.switches,p=>f(e,{swingControl:p})),$("swing","select",c,"A mode select",`${j(e,"Swing",!0)}, and picks one of: ${o.map(p=>p==="both"?ee[p]:ee[p].toLowerCase()).join(", ")}.${d} ${we}`,A.select,p=>f(e,{swingControl:p})),$("swing","hidden",c,"Not shown in Matter","No swing control. Pick below what the plugin does with the swing instead.",A.hidden,p=>f(e,{swingControl:p}))),c==="native"&&t.swingsOnBothAxes||c==="switches"&&s&&a?Oe(e,c==="native"):null,e.swingControl==="hidden"?n("div",{class:"field"},n("label",{for:"swing-fixed"},"When the plugin sends a command, the swing"),n("select",{id:"swing-fixed",onchange:p=>f(e,{swingModeWhenHidden:p.target.value})},n("option",{value:"keep",selected:e.swingModeWhenHidden==="keep"},"stays as it is"),...o.map(p=>n("option",{value:p,selected:e.swingModeWhenHidden===p},`is set to: ${ee[p]}`)))):null)}function Oe(e,t){let o=r=>f(e,{swingAxes:r}),s="The other axis has no control in Matter, and stays as it is.",a=t?"Some apps, such as Apple Home, show the rocking as a single Oscillate on/off. One axis alone makes that switch swing the louvers on it.":"One switch alone, for the axis picked, instead of a switch for each axis.";return n("div",{class:"field"},n("h3",{id:"swing-axes-title"},t?"Rocking axes":"Switch axes"),n("p",{class:"help"},a),n("div",{class:"choices",role:"radiogroup","aria-labelledby":"swing-axes-title"},y("swing-axes","both",e.swingAxes,"Both axes",t?"Up and down, and left and right, each rocking on its own.":"A switch for up and down, and one for left and right.",o),y("swing-axes","vertical",e.swingAxes,"Up and down alone",s,o),y("swing-axes","horizontal",e.swingAxes,"Left and right alone",s,o)))}function je(e,t){let o=D(e.modeReplacements,t);return n("div",{class:"replacements"},...t.lackingModes.flatMap(s=>{let a=`mode-replacement-${s}`,r=t.switchableModes.find(l=>o[l]===s),c=Object.fromEntries(Object.entries(o).filter(([,l])=>l!==s)),d=l=>{let p=l.target.value,w={...c};p!==""&&(w[p]=s),f(e,{modeReplacements:D(w,t)})};return[n("label",{for:a},H[s]),n("select",{id:a,onchange:d},n("option",{value:"",selected:r===void 0},"is not offered"),...t.switchableModes.map(l=>n("option",{value:l,selected:r===l,disabled:c[l]!==void 0||!J(l,s,c,t)},`runs ${H[l].toLowerCase()}`)))]}))}function qe(e,t){let{switchableModes:o,lackingModes:s}=t;if(o.length===0)return null;let a=o.filter(v=>e.modeSwitches.includes(v)),r=o.filter(v=>v==="dehumidify"||v==="fan"),c=r.length>0,d=e.modeControl==="select"&&!c?"native":e.modeControl,l=v=>{v==="switches"&&a.length===0?f(e,{modeControl:v,modeSwitches:c?r:[...o]}):f(e,{modeControl:v})},p=o.includes("cool")?"cool":"heat",w=r.map(v=>H[v].toLowerCase()).join(" and "),m=c?`Off turns the unit off, or from ${w} puts it back in ${p}.`:"Off turns the unit off.",x=`${H[a.length>0?a[0]:o[0]]} Mode`,T=e.isComposed?`Each appears as a part of "${e.name}", tagged with its mode, such as "${x}".`:`Each appears as "${e.name} ${x}", and so on.`,g=s.map(v=>H[v].toLowerCase()),q=g.length===1?g[0]:`${g.slice(0,-1).join(", ")} or ${g[g.length-1]}`;return n("section",{},n("h2",{},"Modes"),n("p",{class:"help"},"Every mode of the unit is a mode of the air conditioner in Matter, but some apps, such as Apple Home and Google Home, only offer off, cool, heat and auto."),n("div",{class:"choices",role:"radiogroup","aria-label":"Modes"},y("mode-control","native",d,"Native modes only","The modes of the unit are those of the air conditioner, as Matter has them, and nothing more is added.",l),c?y("mode-control","select",d,"A mode select",`${j(e,"Mode",!0)}, with Off and every mode of the unit, as the air conditioner has them. Picking a mode turns the unit on in it. ${we}`,l):null,y("mode-control","switches",d,"Switches",`A switch for each mode picked below. On turns the unit on in that mode. ${m}`,l),d==="switches"?n("div",{class:"sub"},Re("mode-switch","Modes that get a switch",o,a,H,v=>f(e,{modeSwitches:v})),n("p",{class:"help"},T)):null),s.length>0?n("div",{class:"field"},n("h3",{},"Modes the unit lacks"),n("p",{class:"help"},`This unit has no ${q}. Each can run one of its modes instead, such as heat running dry on a unit that only cools: an app then reaches that mode from the modes it offers, and nothing is added to Matter. The air conditioner shows the mode picked while the unit is in it, with its setpoint. Auto is offered once the air conditioner both cools and heats, counting these.`),je(e,t)):null)}function Ie(e,t){return t.specialModes.length===0?null:n("section",{},n("h2",{},"Special modes"),n("p",{class:"help"},"Matter has no control for these, so each can get a switch of its own. A switch only takes effect in the modes this unit offers that special mode in."),n("div",{class:"choices"},...t.specialModes.map(o=>O(`special-${o}`,e.specialModeSwitches.includes(o),`Add a switch for ${ge[o].title}`,ge[o].text,s=>f(e,{specialModeSwitches:t.specialModes.filter(a=>a===o?s:e.specialModeSwitches.includes(a))})))))}function Be(e){return n("section",{},n("h2",{},"Humidity and outdoor temperature"),n("p",{class:"help"},"No adapter says which readings its unit has, so each of these takes effect once the unit gives that reading. The room temperature and the humidity are always on the air conditioner."),n("div",{class:"choices"},O("separate-humidity",e.hasSeparateHumiditySensor,"Also show the humidity on a sensor of its own",`${j(e,"Humidity",!1)}, and the air conditioner keeps its humidity. For apps that show no humidity on an air conditioner, which Apple Home is reported to be.`,t=>f(e,{hasSeparateHumiditySensor:t})),O("outdoor-sensor",e.hasOutdoorTemperatureSensor,"Add a sensor for the outdoor temperature",`It appears as "${e.name} Outdoor Temperature". It is a device of its own, which you can put in another room, such as outside. Until you do, a Matter app may show the outdoor temperature as that of the room it put the sensor in. Some units give no outdoor temperature while they are idle: the sensor then shows no value.`,t=>f(e,{hasOutdoorTemperatureSensor:t}))))}function We(e){return n("section",{},n("h2",{},"One device or several"),n("p",{class:"help"},"The switches, a fan of its own and a humidity sensor of its own can be parts of the air conditioner in Matter, or devices of their own beside it. The outdoor temperature sensor is always a device of its own, so that you can put it in another room than the air conditioner."),n("div",{class:"choices"},O("composed",e.isComposed,"Make them parts of the air conditioner",`Your Matter app has one device, "${e.name}", and they move between rooms with it. A part has no name of its own in Matter, so an app may show the switches as numbered outlets, and an app that shows no parts shows the air conditioner alone. Turned off, each is a device of its own with its own name, which your app puts in a room by itself.`,t=>f(e,{isComposed:t}))))}function ve(){let e=S();if(e===void 0)return[b()];let t=e.controls??se;return[E(),K(),z(e,`Options for ${Ee(e)}. Power, mode and temperature always appear in Matter: choose how the rest appears.`),He(e),De(e,t),Fe(e,t),Pe(e,t),qe(e,t),Ie(e,t),Be(e),We(e),e.isNew?null:n("p",{class:"help"},"A change of any of these applies at the next restart of Matterbridge. A switch or a sensor you add is new in your Matter app, in its default room, and one you remove is gone."),b(),n("div",{class:"footer"},u("Cancel",k),u(e.isNew?`Add ${e.name}`:"Save options",()=>{le(e)},"primary"))]}function ye(){try{if(window.parent===window)return;let e=getComputedStyle(window.parent.document.body);for(let t of["--primary-color","--div-bg-color","--div-text-color","--main-bg-color","--main-label-color","--div-border-color","--main-light-color"]){let o=e.getPropertyValue(t).trim();o!==""&&document.documentElement.style.setProperty(`--host${t.slice(1)}`,o)}document.documentElement.style.setProperty("--host-font",e.fontFamily)}catch{}}ae({loading:()=>[n("p",{class:"notice working",role:"status"},n("span",{class:"spinner"}),"Loading\u2026")],home:me,find:fe,connect:he,options:ve,done:ue});ye();h();B();
|
|
1
|
+
async function M(e,t,o){try{let[s,a]=e.split(" "),r={method:s};t!==void 0&&(r.headers={"Content-Type":"application/json"},r.body=JSON.stringify(t));let c=await fetch(new URL(`api/${a}${o===void 0?"":`?${o}`}`,document.baseURI),r);if(c.status===204)return{ok:!0};if(c.status===503)return{ok:!1,error:"The plugin is not running. Start it in Matterbridge, then reload this page."};let d=await c.json();return"ok"in d?d:{ok:!1,error:d.error??`The plugin answered with status ${c.status}`}}catch{return{ok:!1,error:"Matterbridge did not answer. Check that it is running, then try again."}}}var i={screen:"loading",setup:void 0,found:[],selected:new Set,queue:[],saved:[],handled:[],isBusy:!1,busyText:"",error:"",info:"",confirmingRemoval:""};function S(){return i.queue[0]}function C(e){return e.name===""?e.adapter.host:e.name}function G(e){return(i.setup?.devices??[]).some(t=>t.macAddress===e.macAddress)}function R(e){let{fanControl:t,fanSpeedWhenHidden:o,swingControl:s,swingAxes:a,swingModeWhenHidden:r,modeControl:c,modeSwitches:d,modeReplacements:l,fanAutoControl:p,hasSeparateFan:g,specialModeSwitches:m,hasOutdoorTemperatureSensor:x,hasSeparateHumiditySensor:T,isComposed:w}=e;return{fanControl:t,fanSpeedWhenHidden:o,swingControl:s,swingAxes:a,swingModeWhenHidden:r,modeControl:c,modeSwitches:[...d],modeReplacements:{...l},fanAutoControl:p,hasSeparateFan:g,specialModeSwitches:[...m],hasOutdoorTemperatureSensor:x,hasSeparateHumiditySensor:T,isComposed:w}}var Se={fanControl:"steps",fanSpeedWhenHidden:"keep",swingControl:"switches",swingAxes:"both",swingModeWhenHidden:"keep",modeControl:"native",modeSwitches:[],modeReplacements:{},fanAutoControl:"native",hasSeparateFan:!1,specialModeSwitches:[],hasOutdoorTemperatureSensor:!1,hasSeparateHumiditySensor:!1,isComposed:!0},be=32;function Q(e,t){if(e===""||!t.has(e))return e;for(let o=2;;o++){let s=` ${o}`,a=`${e.slice(0,be-s.length).trimEnd()}${s}`;if(!t.has(a))return a}}function te(e){let t=(i.setup?.devices??[]).filter(s=>s.macAddress!==e.adapter.macAddress).map(s=>s.name),o=i.queue.filter(s=>s!==e).map(s=>s.name);return new Set([...t,...o].filter(s=>s!==""))}function ne(e){let t=new Set((i.setup?.devices??[]).map(o=>o.name));return e.map(o=>{let s=Q(o.name??"",t);return s!==""&&t.add(s),{adapter:o,name:s,isNew:!0,...R(Se)}})}function oe(e){let{capabilities:t,controls:o,name:s,macAddress:a,host:r,protocol:c,requiresRegistration:d,usesHttps:l,requiresLocalPassword:p}=e;return{adapter:{host:r,protocol:c,macAddress:a,requiresRegistration:d,usesHttps:l,requiresLocalPassword:p},name:s,isNew:!1,capabilities:t,controls:o,...R(e)}}var se={fanSteps:[],hasFanAuto:!1,hasSwing:!1,swingModes:[],swingsOnBothAxes:!1,switchableModes:[],lackingModes:[],specialModes:[]};function J(e,t,o,s){if(!s.switchableModes.includes(e)||!s.lackingModes.includes(t))return!1;let a=s.switchableModes.filter(c=>c!==e).map(c=>o[c]);if(a.includes(t))return!1;if(t!=="auto")return!0;let r=new Set([...s.switchableModes,...a]);return r.has("cool")&&r.has("heat")}function D(e,t){let o={};for(let s of t.switchableModes){let a=e[s];a!==void 0&&J(s,a,e,t)&&(o[s]=a)}return o}var I={apple:{title:"Apple Home",text:"Fan speed as a percentage, the swing as the rocking of the fan on one axis, the humidity on a sensor of its own too, and a switch for auto fan and for each of dry and fan, each a device of its own."},google:{title:"Google Home",text:"Fan speed as steps, the swing as the rocking of the fan on one axis, the humidity on a sensor of its own too, and a switch for auto fan and for each of dry and fan, each a device of its own."},matter:{title:"Full Matter support",text:"For apps that show every Matter control: fan speed as steps with its auto mode, the swing as the rocking of the fan, a switch for each special mode and the outdoor temperature, all as one device."}};function L(e,t){let o=e==="matter",s=t.hasSwing&&(o||t.fanSteps.length>0),a=s?"native":"hidden",r=o?[]:t.switchableModes.filter(c=>c==="dehumidify"||c==="fan");return{fanControl:t.fanSteps.length===0?"hidden":e==="apple"?"percent":"steps",fanSpeedWhenHidden:"keep",swingControl:a,swingAxes:!o&&s&&t.swingsOnBothAxes?"horizontal":"both",swingModeWhenHidden:"keep",modeControl:r.length>0?"switches":"native",modeSwitches:r,modeReplacements:{},fanAutoControl:!o&&t.hasFanAuto?"switch":"native",hasSeparateFan:!1,specialModeSwitches:o?[...t.specialModes]:[],hasOutdoorTemperatureSensor:o,hasSeparateHumiditySensor:!o,isComposed:o}}function ie(e,t,o){let s=R(e);o.fanSteps.length===0&&Object.assign(s,{fanControl:"hidden",fanSpeedWhenHidden:"keep"}),s.fanControl==="hidden"&&(s.hasSeparateFan=!1);let a=s.fanAutoControl==="firstStep"||s.fanAutoControl==="lastStep",r=s.fanControl==="hidden"&&s.fanSpeedWhenHidden!=="keep";return(!o.hasFanAuto||a&&s.fanControl==="hidden"||r)&&(s.fanAutoControl="native"),o.hasSwing||Object.assign(s,{swingControl:"hidden",swingModeWhenHidden:"keep"}),s.fanControl==="hidden"&&s.swingControl==="switches"&&(s.swingControl="native"),(s.swingControl!=="native"&&s.swingControl!=="switches"||!o.swingsOnBothAxes)&&(s.swingAxes="both"),s.modeSwitches=s.modeControl==="switches"?o.switchableModes.filter(d=>s.modeSwitches.includes(d)):[],s.modeReplacements=D(s.modeReplacements,o),{native:!0,select:o.switchableModes.includes("dehumidify")||o.switchableModes.includes("fan"),switches:s.modeSwitches.length>0}[s.modeControl]||(s.modeControl="native"),s.specialModeSwitches=o.specialModes.filter(d=>s.specialModeSwitches.includes(d)),JSON.stringify(s)===JSON.stringify(L(t,o))}var Z;function ae(e){Z=e}function h(){let e=document.getElementById("app");if(e===null||Z===void 0)return;let t=`${i.screen}:${S()?.adapter.host??""}`,o=e.dataset.form===t,s=document.activeElement,a=s instanceof HTMLElement?s.id:"",r=s instanceof HTMLInputElement&&(s.type==="text"||s.type==="password")?{start:s.selectionStart,end:s.selectionEnd}:void 0,c=new Map;for(let l of e.querySelectorAll("input[type=text], input[type=password]"))l.id!==""&&c.set(l.id,l.value);if(e.replaceChildren(...Z[i.screen]().filter(l=>l!==!1&&l!==null&&l!==void 0)),e.dataset.form=t,!o)return;for(let[l,p]of c){let g=document.getElementById(l);g instanceof HTMLInputElement&&(g.value=p)}if(a==="")return;let d=document.getElementById(a);d?.focus(),r!==void 0&&d instanceof HTMLInputElement&&d.setSelectionRange(r.start,r.end)}async function N(e,t){i.isBusy=!0,i.busyText=e,i.error="",i.info="",h();try{return await t()}finally{i.isBusy=!1,h()}}async function B(){let e=await M("GET state");if(!e.ok){i.error=e.error,i.screen="home",h();return}if(i.setup=e.state,e.state.devices.length===0){await F();return}i.screen="home",h()}async function W(){let e=await M("GET state");e.ok&&(i.setup=e.state)}function k(){i.queue=[],i.saved=[],i.handled=[],i.error="",i.info="",i.screen="home",W().then(h),h()}async function F(){i.screen="find";let e=await N("Searching your network. This takes about three seconds\u2026",async()=>M("POST discover"));if(!e.ok){i.error=`The search did not run: ${e.error}`,h();return}await W();let t=i.found.filter(o=>!e.devices.some(s=>s.host===o.host)&&i.selected.has(o.host)).map(o=>({...o,isConfigured:G(o)}));i.found=[...e.devices,...t];for(let o of e.devices)o.isConfigured||i.selected.add(o.host);h()}async function re(e){let t=await N(`Looking for an adapter at ${e}\u2026`,async()=>M("POST identify",{host:e}));if(!t.ok){i.error=t.error,h();return}let o=G(t.device),s=t.device.requiresRegistration===!0;i.found=[...i.found.filter(a=>a.host!==t.device.host),{...t.device,isConfigured:o,needsRegistration:s}],o||i.selected.add(t.device.host),h()}function U(e){i.queue=e,i.saved=[],i.handled=[],X()}async function X(){let e=S();if(e===void 0){i.screen=i.saved.length>0?"done":"home",await W(),h();return}i.screen="connect",i.error="",i.info="",e.probe=void 0,h(),await P(e)}async function P(e,t){let o={device:e.adapter,localPassword:e.localPassword,key:t},s=t===void 0?`Checking ${C(e)}\u2026`:`Registering with ${C(e)}\u2026`,a=await N(s,async()=>M(t===void 0?"POST probe":"POST register",o));if(!a.ok){i.error=a.error,h();return}if(e.probe=a.result,e.adapter=a.result.device,a.result.status==="ready"){let r=e.controls===void 0;e.capabilities=a.result.capabilities,e.controls=a.result.controls,e.isNew&&r&&e.controls!==void 0&&Object.assign(e,L("apple",e.controls));let c=a.result.device.name??"";e.name===""&&c!==""&&(e.name=Q(c,te(e))),i.screen="options"}h()}function ce(){let e=i.queue.shift();e!==void 0&&i.handled.push({label:C(e),isSaved:!1}),X()}async function le(e){let t=e.name.trim(),o=xe(e,t);if(o!==""){i.error=o,h();return}let{adapter:s,localPassword:a}=e,r={...s,name:t,localPassword:a,...R(e)},c=await N(`Saving ${t}\u2026`,async()=>M("POST device",{device:r}));if(!c.ok){i.error=c.error,h();return}i.setup=c.state,i.saved.push(t),i.handled.push({label:t,isSaved:!0}),i.queue.shift(),await X()}function xe(e,t){return t===""?"Give the air conditioner a name: it is the name it gets in Matter.":(i.setup?.devices??[]).some(s=>s.name===t&&s.macAddress!==e.adapter.macAddress)?`"${t}" is already the name of another air conditioner. Pick a different one.`:""}var _="Matterbridge's own list of devices shows the change once you reload its page.",de="Restart Matterbridge to apply the new options in Matter: until then the air conditioner keeps its current controls.";async function pe(e){let t=await N(`Removing ${e.name}\u2026`,async()=>M("DELETE device",void 0,`macAddress=${encodeURIComponent(e.macAddress)}`));i.confirmingRemoval="",t.ok?i.info=`${e.name} is removed. ${_}`:i.error=t.error,await W(),h()}function n(e,t={},...o){let s=document.createElement(e);for(let[a,r]of Object.entries(t))r===void 0||r===!1||(a==="class"?s.className=String(r):a==="html"?s.innerHTML=String(r):a.startsWith("on")&&typeof r=="function"?s.addEventListener(a.slice(2),r):a in s?s[a]=r:s.setAttribute(a,String(r)));for(let a of o)a!==!1&&a!==null&&a!==void 0&&s.append(a);return s}function u(e,t,o="quiet",s=!1){return n("button",{type:"button",class:`button ${o}`,onclick:t,disabled:s||i.isBusy},e)}function b(){return i.isBusy?n("p",{class:"notice working",role:"status"},n("span",{class:"spinner"}),i.busyText):i.error!==""?n("p",{class:"notice problem",role:"alert"},i.error):i.info!==""?n("p",{class:"notice",role:"status"},i.info):null}function K(){let e=S();if(e===void 0||!e.isNew||i.handled.length+i.queue.length<2)return null;let t=i.screen==="connect"?"Connecting":"Choosing options";return n("ol",{class:"units","aria-label":"Air conditioners in this setup"},...i.handled.map(o=>n("li",{class:o.isSaved?"done":"skipped"},n("strong",{},o.label),n("span",{class:"meta"},o.isSaved?"Added":"Skipped"))),...i.queue.map((o,s)=>n("li",{class:s===0?"current":"ahead","aria-current":s===0?"true":void 0},n("strong",{},C(o)),n("span",{class:"meta"},s===0?t:"Waiting"))))}function z(e,t){return n("header",{class:"unit-header"},n("h1",{},C(e)),n("p",{class:"meta"},t))}function E(){if(i.queue.length>0&&!i.queue.some(s=>s.isNew))return null;let e=["Find","Connect","Options"],o=["find","connect","options"].indexOf(i.screen);return n("ol",{class:"steps"},...e.map((s,a)=>{let r="ahead";return a<o?r="done":a===o&&(r="current"),n("li",{class:r,"aria-current":a===o?"step":void 0},s)}))}function Me(e,t){let o=n("input",{type:"password",id:"lock-code",inputMode:"numeric",autocomplete:"off",maxLength:64});return n("div",{class:"field"},n("label",{for:"lock-code"},"Child lock code"),n("p",{class:"help"},"The 4-digit code set under Child lock in the Daikin app the adapter was set up with. It is not printed on the adapter."),t?n("p",{class:"problem-text"},"The adapter did not accept that code."):null,n("div",{class:"inline-form"},o,u("Check the code",()=>{o.value!==""&&(e.localPassword=o.value,P(e))},"primary")))}function ke(e,t){let o=n("input",{type:"text",id:"adapter-key",autocomplete:"off",spellcheck:!1,maxLength:64});return n("div",{class:"field"},n("label",{for:"adapter-key"},"KEY on the adapter"),n("p",{class:"help"},"This adapter only answers apps it has registered. The KEY is printed on its label, next to the SSID, and in the operation manual. It is used once and not stored."),t?n("p",{class:"problem-text"},"The adapter did not accept that KEY."):null,n("div",{class:"inline-form"},o,u("Register",()=>{o.value.trim()!==""&&P(e,o.value.trim())},"primary")))}function Ce(e){let t=e.probe?.status;return t==="localPasswordRequired"||t==="localPasswordRejected"?Me(e,t==="localPasswordRejected"):t==="registrationRequired"||t==="registrationRejected"?ke(e,t==="registrationRejected"):t==="unreachable"?n("p",{class:"notice problem",role:"alert"},`${e.name} did not answer at ${e.adapter.host}. Check that it has power and is on the network, then try again.`):t==="failed"?n("p",{class:"notice problem",role:"alert"},`${e.name} answered with an error: ${e.probe?.message??"unknown"}`):null}function he(){let e=S();if(e===void 0)return[b()];let t=e.probe?.status==="unreachable"||e.probe?.status==="failed"||i.error!=="";return[E(),K(),z(e,`Connecting to its adapter at ${e.adapter.host}.`),b(),i.isBusy?null:Ce(e),n("div",{class:"footer"},t?u("Try again",()=>{P(e)}):null,u(e.isNew&&i.queue.length>1?"Skip this one":"Cancel",e.isNew&&i.queue.length>1?ce:k))]}function ue(){let e=i.saved,t=(i.setup?.devices??[]).some(o=>e.includes(o.name)&&o.needsRestart);return[n("header",{},n("h1",{},e.length===1?`${e[0]} is set up`:`${e.length} air conditioners are set up`)),n("p",{class:"lead"},"They now appear in the Matter apps paired with Matterbridge. If Matterbridge is not paired yet, pair it from its home page."),t?n("p",{class:"help"},n("strong",{},de)):null,n("p",{class:"help"},_),n("div",{class:"footer"},u("Done",k,"primary"))]}function Ae(e){let t=!e.isConfigured,o=[];e.isConfigured&&o.push("Already set up."),e.name===void 0&&o.push("It has not told its name yet: you will name it in its options."),t&&e.needsRegistration?o.push("Asks for the KEY printed on its label."):t&&e.requiresRegistration&&o.push("Already registered with this plugin, so it will not ask for its KEY."),t&&e.requiresLocalPassword&&o.push("Asks for its child lock code.");let s=n("input",{type:"checkbox",id:`found-${e.host}`,checked:t&&i.selected.has(e.host),disabled:!t,onchange:()=>{s.checked?i.selected.add(e.host):i.selected.delete(e.host),h()}});return n("li",{class:t?"found":"found unavailable"},n("label",{for:`found-${e.host}`},s,n("span",{},n("strong",{},e.name??"Unnamed adapter"),n("span",{class:"meta"},` ${e.host}`),...o.map(a=>n("span",{class:"meta note"},a)))))}function fe(){let e=i.found.filter(a=>i.selected.has(a.host)&&!a.isConfigured),t=n("input",{type:"text",id:"host",placeholder:"192.168.1.50",spellcheck:!1,autocomplete:"off"}),o=()=>{t.value.trim()!==""&&re(t.value.trim())};t.addEventListener("keydown",a=>{a.key==="Enter"&&o()});let s=e.length===1?"Set up 1 air conditioner":`Set up ${e.length} air conditioners`;return[E(),n("header",{},n("h1",{},"Find your air conditioners")),b(),i.found.length>0?n("ul",{class:"found-list"},...i.found.map(Ae)):null,!i.isBusy&&i.found.length===0?n("p",{class:"empty"},"No adapter answered. A search only reaches adapters on the same network segment as Matterbridge: add the others by address below."):null,n("details",{class:"manual",open:!i.isBusy&&i.found.length===0},n("summary",{},"Can't see your air conditioner?"),n("p",{class:"help"},"Enter the address of its adapter. The plugin reads the name of the adapter there and follows it to a new address like any other, as long as a search can reach it. An adapter on another subnet or VLAN keeps this address."),n("div",{class:"inline-form"},n("label",{for:"host",class:"visually-hidden"},"Adapter address"),t,u("Look it up",o))),n("div",{class:"footer"},u("Search again",()=>{F()}),u("Cancel",k),u(s,()=>U(ne(e)),"primary",e.length===0))]}var V={auto:"auto mode",cool:"cool mode",heat:"heat mode",dehumidify:"dry mode",fan:"fan mode"};function $e(e){let t=e.controls===void 0||e.controls.fanSteps.length>0,o=e.controls===void 0||e.controls.hasSwing,s=e.hasSeparateFan?" on a fan of its own":"",a={native:"",switch:"",firstStep:" with auto first",lastStep:" with auto last"}[e.fanAutoControl],r=e.fanControl==="hidden"?"fan speed not shown":`fan speed as ${e.fanControl==="steps"?"steps":"a percentage"}${a}${s}`,c={both:"",vertical:" up and down",horizontal:" left and right"}[e.swingAxes],d={native:`swing as native rocking${c}`,switches:`swing as switches${c}`,select:"swing as a mode select",hidden:"swing not shown"}[e.swingControl],l=[t?r:"",o?d:""].filter(w=>w!=="").join(", "),p=e.modeControl==="switches"?e.modeSwitches.map(w=>V[w]):[],g=Object.keys(V).flatMap(w=>{let q=e.modeReplacements[w];return q===void 0?[]:[`${V[w]} as ${V[q].replace(" mode","")}`]}),m=[...p,e.fanAutoControl==="switch"?"auto fan":"",...e.specialModeSwitches].filter(w=>w!==""),x=[m.length===0?"":`a switch for ${m.join(", ")}`,e.modeControl==="select"?"a mode select":"",g.join(" and ")].filter(w=>w!=="").join(" and "),T=e.isComposed?", all as one device":"";return l===""?`${x===""?"power, mode and temperature":x}${T}`:`${x===""?l:`${l}, and ${x}`}${T}`}function Te(e){let t={online:"Online",offline:"Not answering",stopped:"Not started"}[e.status],o=i.confirmingRemoval===e.macAddress;return n("li",{class:"device"},n("div",{class:"device-main"},n("h3",{},e.name),n("p",{class:"meta"},n("span",{class:`status ${e.status}`},t),` at ${e.host}. In Matter: ${$e(e)}.`),e.status!=="online"&&e.error?n("p",{class:"meta problem-text"},e.error):null,e.needsRestart?n("p",{class:"meta"},n("strong",{},"Restart Matterbridge")," to apply the new options in Matter. Until then it keeps its current controls."):null),o?n("div",{class:"actions"},n("span",{class:"meta"},"Remove it from Matter too?"),u("Remove",()=>{pe(e)},"danger"),u("Keep",()=>{i.confirmingRemoval="",h()})):n("div",{class:"actions"},u(e.status==="online"?"Options":"Reconnect",()=>U([oe(e)])),u("Remove",()=>{i.confirmingRemoval=e.macAddress,h()})))}function me(){let e=i.setup?.devices??[];return[n("header",{},n("h1",{},"Daikin air conditioners"),i.setup?u("Add air conditioners",()=>{F()},"primary"):null),b(),e.length===0&&i.setup?n("p",{class:"empty"},"No air conditioner is set up yet. Add one to control it from Matter."):n("ul",{class:"devices"},...e.map(Te)),i.setup?null:u("Try again",()=>{B()},"primary")]}var Y={auto:"Auto",silent:"Silent",level1:"Level 1",level2:"Level 2",level3:"Level 3",level4:"Level 4",level5:"Level 5"},ee={off:"No swing",vertical:"Up and down",horizontal:"Left and right",both:"3D swing"},H={auto:"Auto",cool:"Cool",heat:"Heat",dehumidify:"Dry",fan:"Fan"},we={powerful:{title:"Powerful",text:"Runs the unit at full power for a while."},econo:{title:"Econo",text:"Limits how much power the unit draws."},streamer:{title:"Streamer",text:"Runs the air purifying of the unit."},heatPlus:{title:"Heat Plus",text:"The Heat Plus mode of the unit, which it takes in heat alone."}},A={steps:'<svg viewBox="0 0 48 28" aria-hidden="true"><rect x="2" y="20" width="8" height="6"/><rect x="14" y="14" width="8" height="12"/><rect x="26" y="8" width="8" height="18"/><rect x="38" y="2" width="8" height="24"/></svg>',percent:'<svg viewBox="0 0 48 28" aria-hidden="true"><path d="M2 26 L46 2 L46 26 Z"/></svg>',hidden:'<svg viewBox="0 0 48 28" aria-hidden="true"><path class="stroke" d="M6 14 H42" stroke-dasharray="3 5"/></svg>',switches:'<svg viewBox="0 0 48 28" aria-hidden="true"><path class="stroke" d="M12 4 V24 M7 9 L12 4 L17 9 M7 19 L12 24 L17 19"/><path class="stroke" d="M26 14 H46 M31 9 L26 14 L31 19 M41 9 L46 14 L41 19"/></svg>',select:'<svg viewBox="0 0 48 28" aria-hidden="true"><rect class="stroke" x="3" y="5" width="42" height="18" rx="4"/><path class="stroke" d="M31 12 L35 16 L39 12"/></svg>',rocking:'<svg viewBox="0 0 48 28" aria-hidden="true"><path class="stroke" d="M8 20 Q24 0 40 20"/><path class="stroke" d="M8 13 V20 H15 M40 13 V20 H33"/></svg>'},ge="Few apps show a mode select: Home Assistant does, Apple Home does not.";function j(e,t,o){return e.isComposed?o?`It appears as a part of "${e.name}", tagged "${t}"`:`It appears as a part of "${e.name}"`:`It appears as "${e.name} ${t}"`}function f(e,t){Object.assign(e,t),h()}function $(e,t,o,s,a,r,c){let d=`${e}-${t}`,l=n("input",{type:"radio",name:e,id:d,checked:t===o,onchange:()=>c(t)});return n("label",{class:"choice pictured",for:d},l,n("span",{class:"glyph",html:r}),n("span",{},n("strong",{},s),n("span",{class:"meta"},a)))}function y(e,t,o,s,a,r){let c=`${e}-${t}`,d=n("input",{type:"radio",name:e,id:c,checked:t===o,onchange:()=>r(t)});return n("label",{class:"choice",for:c},d,n("span",{},n("strong",{},s),n("span",{class:"meta"},a)))}function O(e,t,o,s,a){let r=n("input",{type:"checkbox",id:e,checked:t,onchange:()=>a(r.checked)});return n("label",{class:"choice",for:e},r,n("span",{},n("strong",{},o),n("span",{class:"meta"},s)))}function Re(e,t,o,s,a,r){return n("div",{class:"chips",role:"group","aria-label":t},...o.map(c=>{let d=`${e}-${c}`,l=n("input",{type:"checkbox",id:d,checked:s.includes(c),onchange:()=>r(o.filter(p=>p===c?l.checked:s.includes(p)))});return n("label",{class:"chip",for:d},l,a[c])}))}function Ee(e){let t=e.adapter.name,o=`at ${e.adapter.host}`;return t===void 0||t===""?`the air conditioner ${o}`:`the air conditioner named "${t}" in its Daikin app, ${o}`}function He(e){let t=n("input",{type:"text",id:"device-name",value:e.name,maxLength:32,autocomplete:"off",spellcheck:!1});t.addEventListener("input",a=>{e.name=t.value.trim(),a.isComposing||h()});let o=e.adapter.name,s=o===void 0||o===""?"Its adapter has no name of its own.":`Its adapter is named "${o}" in its Daikin app, which other adapters can share.`;return n("section",{},n("h2",{},n("label",{for:"device-name"},"Name in Matter")),n("p",{class:"help"},`${s} The name here is what your Matter apps show, up to 32 characters, and no two air conditioners of this plugin share one. A new name of the adapter does not change it.`),n("div",{class:"inline-form"},t))}function De(e,t){return n("section",{class:"presets"},n("h2",{},"Start from a preset"),n("div",{class:"preset-list"},...Object.keys(I).map(o=>n("button",{type:"button",class:"preset","aria-pressed":String(ie(e,o,t)),onclick:()=>f(e,L(o,t))},n("strong",{},I[o].title),n("span",{class:"meta"},I[o].text)))),n("p",{class:"help"},"A preset fills in the choices below for what this unit can do. Change any of them afterwards."))}function Le(e){let t=e.map(o=>Y[o]);return t.length===1?t[0]:`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function Ne(e,t,o){if(!t.hasFanAuto||e.fanControl==="hidden"&&e.fanSpeedWhenHidden!=="keep")return null;let s=p=>f(e,{fanAutoControl:p}),a=e.fanControl==="hidden",r=`${j(e,"Auto Fan",!0)}. On sets the fan to auto, off puts it back at the speed it last ran at.`,c=Y[t.fanSteps[0]],d=Y[t.fanSteps[t.fanSteps.length-1]],l=a?[y("fan-auto","native",o,"Not shown in Matter","Without a fan speed in Matter, auto has no place there either.",s),y("fan-auto","switch",o,"A switch",r,s)]:[y("fan-auto","native",o,"Native fan mode only","Auto is a mode of the fan speed, beside its speeds, as Matter has it.",s),y("fan-auto","switch",o,"A switch",`${r} Auto stays a fan mode as well.`,s),y("fan-auto","firstStep",o,"The first step",`Auto comes below ${c}: step 1, or the bottom of the slider.`,s),y("fan-auto","lastStep",o,"The last step",`Auto comes above ${d}: the top step, or 100 %.`,s)];return n("div",{class:"field"},n("h3",{id:"fan-auto-title"},"Auto fan speed"),a?null:n("p",{class:"help"},"Matter has auto as a fan mode, which not every app shows. A switch makes it reachable there too, and a step takes its place."),n("div",{class:"choices",role:"radiogroup","aria-labelledby":"fan-auto-title"},...l))}function Fe(e,t){let o=e.capabilities?.fanSpeeds??[];if(t.fanSteps.length===0)return n("section",{},n("h2",{},"Fan speed"),n("p",{class:"help"},"This unit does not let apps set its fan speed, so there is nothing to choose."));let a=e.fanControl==="hidden",r=t.hasFanAuto&&!a&&(e.fanAutoControl==="firstStep"||e.fanAutoControl==="lastStep"),c=t.hasFanAuto&&e.fanAutoControl==="switch",d=t.fanSteps;r&&(d=e.fanAutoControl==="firstStep"?["auto",...t.fanSteps]:[...t.fanSteps,"auto"]);let p=t.hasFanAuto&&!r?" Auto is not among them: it is a fan mode of its own.":"",g=`${d.length} ${d.length===1?"speed":"speeds"}, ${r?"in order":"slowest first"}: ${Le(d)}.${p}`;return n("section",{},n("h2",{},"Fan speed"),n("div",{class:"choices"},$("fan","steps",e.fanControl,"Steps",g,A.steps,m=>f(e,{fanControl:m})),$("fan","percent",e.fanControl,"Percentage",`A slider from 0 to 100, which the plugin rounds to the nearest of ${g}`,A.percent,m=>f(e,{fanControl:m})),$("fan","hidden",e.fanControl,"Not shown in Matter","No fan control. Pick below what the plugin does with the fan speed instead.",A.hidden,m=>f(e,{fanControl:m}))),e.fanControl==="hidden"?n("div",{class:"field"},n("label",{for:"fan-fixed"},"When the plugin sends a command, the fan speed"),n("select",{id:"fan-fixed",onchange:m=>f(e,{fanSpeedWhenHidden:m.target.value})},n("option",{value:"keep",selected:e.fanSpeedWhenHidden==="keep"},"stays as it is"),...o.map(m=>n("option",{value:m,selected:e.fanSpeedWhenHidden===m},`is set to ${Y[m]}`)))):null,e.fanControl==="hidden"?null:O("separate-fan",e.hasSeparateFan,"Show the fan as a device of its own",`${j(e,"Fan",!1)}, and the air conditioner has no fan speed of its own. For apps that show no fan speed on an air conditioner, or do not show it well. It always shows the speed the unit holds, also while the unit is off.`,m=>f(e,{hasSeparateFan:m})),Ne(e,t,a&&!c?"native":e.fanAutoControl))}function Pe(e,t){let{swingModes:o}=t;if(o.length===0)return n("section",{},n("h2",{},"Swing"),n("p",{class:"help"},"This unit does not let apps move its louvers, so there is nothing to choose."));let s=o.includes("vertical"),a=o.includes("horizontal"),r=e.fanControl!=="hidden"&&t.fanSteps.length>0,c=e.swingControl==="native"&&!r?"switches":e.swingControl,d=r?" The fan control then has no rocking.":"",l="One switch, for the up and down swing.";return s&&a?l="Two switches: one for the up and down swing, one for left and right.":a&&(l="One switch, for the left and right swing."),n("section",{},n("h2",{},"Swing"),n("div",{class:"choices"},r?$("swing","native",c,"Native rocking","The rocking of the fan control, as Matter has it: up and down for the vertical swing, left and right for the horizontal. Not every app shows it, and Apple Home shows it as a single Oscillate on/off.",A.rocking,p=>f(e,{swingControl:p})):null,$("swing","switches",c,"Switches",`${l}${d}`,A.switches,p=>f(e,{swingControl:p})),$("swing","select",c,"A mode select",`${j(e,"Swing",!0)}, and picks one of: ${o.map(p=>p==="both"?ee[p]:ee[p].toLowerCase()).join(", ")}.${d} ${ge}`,A.select,p=>f(e,{swingControl:p})),$("swing","hidden",c,"Not shown in Matter","No swing control. Pick below what the plugin does with the swing instead.",A.hidden,p=>f(e,{swingControl:p}))),c==="native"&&t.swingsOnBothAxes||c==="switches"&&s&&a?Oe(e,c==="native"):null,e.swingControl==="hidden"?n("div",{class:"field"},n("label",{for:"swing-fixed"},"When the plugin sends a command, the swing"),n("select",{id:"swing-fixed",onchange:p=>f(e,{swingModeWhenHidden:p.target.value})},n("option",{value:"keep",selected:e.swingModeWhenHidden==="keep"},"stays as it is"),...o.map(p=>n("option",{value:p,selected:e.swingModeWhenHidden===p},`is set to: ${ee[p]}`)))):null)}function Oe(e,t){let o=r=>f(e,{swingAxes:r}),s="The other axis has no control in Matter, and stays as it is.",a=t?"Some apps, such as Apple Home, show the rocking as a single Oscillate on/off. One axis alone makes that switch swing the louvers on it.":"One switch alone, for the axis picked, instead of a switch for each axis.";return n("div",{class:"field"},n("h3",{id:"swing-axes-title"},t?"Rocking axes":"Switch axes"),n("p",{class:"help"},a),n("div",{class:"choices",role:"radiogroup","aria-labelledby":"swing-axes-title"},y("swing-axes","both",e.swingAxes,"Both axes",t?"Up and down, and left and right, each rocking on its own.":"A switch for up and down, and one for left and right.",o),y("swing-axes","vertical",e.swingAxes,"Up and down alone",s,o),y("swing-axes","horizontal",e.swingAxes,"Left and right alone",s,o)))}function je(e,t){let o=D(e.modeReplacements,t);return n("div",{class:"replacements"},...t.lackingModes.flatMap(s=>{let a=`mode-replacement-${s}`,r=t.switchableModes.find(l=>o[l]===s),c=Object.fromEntries(Object.entries(o).filter(([,l])=>l!==s)),d=l=>{let p=l.target.value,g={...c};p!==""&&(g[p]=s),f(e,{modeReplacements:D(g,t)})};return[n("label",{for:a},H[s]),n("select",{id:a,onchange:d},n("option",{value:"",selected:r===void 0},"is not offered"),...t.switchableModes.map(l=>n("option",{value:l,selected:r===l,disabled:c[l]!==void 0||!J(l,s,c,t)},`runs ${H[l].toLowerCase()}`)))]}))}function qe(e,t){let{switchableModes:o,lackingModes:s}=t;if(o.length===0)return null;let a=o.filter(v=>e.modeSwitches.includes(v)),r=o.filter(v=>v==="dehumidify"||v==="fan"),c=r.length>0,d=e.modeControl==="select"&&!c?"native":e.modeControl,l=v=>{v==="switches"&&a.length===0?f(e,{modeControl:v,modeSwitches:c?r:[...o]}):f(e,{modeControl:v})},p=o.includes("cool")?"cool":"heat",g=r.map(v=>H[v].toLowerCase()).join(" and "),m=c?`Off turns the unit off, or from ${g} puts it back in ${p}.`:"Off turns the unit off.",x=`${H[a.length>0?a[0]:o[0]]} Mode`,T=e.isComposed?`Each appears as a part of "${e.name}", tagged with its mode, such as "${x}".`:`Each appears as "${e.name} ${x}", and so on.`,w=s.map(v=>H[v].toLowerCase()),q=w.length===1?w[0]:`${w.slice(0,-1).join(", ")} or ${w[w.length-1]}`;return n("section",{},n("h2",{},"Modes"),n("p",{class:"help"},"Every mode of the unit is a mode of the air conditioner in Matter, but some apps, such as Apple Home and Google Home, only offer off, cool, heat and auto."),n("div",{class:"choices",role:"radiogroup","aria-label":"Modes"},y("mode-control","native",d,"Native modes only","The modes of the unit are those of the air conditioner, as Matter has them, and nothing more is added.",l),c?y("mode-control","select",d,"A mode select",`${j(e,"Mode",!0)}, with Off and every mode of the unit, as the air conditioner has them. Picking a mode turns the unit on in it. ${ge}`,l):null,y("mode-control","switches",d,"Switches",`A switch for each mode picked below. On turns the unit on in that mode. ${m}`,l),d==="switches"?n("div",{class:"sub"},Re("mode-switch","Modes that get a switch",o,a,H,v=>f(e,{modeSwitches:v})),n("p",{class:"help"},T)):null),s.length>0?n("div",{class:"field"},n("h3",{},"Modes the unit lacks"),n("p",{class:"help"},`This unit has no ${q}. Each can run one of its modes instead, such as heat running dry on a unit that only cools: an app then reaches that mode from the modes it offers, and nothing is added to Matter. The air conditioner shows the mode picked while the unit is in it, with its setpoint. Auto is offered once the air conditioner both cools and heats, counting these.`),je(e,t)):null)}function Ie(e,t){return t.specialModes.length===0?null:n("section",{},n("h2",{},"Special modes"),n("p",{class:"help"},"Matter has no control for these, so each can get a switch of its own. A switch only takes effect in the modes this unit offers that special mode in."),n("div",{class:"choices"},...t.specialModes.map(o=>O(`special-${o}`,e.specialModeSwitches.includes(o),`Add a switch for ${we[o].title}`,we[o].text,s=>f(e,{specialModeSwitches:t.specialModes.filter(a=>a===o?s:e.specialModeSwitches.includes(a))})))))}function Be(e){return n("section",{},n("h2",{},"Humidity and outdoor temperature"),n("p",{class:"help"},"No adapter says which readings its unit has, so each of these takes effect once the unit gives that reading. The room temperature and the humidity are always on the air conditioner."),n("div",{class:"choices"},O("separate-humidity",e.hasSeparateHumiditySensor,"Also show the humidity on a sensor of its own",`${j(e,"Humidity",!1)}, and the air conditioner keeps its humidity. For apps that show no humidity on an air conditioner, which Apple Home is reported to be.`,t=>f(e,{hasSeparateHumiditySensor:t})),O("outdoor-sensor",e.hasOutdoorTemperatureSensor,"Add a sensor for the outdoor temperature",`It appears as "${e.name} Outdoor Temperature". It is a device of its own, which you can put in another room, such as outside. Until you do, a Matter app may show the outdoor temperature as that of the room it put the sensor in. Some units give no outdoor temperature while they are idle: the sensor then shows no value.`,t=>f(e,{hasOutdoorTemperatureSensor:t}))))}function We(e){return n("section",{},n("h2",{},"One device or several"),n("p",{class:"help"},"The switches, a fan of its own and a humidity sensor of its own can be parts of the air conditioner in Matter, or devices of their own beside it. The outdoor temperature sensor is always a device of its own, so that you can put it in another room than the air conditioner."),n("div",{class:"choices"},O("composed",e.isComposed,"Make them parts of the air conditioner",`Your Matter app has one device, "${e.name}", and they move between rooms with it. A part has no name of its own in Matter, so an app may show the switches as numbered outlets, and an app that shows no parts shows the air conditioner alone. Turned off, each is a device of its own with its own name, which your app puts in a room by itself.`,t=>f(e,{isComposed:t}))))}function ve(){let e=S();if(e===void 0)return[b()];let t=e.controls??se;return[E(),K(),z(e,`Options for ${Ee(e)}. Power, mode and temperature always appear in Matter: choose how the rest appears.`),He(e),De(e,t),Fe(e,t),Pe(e,t),qe(e,t),Ie(e,t),Be(e),We(e),e.isNew?null:n("p",{class:"help"},"A change of any of these applies at the next restart of Matterbridge. A switch or a sensor you add is new in your Matter app, in its default room, and one you remove is gone."),b(),n("div",{class:"footer"},u("Cancel",k),u(e.isNew?`Add ${e.name}`:"Save options",()=>{le(e)},"primary"))]}function ye(){try{if(window.parent===window)return;let e=getComputedStyle(window.parent.document.body);for(let t of["--primary-color","--div-bg-color","--div-text-color","--main-bg-color","--main-label-color","--div-border-color","--main-light-color"]){let o=e.getPropertyValue(t).trim();o!==""&&document.documentElement.style.setProperty(`--host${t.slice(1)}`,o)}document.documentElement.style.setProperty("--host-font",e.fontFamily)}catch{}}ae({loading:()=>[n("p",{class:"notice working",role:"status"},n("span",{class:"spinner"}),"Loading\u2026")],home:me,find:fe,connect:he,options:ve,done:ue});ye();h();B();
|
|
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.
|