matterbridge-daikin-local 0.6.0 → 0.7.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 CHANGED
@@ -4,6 +4,26 @@ 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.7.0] - 2026-10-15
8
+
9
+ ### Added
10
+
11
+ - [devices]: Add the option to have a Matter mode the unit lacks run one of its modes, for Matter apps that offer only some of them, with nothing more added to Matter: Heat running dry on a unit that only cools, or Auto running fan. The air conditioner shows that mode, with its setpoint, while the unit is in the mode it runs. It is `modeReplacements`, from each mode of the unit to the mode it is shown as, such as `{ "dehumidify": "heat", "fan": "auto" }`, and goes with the mode switches or the mode select.
12
+ - [devices]: Add a switch for any mode of the unit, Auto, Cool and Heat among them, not only for dry and fan. Turning one of those three off turns the unit off. The setup page picks the switches with a compact list.
13
+
14
+ ### Changed
15
+
16
+ - [package]: Use daikin-local-control 0.6.1: a classic adapter is sent its setpoint rounded to the whole degree, and a DSIOT adapter rounds it to the nearest half degree instead of down. Its clients close with `dispose`, which the plugin calls where it called `close`, and send nothing once disposed.
17
+ - [setup]: Call the swing on both axes at once 3D swing: `3D` on the swing mode select in Matter instead of `Both`, and `3D swing` in the setup page.
18
+ - [setup]: Start a new air conditioner with the Apple Home preset in the setup page, instead of choices that matched no preset.
19
+ - [setup]: The Apple Home and Google Home presets add a switch for each of the dry and fan modes the unit has, since both apps are reported to offer only off, cool, heat and auto.
20
+ - [devices]: Give a fan of its own an on/off that follows the power of the air conditioner, so that a Matter app does not show the fan running while the unit is off. Turning the fan on or off turns the air conditioner on or off, and the fan keeps showing the speed the unit holds. A command that turns the unit off leaves its fan speed as it is, since an app that turns a fan off sets its speed to 0 as well.
21
+
22
+ ### Fixed
23
+
24
+ - [devices]: Put a setpoint a Matter app changes while the unit is in dry or fan back to what it showed, since neither mode takes one, instead of leaving the app showing a setpoint the unit never took.
25
+ - [devices]: Keep taking the commands of a Matter app after the bridge is removed from the last app it was in and paired again. Matter resets the bridge to factory defaults when its last app leaves, which dropped what the plugin listens to on each endpoint, so that commands reached nothing until Matterbridge was restarted. The plugin now listens again once each endpoint is back, and writes the state of the unit to it.
26
+
7
27
  ## [0.6.0] - 2026-10-14
8
28
 
9
29
  ### Added
package/README.md CHANGED
@@ -80,12 +80,12 @@ Afterwards the same page lists your air conditioners with their status. From the
80
80
  </tr>
81
81
  <tr>
82
82
  <td valign="top">
83
- <img src="screenshots/options-presets-fan.png" alt="The Options step with the presets and the three ways to show the fan speed">
83
+ <img src="screenshots/options-presets-fan.png" alt="The Options step with the Apple Home preset chosen, the three ways to show the fan speed and the four ways to show the auto fan speed">
84
84
  <br><b>Options.</b> Start from a preset, then choose how the fan speed appears.
85
85
  </td>
86
86
  <td valign="top">
87
- <img src="screenshots/options-switches.png" alt="The Options step with the swing choice and the switches for the dry mode, the fan mode and the special modes">
88
- <br><b>Options.</b> The swing, and a switch for each mode Matter apps do not offer.
87
+ <img src="screenshots/options-modes.png" alt="The Options step with the swing not shown, a switch for the fan mode picked from a row of modes, and Heat running dry on a unit that only cools">
88
+ <br><b>Options.</b> The swing, a switch for any mode, and a mode the unit lacks running another.
89
89
  </td>
90
90
  </tr>
91
91
  </table>
@@ -96,16 +96,16 @@ The plugin presents itself to every adapter with a **Terminal ID**, which it gen
96
96
 
97
97
  ## How an air conditioner appears in Matter
98
98
 
99
- | In Matter | From the unit |
100
- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
101
- | On/off | Power |
102
- | Thermostat mode | Off, Cool, Heat, Auto, Dry (dehumidify) and Fan only, for the modes the unit has. Not every Matter app offers Dry and Fan only |
103
- | Target temperature | The setpoint of the current mode, within the limits and the step the unit reports. In Auto the unit has one setpoint, which both the heating and the cooling setpoint show |
104
- | Current temperature | The indoor temperature the unit measures |
105
- | Humidity | The indoor humidity, on the air conditioner and, when you add one, on a sensor of its own, for a unit that gives it: see below |
106
- | Outdoor temperature | A temperature sensor named `<name> Outdoor Temperature`, when you turn it on, for a unit that gives it: see below |
107
- | Fan speed | Your choice: see below |
108
- | Swing | Your choice: see below |
99
+ | In Matter | From the unit |
100
+ | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
101
+ | On/off | Power |
102
+ | Thermostat mode | Off, Cool, Heat, Auto, Dry (dehumidify) and Fan only, for the modes the unit has. Not every Matter app offers Dry and Fan only |
103
+ | Target temperature | The setpoint of the current mode, within the limits and the step the unit reports. In Auto the unit has one setpoint, which both the heating and the cooling setpoint show. Dry and fan take none: a setpoint changed in them goes back to what it showed |
104
+ | Current temperature | The indoor temperature the unit measures |
105
+ | Humidity | The indoor humidity, on the air conditioner and, when you add one, on a sensor of its own, for a unit that gives it: see below |
106
+ | Outdoor temperature | A temperature sensor named `<name> Outdoor Temperature`, when you turn it on, for a unit that gives it: see below |
107
+ | Fan speed | Your choice: see below |
108
+ | Swing | Your choice: see below |
109
109
 
110
110
  The adapter does not report whether the compressor is running, so a unit that is on is shown as cooling or heating according to its mode.
111
111
 
@@ -172,7 +172,7 @@ The room temperature and the humidity are always on the air conditioner. You cho
172
172
 
173
173
  Every Matter fan control has an off position below its first step: speed 0, 0 %, or the fan mode Off. An air conditioner has no fan-off of its own, so a Matter app turning the fan to off or 0 sets the first step instead: the slowest speed, or auto when auto is the first step. To let the unit pick the speed, choose auto, wherever the setup puts it: see [Auto fan speed](#auto-fan-speed).
174
174
 
175
- The fan speed is a control of the air conditioner itself. For Matter apps that show no fan speed on an air conditioner, or do not show it well, the setup can move it to a fan of its own instead, named `<name> Fan`, as steps or as a percentage. The air conditioner then has no fan speed, so an app does not show two. No preset does this. The fan behaves the same in either place: it shows the speed the unit holds, also while the unit is off, and turning it off sets the first step.
175
+ The fan speed is a control of the air conditioner itself. For Matter apps that show no fan speed on an air conditioner, or do not show it well, the setup can move it to a fan of its own instead, named `<name> Fan`, as steps or as a percentage. The air conditioner then has no fan speed, so an app does not show two. No preset does this. The fan behaves the same in either place: it shows the speed the unit holds, also while the unit is off, and setting it to 0 sets the first step. A fan of its own is also on and off with the air conditioner, so an app does not show it running while the unit is off, and turning it on or off turns the air conditioner on or off. An app may turn the fan off when it is dragged to 0, such as Apple Home: the air conditioner then turns off and keeps its fan speed.
176
176
 
177
177
  #### Auto fan speed
178
178
 
@@ -192,38 +192,49 @@ A switch or a step is for Matter apps that show no Auto fan mode. A step takes t
192
192
  | Option | In Matter |
193
193
  | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
194
194
  | 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 |
195
- | Mode select | One mode select named `<name> Swing`, with Off, Vertical, Horizontal and Both for the swing modes the unit has. Few Matter apps show it: see [Mode selects](#mode-selects) |
195
+ | 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) |
196
196
  | 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 |
197
197
 
198
198
  Fixed louver positions are not controlled from Matter.
199
199
 
200
- ### Dry and fan modes
200
+ ### Modes
201
201
 
202
- Dry and Fan only are always among the native Matter modes of the air conditioner, but some Matter apps, such as Apple Home, only offer Off, Cool, Heat and Auto. For those apps the setup can add one of these:
202
+ Every mode of the unit is a native Matter mode of the air conditioner, but some Matter apps, such as Apple Home and, by reports, Google Home, only offer Off, Cool, Heat and Auto. For those apps the setup can add one of these, and can also have the modes the unit lacks run others: see [Modes the unit lacks](#modes-the-unit-lacks).
203
203
 
204
- | Option | In Matter |
205
- | ----------------- | ---------------------------------------------------------------------------------------------------------------------- |
206
- | Native modes only | Nothing more: Dry and Fan only are among the modes of the air conditioner. The default |
207
- | A mode select | A mode select named `<name> Mode`, with every mode of the unit: see [Mode selects](#mode-selects) |
208
- | Switches | A switch named `<name> Dry Mode`, `<name> Fan Mode` or both, for whichever of the two modes the unit has that you pick |
204
+ | Option | In Matter |
205
+ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
206
+ | Native modes only | Nothing more: every mode of the unit is among the modes of the air conditioner. The default |
207
+ | A mode select | A mode select named `<name> Mode`, with every mode of the unit, on a unit with a dry or a fan mode: see [Mode selects](#mode-selects) |
208
+ | Switches | A switch for each mode of the unit you pick, named `<name> Auto Mode`, `<name> Cool Mode`, `<name> Heat Mode`, `<name> Dry Mode` or `<name> Fan Mode` |
209
209
 
210
210
  A switch does this:
211
211
 
212
- | Switch | Does |
213
- | ---------- | ------------------------------------------------------------------------------------------------------------------------- |
214
- | Turned on | Turns the unit on in that mode |
215
- | Turned off | Puts the unit back in Cool, or in Heat on a unit that only heats. The unit stays on: turn it off from the air conditioner |
212
+ | Switch | Does |
213
+ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
214
+ | Turned on | Turns the unit on in that mode |
215
+ | Turned off | For Dry and Fan, puts the unit back in Cool, or in Heat on a unit that only heats: the unit stays on. For Auto, Cool and Heat, turns the unit off |
216
216
 
217
217
  A switch is on while the unit is on and in its mode, whichever way it got there.
218
218
 
219
+ #### Modes the unit lacks
220
+
221
+ Each Matter mode the unit lacks can run one of its modes instead, as you pick, such as Heat running dry on a unit that only cools. Picking Heat then turns the unit on in dry, and the air conditioner shows Heat while the unit is in dry, whichever way it got there. Nothing is added to Matter, so an app that offers only Off, Cool, Heat and Auto reaches dry, and it goes with any of the options above: with a switch for Fan, a cool-only unit has every mode in such an app.
222
+
223
+ - Only a mode the unit lacks can run another, so the unit loses none of its own modes. Any mode of the unit can be run: Heat for dry on a unit that only cools, Auto for fan, or Heat for auto on a unit without a heat mode.
224
+ - A replacement can give the air conditioner what the unit lacks: Heat for dry on a unit that only cools makes the air conditioner both heat and cool in Matter.
225
+ - Auto can run a mode only once the air conditioner both cools and heats, counting the replacements, because Matter has Auto only with both.
226
+ - **Do not use Auto for Apple Home.** Apple Home has an Auto of its own, which never picks Matter's Auto: it picks Cool or Heat itself, from the room temperature, so a mode shown as Auto cannot be reached from Apple Home. Use Cool or Heat there instead. Other apps, such as Home Assistant, pick Matter's Auto.
227
+ - No two Matter modes run the same mode of the unit.
228
+ - The setpoint and its limits are those of the mode the air conditioner shows: Heat for auto shows the setpoint of auto as the heating setpoint. Dry and fan take no setpoint on any adapter, so in Heat for dry a change of the heating setpoint is not sent, and the setpoint goes back to what it showed.
229
+
219
230
  ### Mode selects
220
231
 
221
- 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 [Dry and fan modes](#dry-and-fan-modes), the swing select under [Swing](#swing). The Full Matter support preset adds the swing select, and no preset adds the mode select.
232
+ 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). The Full Matter support preset adds the swing select, and no preset adds the mode select.
222
233
 
223
234
  | Mode select | Lists | Picking a value |
224
235
  | ----------- | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
225
236
  | Mode | Off, Auto, Cool, Heat, Dry and Fan Only, as the thermostat mode has them | Off turns the unit off, and any other mode turns it on in that mode. The select shows Off while the unit is off, as the thermostat mode does |
226
- | Swing | Off, Vertical, Horizontal and Both | Sets the swing |
237
+ | Swing | Off, Vertical, Horizontal and 3D | Sets the swing |
227
238
 
228
239
  **Few Matter apps show a mode select.** Home Assistant shows each one as a select among the settings of the device. Apple Home is reported not to show them, and Google Home, Amazon Alexa and SmartThings do not list them among the devices they support. This has not been tested with this plugin. In the other apps, the switches are the way to reach these controls.
229
240
 
@@ -238,17 +249,17 @@ Matter has no control for Powerful, Econo and Streamer, so the setup can add a s
238
249
 
239
250
  ### Presets
240
251
 
241
- In the Options step, a preset fills in every choice above for what the unit can do. You can change any of them afterwards.
252
+ 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.
242
253
 
243
- | Preset | Fan speed | Swing | Dry and fan modes | Auto fan | Special mode switches | Humidity | Outdoor sensor | Parts of the air conditioner |
244
- | ------------------- | ---------- | ------------- | ----------------- | -------- | --------------------- | --------------------------- | -------------- | ---------------------------- |
245
- | Apple Home | Percentage | Not shown | Native modes only | Switch | None | Also on a sensor of its own | No | No |
246
- | Google Home | Steps | Not shown | Native modes only | Switch | None | Also on a sensor of its own | No | No |
247
- | Full Matter support | Steps | A mode select | Native modes only | Native | All | On the air conditioner | Yes | Yes |
254
+ | Preset | Fan speed | Swing | Modes | Auto fan | Special mode switches | Humidity | Outdoor sensor | Parts of the air conditioner |
255
+ | ------------------- | ---------- | ------------- | -------------------- | -------- | --------------------- | --------------------------- | -------------- | ---------------------------- |
256
+ | Apple Home | Percentage | Not shown | Dry and fan switches | Switch | None | Also on a sensor of its own | No | No |
257
+ | Google Home | Steps | Not shown | Dry and fan switches | Switch | None | Also on a sensor of its own | No | No |
258
+ | Full Matter support | Steps | A mode select | Native modes only | Native | All | On the air conditioner | Yes | Yes |
248
259
 
249
260
  ### One device or several
250
261
 
251
- The switches, the mode selects, a fan of its own and a humidity sensor of its own are parts of the air conditioner, which Matter calls a composed device, so they move between rooms with it. The outdoor temperature sensor is a device of its own either way, so that you can put it in another room than the air conditioner. The setup can make each of them a device of its own instead, beside the air conditioner. A Matter app then does not know that they belong together, so each is put in a room by itself: moving the air conditioner to another room leaves them where they were. A new device starts as one composed device. The Full Matter support preset keeps it one, and the Apple Home and Google Home presets make each part a device of its own: see [Presets](#presets).
262
+ The switches, the mode selects, a fan of its own and a humidity sensor of its own are parts of the air conditioner, which Matter calls a composed device, so they move between rooms with it. The outdoor temperature sensor is a device of its own either way, so that you can put it in another room than the air conditioner. The setup can make each of them a device of its own instead, beside the air conditioner. A Matter app then does not know that they belong together, so each is put in a room by itself: moving the air conditioner to another room leaves them where they were. A new device starts with the Apple Home preset, which makes each part a device of its own. The Google Home preset does too, and the Full Matter support preset makes it one composed device: see [Presets](#presets).
252
263
 
253
264
  ```mermaid
254
265
  flowchart TD
@@ -291,7 +302,7 @@ This plugin is the only one of the four that finds the adapters itself, that spe
291
302
  | 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) |
292
303
  | Adding a unit | A search of the network and a guided setup page, or by address. No restart | IP addresses in the plugin settings | IP addresses in the plugin settings, then a restart | Every unit of the account, with a white list and a black list |
293
304
  | 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 |
294
- | Thermostat modes | Off, Cool, Heat, Auto, Dry and Fan only, and an optional switch for each of Dry and Fan only or a mode select | Off, Cool, Heat, Auto, Dry and Fan only | Off, Cool, Heat, Auto and Fan only. Dry and humidify through a mode select | Off, Cool, Heat, Auto, Dry and Fan only |
305
+ | 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 and Fan only. Dry and humidify through a mode select | Off, Cool, Heat, Auto, Dry and Fan only |
295
306
  | 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 |
296
307
  | Swing | 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 |
297
308
  | Powerful, Econo and Streamer | An optional switch for each | No | No | A switch for Powerful |
@@ -1,4 +1,4 @@
1
- async function b(e,t,n){try{let[i,r]=e.split(" "),a={method:i};t!==void 0&&(a.headers={"Content-Type":"application/json"},a.body=JSON.stringify(t));let c=await fetch(new URL(`api/${r}${n===void 0?"":`?${n}`}`,document.baseURI),a);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."}}}function k(e){let{fanControl:t,fanSpeedWhenHidden:n,swingControl:i,swingModeWhenHidden:r,modeControl:a,modeSwitches:c,fanAutoControl:l,hasSeparateFan:m,specialModeSwitches:f,hasOutdoorTemperatureSensor:w,hasSeparateHumiditySensor:h,isComposed:v}=e;return{fanControl:t,fanSpeedWhenHidden:n,swingControl:i,swingModeWhenHidden:r,modeControl:a,modeSwitches:[...c],fanAutoControl:l,hasSeparateFan:m,specialModeSwitches:[...f],hasOutdoorTemperatureSensor:w,hasSeparateHumiditySensor:h,isComposed:v}}var le={fanControl:"steps",fanSpeedWhenHidden:"keep",swingControl:"switches",swingModeWhenHidden:"keep",modeControl:"native",modeSwitches:[],fanAutoControl:"native",hasSeparateFan:!1,specialModeSwitches:[],hasOutdoorTemperatureSensor:!1,hasSeparateHumiditySensor:!1,isComposed:!0};function K(e){return{adapter:e,name:e.name??"",isNew:!0,...k(le)}}function Y(e){let{capabilities:t,controls:n,name:i,macAddress:r,host:a,protocol:c,requiresRegistration:l,usesHttps:m,requiresLocalPassword:f}=e;return{adapter:{host:a,protocol:c,name:i,macAddress:r,requiresRegistration:l,usesHttps:m,requiresLocalPassword:f},name:i,isNew:!1,capabilities:t,controls:n,...k(e)}}var G={fanSteps:[],hasFanAuto:!1,hasSwing:!1,hasDryMode:!1,hasFanMode:!1,specialModes:[]};var s={screen:"loading",setup:void 0,found:[],selected:new Set,queue:[],saved:[],handled:[],isBusy:!1,busyText:"",error:"",confirmingRemoval:""};function g(){return s.queue[0]}function x(e){return e.name===""?e.adapter.host:e.name}function W(e){return(s.setup?.devices??[]).some(t=>t.macAddress===e.macAddress)}var q;function V(e){q=e}function d(){let e=document.getElementById("app");if(e===null||q===void 0)return;let t=`${s.screen}:${g()?.adapter.host??""}`,n=e.dataset.form===t,i=document.activeElement instanceof HTMLElement?document.activeElement.id:"",r=new Map;for(let a of e.querySelectorAll("input[type=text], input[type=password]"))a.id!==""&&r.set(a.id,a.value);if(e.replaceChildren(...q[s.screen]().filter(a=>a!==!1&&a!==null&&a!==void 0)),e.dataset.form=t,!!n){for(let[a,c]of r){let l=document.getElementById(a);l instanceof HTMLInputElement&&(l.value=c)}i!==""&&document.getElementById(i)?.focus()}}async function E(e,t){s.isBusy=!0,s.busyText=e,s.error="",d();try{return await t()}finally{s.isBusy=!1,d()}}async function R(){let e=await b("GET state");if(!e.ok){s.error=e.error,s.screen="home",d();return}if(s.setup=e.state,e.state.devices.length===0){await H();return}s.screen="home",d()}async function F(){let e=await b("GET state");e.ok&&(s.setup=e.state)}function C(){s.queue=[],s.saved=[],s.handled=[],s.error="",s.screen="home",F().then(d),d()}async function H(){s.screen="find";let e=await E("Searching your network. This takes about three seconds\u2026",async()=>b("POST discover"));if(!e.ok){s.error=`The search did not run: ${e.error}`,d();return}await F();let t=s.found.filter(n=>!e.devices.some(i=>i.host===n.host)&&s.selected.has(n.host)).map(n=>({...n,isConfigured:W(n)}));s.found=[...e.devices,...t];for(let n of e.devices)!n.isConfigured&&!n.hasDuplicateName&&s.selected.add(n.host);d()}async function z(e){let t=await E(`Looking for an adapter at ${e}\u2026`,async()=>b("POST identify",{host:e}));if(!t.ok){s.error=t.error,d();return}let n=W(t.device),i=t.device.requiresRegistration===!0;s.found=[...s.found.filter(r=>r.host!==t.device.host),{...t.device,isConfigured:n,hasDuplicateName:!1,needsRegistration:i}],n||s.selected.add(t.device.host),d()}function N(e){s.queue=e,s.saved=[],s.handled=[],B()}async function B(){let e=g();if(e===void 0){s.screen=s.saved.length>0?"done":"home",await F(),d();return}s.screen="connect",s.error="",e.probe=void 0,d(),await L(e)}async function L(e,t){let i={device:{...e.adapter,name:e.name===""?void 0:e.name},localPassword:e.localPassword,key:t},r=t===void 0?`Checking ${x(e)}\u2026`:`Registering with ${x(e)}\u2026`,a=await E(r,async()=>b(t===void 0?"POST probe":"POST register",i));if(!a.ok){s.error=a.error,d();return}if(e.probe=a.result,e.adapter=a.result.device,a.result.status==="ready"){e.capabilities=a.result.capabilities,e.controls=a.result.controls;let c=a.result.device.name??"";c!==""&&(e.name=c),e.name!==""&&(s.screen="options")}d()}function J(){let e=s.queue.shift();e!==void 0&&s.handled.push({label:x(e),isSaved:!1}),B()}async function Q(e){let{adapter:t,name:n,localPassword:i}=e,r={...t,name:n,localPassword:i,...k(e)},a=await E(`Saving ${n}\u2026`,async()=>b("POST device",{device:r}));if(!a.ok){s.error=a.error,d();return}s.setup=a.state,s.saved.push(n),s.handled.push({label:n,isSaved:!0}),s.queue.shift(),await B()}async function Z(e){let t=await E(`Removing ${e.name}\u2026`,async()=>b("DELETE device",void 0,`macAddress=${encodeURIComponent(e.macAddress)}`));s.confirmingRemoval="",t.ok||(s.error=t.error),await F(),d()}function o(e,t={},...n){let i=document.createElement(e);for(let[r,a]of Object.entries(t))a===void 0||a===!1||(r==="class"?i.className=String(a):r==="html"?i.innerHTML=String(a):r.startsWith("on")&&typeof a=="function"?i.addEventListener(r.slice(2),a):r in i?i[r]=a:i.setAttribute(r,String(a)));for(let r of n)r!==!1&&r!==null&&r!==void 0&&i.append(r);return i}function p(e,t,n="quiet",i=!1){return o("button",{type:"button",class:`button ${n}`,onclick:t,disabled:i||s.isBusy},e)}function y(){return s.isBusy?o("p",{class:"notice working",role:"status"},o("span",{class:"spinner"}),s.busyText):s.error!==""?o("p",{class:"notice problem",role:"alert"},s.error):null}function P(){let e=g();if(e===void 0||!e.isNew||s.handled.length+s.queue.length<2)return null;let t=s.screen==="connect"?"Connecting":"Choosing options";return o("ol",{class:"units","aria-label":"Air conditioners in this setup"},...s.handled.map(n=>o("li",{class:n.isSaved?"done":"skipped"},o("strong",{},n.label),o("span",{class:"meta"},n.isSaved?"Added":"Skipped"))),...s.queue.map((n,i)=>o("li",{class:i===0?"current":"ahead","aria-current":i===0?"true":void 0},o("strong",{},x(n)),o("span",{class:"meta"},i===0?t:"Waiting"))))}function j(e,t){return o("header",{class:"unit-header"},o("h1",{},x(e)),o("p",{class:"meta"},t))}function M(){if(s.queue.length>0&&!s.queue.some(i=>i.isNew))return null;let e=["Find","Connect","Options"],n=["find","connect","options"].indexOf(s.screen);return o("ol",{class:"steps"},...e.map((i,r)=>{let a="ahead";return r<n?a="done":r===n&&(a="current"),o("li",{class:a,"aria-current":r===n?"step":void 0},i)}))}function ce(e){let t=o("input",{type:"text",id:"device-name",maxLength:32,autocomplete:"off"}),n=()=>{let i=t.value.trim();if(i!==""){if(s.setup?.devices.some(r=>r.name===i)){s.error=`"${i}" is already the name of another air conditioner. Pick a different one.`,d();return}e.name=i,s.error="",s.screen="options",d()}};return o("div",{class:"field"},o("label",{for:"device-name"},"Name this air conditioner"),o("p",{class:"help"},"Its adapter has no name of its own. This is the name it gets in Matter, up to 32 characters. Name the adapter in its Daikin app later and the plugin takes that name instead."),o("div",{class:"inline-form"},t,p("Continue",n,"primary")))}function de(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,p("Check the code",()=>{n.value!==""&&(e.localPassword=n.value,L(e))},"primary")))}function pe(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,p("Register",()=>{n.value.trim()!==""&&L(e,n.value.trim())},"primary")))}function he(e){let t=e.probe?.status;return t==="ready"&&e.name===""?ce(e):t==="localPasswordRequired"||t==="localPasswordRejected"?de(e,t==="localPasswordRejected"):t==="registrationRequired"||t==="registrationRejected"?pe(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 X(){let e=g();if(e===void 0)return[y()];let t=e.probe?.status==="unreachable"||e.probe?.status==="failed"||s.error!==""&&e.name!=="";return[M(),P(),j(e,`Connecting to its adapter at ${e.adapter.host}.`),y(),s.isBusy?null:he(e),o("div",{class:"footer"},t?p("Try again",()=>{L(e)}):null,p(e.isNew&&s.queue.length>1?"Skip this one":"Cancel",e.isNew&&s.queue.length>1?J:C))]}function _(){let e=s.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("div",{class:"footer"},p("Done",C,"primary"))]}function ue(e){let t=!e.isConfigured&&!e.hasDuplicateName,n=[];e.isConfigured&&n.push("Already set up."),e.hasDuplicateName&&n.push("Another adapter has the same name. Give each its own name in its Daikin app, then search again."),e.name===void 0&&n.push("It has not told its name yet. If it has none, you will name it after connecting."),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 i=o("input",{type:"checkbox",id:`found-${e.host}`,checked:t&&s.selected.has(e.host),disabled:!t,onchange:()=>{i.checked?s.selected.add(e.host):s.selected.delete(e.host),d()}});return o("li",{class:t?"found":"found unavailable"},o("label",{for:`found-${e.host}`},i,o("span",{},o("strong",{},e.name??"Unnamed adapter"),o("span",{class:"meta"},` ${e.host}`),...n.map(r=>o("span",{class:"meta note"},r)))))}function ee(){let e=s.found.filter(r=>s.selected.has(r.host)&&!r.isConfigured&&!r.hasDuplicateName),t=o("input",{type:"text",id:"host",placeholder:"192.168.1.50",spellcheck:!1,autocomplete:"off"}),n=()=>{t.value.trim()!==""&&z(t.value.trim())};t.addEventListener("keydown",r=>{r.key==="Enter"&&n()});let i=e.length===1?"Set up 1 air conditioner":`Set up ${e.length} air conditioners`;return[M(),o("header",{},o("h1",{},"Find your air conditioners")),y(),s.found.length>0?o("ul",{class:"found-list"},...s.found.map(ue)):null,!s.isBusy&&s.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:!s.isBusy&&s.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,p("Look it up",n))),o("div",{class:"footer"},p("Search again",()=>{H()}),p("Cancel",C),p(i,()=>N(e.map(K)),"primary",e.length===0))]}function fe(e){let t=e.controls===void 0||e.controls.fanSteps.length>0,n=e.controls===void 0||e.controls.hasSwing,i=e.hasSeparateFan?" on a fan of its own":"",r={native:"",switch:"",firstStep:" with auto first",lastStep:" with auto last"}[e.fanAutoControl],a=e.fanControl==="hidden"?"fan speed not shown":`fan speed as ${e.fanControl==="steps"?"steps":"a percentage"}${r}${i}`,c={switches:"swing as switches",select:"swing as a mode select",hidden:"swing not shown"}[e.swingControl],l=[t?a:"",n?c:""].filter(v=>v!=="").join(", "),f=[...e.modeControl==="switches"?e.modeSwitches.map(v=>v==="dehumidify"?"dry mode":"fan mode"):[],e.fanAutoControl==="switch"?"auto fan":"",...e.specialModeSwitches].filter(v=>v!==""),w=[f.length===0?"":`a switch for ${f.join(", ")}`,e.modeControl==="select"?"a mode select":""].filter(v=>v!=="").join(" and "),h=e.isComposed?", all as one device":"";return l===""?`${w===""?"power, mode and temperature":w}${h}`:`${w===""?l:`${l}, and ${w}`}${h}`}function me(e){let t={online:"Online",offline:"Not answering",stopped:"Not started"}[e.status],n=s.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: ${fe(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?"),p("Remove",()=>{Z(e)},"danger"),p("Keep",()=>{s.confirmingRemoval="",d()})):o("div",{class:"actions"},p(e.status==="online"?"Options":"Reconnect",()=>N([Y(e)])),p("Remove",()=>{s.confirmingRemoval=e.macAddress,d()})))}function te(){let e=s.setup?.devices??[];return[o("header",{},o("h1",{},"Daikin air conditioners"),s.setup?p("Add air conditioners",()=>{H()},"primary"):null),y(),e.length===0&&s.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(me)),s.setup?null:p("Try again",()=>{R()},"primary")]}var O={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, 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, 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 U(e,t){let n=e==="matter",i=n&&t.hasSwing?"select":"hidden";return{fanControl:t.fanSteps.length===0?"hidden":e==="apple"?"percent":"steps",fanSpeedWhenHidden:"keep",swingControl:i,swingModeWhenHidden:"keep",modeControl:"native",modeSwitches:[],fanAutoControl:!n&&t.hasFanAuto?"switch":"native",hasSeparateFan:!1,specialModeSwitches:n?[...t.specialModes]:[],hasOutdoorTemperatureSensor:n,hasSeparateHumiditySensor:!n,isComposed:n}}function oe(e,t,n){let i=k(e);n.fanSteps.length===0&&Object.assign(i,{fanControl:"hidden",fanSpeedWhenHidden:"keep"}),i.fanControl==="hidden"&&(i.hasSeparateFan=!1);let r=i.fanAutoControl==="firstStep"||i.fanAutoControl==="lastStep",a=i.fanControl==="hidden"&&i.fanSpeedWhenHidden!=="keep";return(!n.hasFanAuto||r&&i.fanControl==="hidden"||a)&&(i.fanAutoControl="native"),n.hasSwing||Object.assign(i,{swingControl:"hidden",swingModeWhenHidden:"keep"}),i.modeControl!=="switches"&&(i.modeSwitches=[]),!n.hasDryMode&&!n.hasFanMode&&Object.assign(i,{modeControl:"native",modeSwitches:[]}),i.specialModeSwitches=n.specialModes.filter(c=>i.specialModeSwitches.includes(c)),JSON.stringify(i)===JSON.stringify(U(t,n))}var I={auto:"Auto",silent:"Silent",level1:"Level 1",level2:"Level 2",level3:"Level 3",level4:"Level 4",level5:"Level 5"},ne={off:"No swing",vertical:"Up and down",horizontal:"Left and right",both:"Up, down, left and right"},se={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>'},ie="Few apps show a mode select: Home Assistant does, Apple Home does not.";function T(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 u(e,t){Object.assign(e,t),d()}function D(e,t,n,i,r,a,c){let l=`${e}-${t}`,m=o("input",{type:"radio",name:e,id:l,checked:t===n,onchange:()=>c(t)});return o("label",{class:"choice pictured",for:l},m,o("span",{class:"glyph",html:a}),o("span",{},o("strong",{},i),o("span",{class:"meta"},r)))}function S(e,t,n,i,r,a){let c=`${e}-${t}`,l=o("input",{type:"radio",name:e,id:c,checked:t===n,onchange:()=>a(t)});return o("label",{class:"choice",for:c},l,o("span",{},o("strong",{},i),o("span",{class:"meta"},r)))}function $(e,t,n,i,r){let a=o("input",{type:"checkbox",id:e,checked:t,onchange:()=>r(a.checked)});return o("label",{class:"choice",for:e},a,o("span",{},o("strong",{},n),o("span",{class:"meta"},i)))}function we(e,t){return o("section",{class:"presets"},o("h2",{},"Start from a preset"),o("div",{class:"preset-list"},...Object.keys(O).map(n=>o("button",{type:"button",class:"preset","aria-pressed":String(oe(e,n,t)),onclick:()=>u(e,U(n,t))},o("strong",{},O[n].title),o("span",{class:"meta"},O[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 ge(e){let t=e.map(n=>I[n]);return t.length===1?t[0]:`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function ye(e,t,n){if(!t.hasFanAuto||e.fanControl==="hidden"&&e.fanSpeedWhenHidden!=="keep")return null;let i=f=>u(e,{fanAutoControl:f}),r=e.fanControl==="hidden",a=`${T(e,"Auto Fan",!0)}. On sets the fan to auto, off puts it back at the speed it last ran at.`,c=I[t.fanSteps[0]],l=I[t.fanSteps[t.fanSteps.length-1]],m=r?[S("fan-auto","native",n,"Not shown in Matter","Without a fan speed in Matter, auto has no place there either.",i),S("fan-auto","switch",n,"A switch",a,i)]:[S("fan-auto","native",n,"Native fan mode only","Auto is a mode of the fan speed, beside its speeds, as Matter has it.",i),S("fan-auto","switch",n,"A switch",`${a} Auto stays a fan mode as well.`,i),S("fan-auto","firstStep",n,"The first step",`Auto comes below ${c}: step 1, or the bottom of the slider.`,i),S("fan-auto","lastStep",n,"The last step",`Auto comes above ${l}: the top step, or 100 %.`,i)];return o("div",{class:"field"},o("h3",{id:"fan-auto-title"},"Auto fan speed"),r?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"},...m))}function ve(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 r=e.fanControl==="hidden",a=t.hasFanAuto&&!r&&(e.fanAutoControl==="firstStep"||e.fanAutoControl==="lastStep"),c=t.hasFanAuto&&e.fanAutoControl==="switch",l=t.fanSteps;a&&(l=e.fanAutoControl==="firstStep"?["auto",...t.fanSteps]:[...t.fanSteps,"auto"]);let f=t.hasFanAuto&&!a?" Auto is not among them: it is a fan mode of its own.":"",w=`${l.length} ${l.length===1?"speed":"speeds"}, ${a?"in order":"slowest first"}: ${ge(l)}.${f}`;return o("section",{},o("h2",{},"Fan speed"),o("div",{class:"choices"},D("fan","steps",e.fanControl,"Steps",w,A.steps,h=>u(e,{fanControl:h})),D("fan","percent",e.fanControl,"Percentage",`A slider from 0 to 100, which the plugin rounds to the nearest of ${w}`,A.percent,h=>u(e,{fanControl:h})),D("fan","hidden",e.fanControl,"Not shown in Matter","No fan control. Pick below what the plugin does with the fan speed instead.",A.hidden,h=>u(e,{fanControl:h}))),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:h=>u(e,{fanSpeedWhenHidden:h.target.value})},o("option",{value:"keep",selected:e.fanSpeedWhenHidden==="keep"},"stays as it is"),...n.map(h=>o("option",{value:h,selected:e.fanSpeedWhenHidden===h},`is set to ${I[h]}`)))):null,e.fanControl==="hidden"?null:$("separate-fan",e.hasSeparateFan,"Show the fan as a device of its own",`${T(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.`,h=>u(e,{hasSeparateFan:h})),ye(e,t,r&&!c?"native":e.fanAutoControl))}function Se(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"),i=t.includes("horizontal"),r="One switch, for the up and down swing.";return n&&i?r="Two switches: one for the up and down swing, one for left and right.":i&&(r="One switch, for the left and right swing."),o("section",{},o("h2",{},"Swing"),o("div",{class:"choices"},D("swing","switches",e.swingControl,"Switches",r,A.switches,a=>u(e,{swingControl:a})),D("swing","select",e.swingControl,"A mode select",`${T(e,"Swing",!0)}, and picks one of: ${t.map(a=>ne[a].toLowerCase()).join(", ")}. ${ie}`,A.select,a=>u(e,{swingControl:a})),D("swing","hidden",e.swingControl,"Not shown in Matter","No swing control. Pick below what the plugin does with the swing instead.",A.hidden,a=>u(e,{swingControl:a}))),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:a=>u(e,{swingModeWhenHidden:a.target.value})},o("option",{value:"keep",selected:e.swingModeWhenHidden==="keep"},"stays as it is"),...t.map(a=>o("option",{value:a,selected:e.swingModeWhenHidden===a},`is set to: ${ne[a]}`)))):null)}function be(e,t){if(!t.hasDryMode&&!t.hasFanMode)return null;let n=e.capabilities?.modes??[],i=[...t.hasDryMode?["dehumidify"]:[],...t.hasFanMode?["fan"]:[]],r={dehumidify:"Dry Mode",fan:"Fan Mode"},a=i.filter(l=>e.modeSwitches.includes(l)),c=l=>u(e,l==="switches"&&a.length===0?{modeControl:l,modeSwitches:i}:{modeControl:l});return o("section",{},o("h2",{},"Dry and fan modes"),o("p",{class:"help"},"These are among the modes of the air conditioner in Matter, but some apps, such as Apple Home, only offer cool, heat and auto."),o("div",{class:"choices",role:"radiogroup","aria-label":"Dry and fan modes"},S("mode-control","native",e.modeControl,"Native modes only","Dry and fan are modes of the air conditioner, as Matter has them, and nothing more is added.",c),S("mode-control","select",e.modeControl,"A mode select",`${T(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. ${ie}`,c),S("mode-control","switches",e.modeControl,"Switches",`A switch for each mode picked below. On puts the unit in that mode, off puts it back in ${n.includes("cool")?"cool":"heat"}.`,c)),e.modeControl==="switches"?o("div",{class:"choices"},...i.map(l=>$(`mode-switch-${l}`,a.includes(l),`Add a switch for ${r[l].toLowerCase()}`,`${T(e,r[l],!0)}.`,m=>u(e,{modeSwitches:i.filter(f=>f===l?m:a.includes(f))})))):null)}function Ce(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=>$(`special-${n}`,e.specialModeSwitches.includes(n),`Add a switch for ${se[n].title}`,se[n].text,i=>u(e,{specialModeSwitches:t.specialModes.filter(r=>r===n?i:e.specialModeSwitches.includes(r))})))))}function xe(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"},$("separate-humidity",e.hasSeparateHumiditySensor,"Also show the humidity on a sensor of its own",`${T(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=>u(e,{hasSeparateHumiditySensor:t})),$("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=>u(e,{hasOutdoorTemperatureSensor:t}))))}function ke(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"},$("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=>u(e,{isComposed:t}))))}function ae(){let e=g();if(e===void 0)return[y()];let t=e.controls??G;return[M(),P(),j(e,`Options for the air conditioner at ${e.adapter.host}. Power, mode and temperature always appear in Matter: choose how the rest appears.`),we(e,t),ve(e,t),Se(e),be(e,t),Ce(e,t),xe(e),ke(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."),y(),o("div",{class:"footer"},p("Cancel",C),p(e.isNew?`Add ${e.name}`:"Save options",()=>{Q(e)},"primary"))]}function re(){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{}}V({loading:()=>[o("p",{class:"notice working",role:"status"},o("span",{class:"spinner"}),"Loading\u2026")],home:te,find:ee,connect:X,options:ae,done:_});re();d();R();
1
+ async function C(e,t,n){try{let[s,r]=e.split(" "),a={method:s};t!==void 0&&(a.headers={"Content-Type":"application/json"},a.body=JSON.stringify(t));let l=await fetch(new URL(`api/${r}${n===void 0?"":`?${n}`}`,document.baseURI),a);if(l.status===204)return{ok:!0};if(l.status===503)return{ok:!1,error:"The plugin is not running. Start it in Matterbridge, then reload this page."};let c=await l.json();return"ok"in c?c:{ok:!1,error:c.error??`The plugin answered with status ${l.status}`}}catch{return{ok:!1,error:"Matterbridge did not answer. Check that it is running, then try again."}}}function T(e){let{fanControl:t,fanSpeedWhenHidden:n,swingControl:s,swingModeWhenHidden:r,modeControl:a,modeSwitches:l,modeReplacements:c,fanAutoControl:d,hasSeparateFan:m,specialModeSwitches:y,hasOutdoorTemperatureSensor:u,hasSeparateHumiditySensor:k,isComposed:w}=e;return{fanControl:t,fanSpeedWhenHidden:n,swingControl:s,swingModeWhenHidden:r,modeControl:a,modeSwitches:[...l],modeReplacements:{...c},fanAutoControl:d,hasSeparateFan:m,specialModeSwitches:[...y],hasOutdoorTemperatureSensor:u,hasSeparateHumiditySensor:k,isComposed:w}}var we={fanControl:"steps",fanSpeedWhenHidden:"keep",swingControl:"switches",swingModeWhenHidden:"keep",modeControl:"native",modeSwitches:[],modeReplacements:{},fanAutoControl:"native",hasSeparateFan:!1,specialModeSwitches:[],hasOutdoorTemperatureSensor:!1,hasSeparateHumiditySensor:!1,isComposed:!0};function X(e){return{adapter:e,name:e.name??"",isNew:!0,...T(we)}}function _(e){let{capabilities:t,controls:n,name:s,macAddress:r,host:a,protocol:l,requiresRegistration:c,usesHttps:d,requiresLocalPassword:m}=e;return{adapter:{host:a,protocol:l,name:s,macAddress:r,requiresRegistration:c,usesHttps:d,requiresLocalPassword:m},name:s,isNew:!1,capabilities:t,controls:n,...T(e)}}var ee={fanSteps:[],hasFanAuto:!1,hasSwing:!1,switchableModes:[],lackingModes:[],specialModes:[]};function V(e,t,n,s){if(!s.switchableModes.includes(e)||!s.lackingModes.includes(t))return!1;let r=s.switchableModes.filter(l=>l!==e).map(l=>n[l]);if(r.includes(t))return!1;if(t!=="auto")return!0;let a=new Set([...s.switchableModes,...r]);return a.has("cool")&&a.has("heat")}function H(e,t){let n={};for(let s of t.switchableModes){let r=e[s];r!==void 0&&V(s,r,e,t)&&(n[s]=r)}return n}var I={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",r=n?[]:t.switchableModes.filter(a=>a==="dehumidify"||a==="fan");return{fanControl:t.fanSteps.length===0?"hidden":e==="apple"?"percent":"steps",fanSpeedWhenHidden:"keep",swingControl:s,swingModeWhenHidden:"keep",modeControl:r.length>0?"switches":"native",modeSwitches:r,modeReplacements:{},fanAutoControl:!n&&t.hasFanAuto?"switch":"native",hasSeparateFan:!1,specialModeSwitches:n?[...t.specialModes]:[],hasOutdoorTemperatureSensor:n,hasSeparateHumiditySensor:!n,isComposed:n}}function te(e,t,n){let s=T(e);n.fanSteps.length===0&&Object.assign(s,{fanControl:"hidden",fanSpeedWhenHidden:"keep"}),s.fanControl==="hidden"&&(s.hasSeparateFan=!1);let r=s.fanAutoControl==="firstStep"||s.fanAutoControl==="lastStep",a=s.fanControl==="hidden"&&s.fanSpeedWhenHidden!=="keep";return(!n.hasFanAuto||r&&s.fanControl==="hidden"||a)&&(s.fanAutoControl="native"),n.hasSwing||Object.assign(s,{swingControl:"hidden",swingModeWhenHidden:"keep"}),s.modeSwitches=s.modeControl==="switches"?n.switchableModes.filter(c=>s.modeSwitches.includes(c)):[],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(c=>s.specialModeSwitches.includes(c)),JSON.stringify(s)===JSON.stringify(L(t,n))}var i={screen:"loading",setup:void 0,found:[],selected:new Set,queue:[],saved:[],handled:[],isBusy:!1,busyText:"",error:"",confirmingRemoval:""};function v(){return i.queue[0]}function A(e){return e.name===""?e.adapter.host:e.name}function z(e){return(i.setup?.devices??[]).some(t=>t.macAddress===e.macAddress)}var J;function oe(e){J=e}function p(){let e=document.getElementById("app");if(e===null||J===void 0)return;let t=`${i.screen}:${v()?.adapter.host??""}`,n=e.dataset.form===t,s=document.activeElement instanceof HTMLElement?document.activeElement.id:"",r=new Map;for(let a of e.querySelectorAll("input[type=text], input[type=password]"))a.id!==""&&r.set(a.id,a.value);if(e.replaceChildren(...J[i.screen]().filter(a=>a!==!1&&a!==null&&a!==void 0)),e.dataset.form=t,!!n){for(let[a,l]of r){let c=document.getElementById(a);c instanceof HTMLInputElement&&(c.value=l)}s!==""&&document.getElementById(s)?.focus()}}async function F(e,t){i.isBusy=!0,i.busyText=e,i.error="",p();try{return await t()}finally{i.isBusy=!1,p()}}async function W(){let e=await C("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 q(){let e=await C("GET state");e.ok&&(i.setup=e.state)}function x(){i.queue=[],i.saved=[],i.handled=[],i.error="",i.screen="home",q().then(p),p()}async function N(){i.screen="find";let e=await F("Searching your network. This takes about three seconds\u2026",async()=>C("POST discover"));if(!e.ok){i.error=`The search did not run: ${e.error}`,p();return}await q();let t=i.found.filter(n=>!e.devices.some(s=>s.host===n.host)&&i.selected.has(n.host)).map(n=>({...n,isConfigured:z(n)}));i.found=[...e.devices,...t];for(let n of e.devices)!n.isConfigured&&!n.hasDuplicateName&&i.selected.add(n.host);p()}async function ne(e){let t=await F(`Looking for an adapter at ${e}\u2026`,async()=>C("POST identify",{host:e}));if(!t.ok){i.error=t.error,p();return}let n=z(t.device),s=t.device.requiresRegistration===!0;i.found=[...i.found.filter(r=>r.host!==t.device.host),{...t.device,isConfigured:n,hasDuplicateName:!1,needsRegistration:s}],n||i.selected.add(t.device.host),p()}function B(e){i.queue=e,i.saved=[],i.handled=[],Q()}async function Q(){let e=v();if(e===void 0){i.screen=i.saved.length>0?"done":"home",await q(),p();return}i.screen="connect",i.error="",e.probe=void 0,p(),await P(e)}async function P(e,t){let s={device:{...e.adapter,name:e.name===""?void 0:e.name},localPassword:e.localPassword,key:t},r=t===void 0?`Checking ${A(e)}\u2026`:`Registering with ${A(e)}\u2026`,a=await F(r,async()=>C(t===void 0?"POST probe":"POST register",s));if(!a.ok){i.error=a.error,p();return}if(e.probe=a.result,e.adapter=a.result.device,a.result.status==="ready"){let l=e.controls===void 0;e.capabilities=a.result.capabilities,e.controls=a.result.controls,e.isNew&&l&&e.controls!==void 0&&Object.assign(e,L("apple",e.controls));let c=a.result.device.name??"";c!==""&&(e.name=c),e.name!==""&&(i.screen="options")}p()}function se(){let e=i.queue.shift();e!==void 0&&i.handled.push({label:A(e),isSaved:!1}),Q()}async function ie(e){let{adapter:t,name:n,localPassword:s}=e,r={...t,name:n,localPassword:s,...T(e)},a=await F(`Saving ${n}\u2026`,async()=>C("POST device",{device:r}));if(!a.ok){i.error=a.error,p();return}i.setup=a.state,i.saved.push(n),i.handled.push({label:n,isSaved:!0}),i.queue.shift(),await Q()}async function ae(e){let t=await F(`Removing ${e.name}\u2026`,async()=>C("DELETE device",void 0,`macAddress=${encodeURIComponent(e.macAddress)}`));i.confirmingRemoval="",t.ok||(i.error=t.error),await q(),p()}function o(e,t={},...n){let s=document.createElement(e);for(let[r,a]of Object.entries(t))a===void 0||a===!1||(r==="class"?s.className=String(a):r==="html"?s.innerHTML=String(a):r.startsWith("on")&&typeof a=="function"?s.addEventListener(r.slice(2),a):r in s?s[r]=a:s.setAttribute(r,String(a)));for(let r of n)r!==!1&&r!==null&&r!==void 0&&s.append(r);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):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 $(){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,r)=>{let a="ahead";return r<n?a="done":r===n&&(a="current"),o("li",{class:a,"aria-current":r===n?"step":void 0},s)}))}function ge(e){let t=o("input",{type:"text",id:"device-name",maxLength:32,autocomplete:"off"}),n=()=>{let s=t.value.trim();if(s!==""){if(i.setup?.devices.some(r=>r.name===s)){i.error=`"${s}" is already the name of another air conditioner. Pick a different one.`,p();return}e.name=s,i.error="",i.screen="options",p()}};return o("div",{class:"field"},o("label",{for:"device-name"},"Name this air conditioner"),o("p",{class:"help"},"Its adapter has no name of its own. This is the name it gets in Matter, up to 32 characters. Name the adapter in its Daikin app later and the plugin takes that name instead."),o("div",{class:"inline-form"},t,h("Continue",n,"primary")))}function ye(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 ve(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 Se(e){let t=e.probe?.status;return t==="ready"&&e.name===""?ge(e):t==="localPasswordRequired"||t==="localPasswordRejected"?ye(e,t==="localPasswordRejected"):t==="registrationRequired"||t==="registrationRejected"?ve(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 re(){let e=v();if(e===void 0)return[S()];let t=e.probe?.status==="unreachable"||e.probe?.status==="failed"||i.error!==""&&e.name!=="";return[$(),U(),K(e,`Connecting to its adapter at ${e.adapter.host}.`),S(),i.isBusy?null:Se(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?se:x))]}function ce(){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("div",{class:"footer"},h("Done",x,"primary"))]}function be(e){let t=!e.isConfigured&&!e.hasDuplicateName,n=[];e.isConfigured&&n.push("Already set up."),e.hasDuplicateName&&n.push("Another adapter has the same name. Give each its own name in its Daikin app, then search again."),e.name===void 0&&n.push("It has not told its name yet. If it has none, you will name it after connecting."),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(r=>o("span",{class:"meta note"},r)))))}function le(){let e=i.found.filter(r=>i.selected.has(r.host)&&!r.isConfigured&&!r.hasDuplicateName),t=o("input",{type:"text",id:"host",placeholder:"192.168.1.50",spellcheck:!1,autocomplete:"off"}),n=()=>{t.value.trim()!==""&&ne(t.value.trim())};t.addEventListener("keydown",r=>{r.key==="Enter"&&n()});let s=e.length===1?"Set up 1 air conditioner":`Set up ${e.length} air conditioners`;return[$(),o("header",{},o("h1",{},"Find your air conditioners")),S(),i.found.length>0?o("ul",{class:"found-list"},...i.found.map(be)):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",x),h(s,()=>B(e.map(X)),"primary",e.length===0))]}var Y={auto:"auto mode",cool:"cool mode",heat:"heat mode",dehumidify:"dry mode",fan:"fan mode"};function Me(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":"",r={native:"",switch:"",firstStep:" with auto first",lastStep:" with auto last"}[e.fanAutoControl],a=e.fanControl==="hidden"?"fan speed not shown":`fan speed as ${e.fanControl==="steps"?"steps":"a percentage"}${r}${s}`,l={switches:"swing as switches",select:"swing as a mode select",hidden:"swing not shown"}[e.swingControl],c=[t?a:"",n?l:""].filter(w=>w!=="").join(", "),d=e.modeControl==="switches"?e.modeSwitches.map(w=>Y[w]):[],m=Object.keys(Y).flatMap(w=>{let M=e.modeReplacements[w];return M===void 0?[]:[`${Y[w]} as ${Y[M].replace(" mode","")}`]}),y=[...d,e.fanAutoControl==="switch"?"auto fan":"",...e.specialModeSwitches].filter(w=>w!==""),u=[y.length===0?"":`a switch for ${y.join(", ")}`,e.modeControl==="select"?"a mode select":"",m.join(" and ")].filter(w=>w!=="").join(" and "),k=e.isComposed?", all as one device":"";return c===""?`${u===""?"power, mode and temperature":u}${k}`:`${u===""?c:`${c}, and ${u}`}${k}`}function Ce(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: ${Me(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",()=>{ae(e)},"danger"),h("Keep",()=>{i.confirmingRemoval="",p()})):o("div",{class:"actions"},h(e.status==="online"?"Options":"Reconnect",()=>B([_(e)])),h("Remove",()=>{i.confirmingRemoval=e.macAddress,p()})))}function de(){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(Ce)),i.setup?null:h("Try again",()=>{W()},"primary")]}var G={auto:"Auto",silent:"Silent",level1:"Level 1",level2:"Level 2",level3:"Level 3",level4:"Level 4",level5:"Level 5"},Z={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"},pe={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>'},he="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 f(e,t){Object.assign(e,t),p()}function D(e,t,n,s,r,a,l){let c=`${e}-${t}`,d=o("input",{type:"radio",name:e,id:c,checked:t===n,onchange:()=>l(t)});return o("label",{class:"choice pictured",for:c},d,o("span",{class:"glyph",html:a}),o("span",{},o("strong",{},s),o("span",{class:"meta"},r)))}function b(e,t,n,s,r,a){let l=`${e}-${t}`,c=o("input",{type:"radio",name:e,id:l,checked:t===n,onchange:()=>a(t)});return o("label",{class:"choice",for:l},c,o("span",{},o("strong",{},s),o("span",{class:"meta"},r)))}function O(e,t,n,s,r){let a=o("input",{type:"checkbox",id:e,checked:t,onchange:()=>r(a.checked)});return o("label",{class:"choice",for:e},a,o("span",{},o("strong",{},n),o("span",{class:"meta"},s)))}function xe(e,t,n,s,r,a){return o("div",{class:"chips",role:"group","aria-label":t},...n.map(l=>{let c=`${e}-${l}`,d=o("input",{type:"checkbox",id:c,checked:s.includes(l),onchange:()=>a(n.filter(m=>m===l?d.checked:s.includes(m)))});return o("label",{class:"chip",for:c},d,r[l])}))}function ke(e,t){return o("section",{class:"presets"},o("h2",{},"Start from a preset"),o("div",{class:"preset-list"},...Object.keys(I).map(n=>o("button",{type:"button",class:"preset","aria-pressed":String(te(e,n,t)),onclick:()=>f(e,L(n,t))},o("strong",{},I[n].title),o("span",{class:"meta"},I[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 Ae(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 Te(e,t,n){if(!t.hasFanAuto||e.fanControl==="hidden"&&e.fanSpeedWhenHidden!=="keep")return null;let s=m=>f(e,{fanAutoControl:m}),r=e.fanControl==="hidden",a=`${j(e,"Auto Fan",!0)}. On sets the fan to auto, off puts it back at the speed it last ran at.`,l=G[t.fanSteps[0]],c=G[t.fanSteps[t.fanSteps.length-1]],d=r?[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",a,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",`${a} Auto stays a fan mode as well.`,s),b("fan-auto","firstStep",n,"The first step",`Auto comes below ${l}: step 1, or the bottom of the slider.`,s),b("fan-auto","lastStep",n,"The last step",`Auto comes above ${c}: the top step, or 100 %.`,s)];return o("div",{class:"field"},o("h3",{id:"fan-auto-title"},"Auto fan speed"),r?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"},...d))}function $e(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 r=e.fanControl==="hidden",a=t.hasFanAuto&&!r&&(e.fanAutoControl==="firstStep"||e.fanAutoControl==="lastStep"),l=t.hasFanAuto&&e.fanAutoControl==="switch",c=t.fanSteps;a&&(c=e.fanAutoControl==="firstStep"?["auto",...t.fanSteps]:[...t.fanSteps,"auto"]);let m=t.hasFanAuto&&!a?" Auto is not among them: it is a fan mode of its own.":"",y=`${c.length} ${c.length===1?"speed":"speeds"}, ${a?"in order":"slowest first"}: ${Ae(c)}.${m}`;return o("section",{},o("h2",{},"Fan speed"),o("div",{class:"choices"},D("fan","steps",e.fanControl,"Steps",y,E.steps,u=>f(e,{fanControl:u})),D("fan","percent",e.fanControl,"Percentage",`A slider from 0 to 100, which the plugin rounds to the nearest of ${y}`,E.percent,u=>f(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=>f(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=>f(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=>f(e,{hasSeparateFan:u})),Te(e,t,r&&!l?"native":e.fanAutoControl))}function Re(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"),r="One switch, for the up and down swing.";return n&&s?r="Two switches: one for the up and down swing, one for left and right.":s&&(r="One switch, for the left and right swing."),o("section",{},o("h2",{},"Swing"),o("div",{class:"choices"},D("swing","switches",e.swingControl,"Switches",r,E.switches,a=>f(e,{swingControl:a})),D("swing","select",e.swingControl,"A mode select",`${j(e,"Swing",!0)}, and picks one of: ${t.map(a=>a==="both"?Z[a]:Z[a].toLowerCase()).join(", ")}. ${he}`,E.select,a=>f(e,{swingControl:a})),D("swing","hidden",e.swingControl,"Not shown in Matter","No swing control. Pick below what the plugin does with the swing instead.",E.hidden,a=>f(e,{swingControl:a}))),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:a=>f(e,{swingModeWhenHidden:a.target.value})},o("option",{value:"keep",selected:e.swingModeWhenHidden==="keep"},"stays as it is"),...t.map(a=>o("option",{value:a,selected:e.swingModeWhenHidden===a},`is set to: ${Z[a]}`)))):null)}function Ee(e,t){let n=H(e.modeReplacements,t);return o("div",{class:"replacements"},...t.lackingModes.flatMap(s=>{let r=`mode-replacement-${s}`,a=t.switchableModes.find(d=>n[d]===s),l=Object.fromEntries(Object.entries(n).filter(([,d])=>d!==s)),c=d=>{let m=d.target.value,y={...l};m!==""&&(y[m]=s),f(e,{modeReplacements:H(y,t)})};return[o("label",{for:r},R[s]),o("select",{id:r,onchange:c},o("option",{value:"",selected:a===void 0},"is not offered"),...t.switchableModes.map(d=>o("option",{value:d,selected:a===d,disabled:l[d]!==void 0||!V(d,s,l,t)},`runs ${R[d].toLowerCase()}`)))]}))}function De(e,t){let{switchableModes:n,lackingModes:s}=t;if(n.length===0)return null;let r=n.filter(g=>e.modeSwitches.includes(g)),a=n.filter(g=>g==="dehumidify"||g==="fan"),l=a.length>0,c=e.modeControl==="select"&&!l?"native":e.modeControl,d=g=>{g==="switches"&&r.length===0?f(e,{modeControl:g,modeSwitches:l?a:[...n]}):f(e,{modeControl:g})},m=n.includes("cool")?"cool":"heat",y=a.map(g=>R[g].toLowerCase()).join(" and "),u=l?`Off turns the unit off, or from ${y} puts it back in ${m}.`:"Off turns the unit off.",k=`${R[r.length>0?r[0]:n[0]]} Mode`,w=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(g=>R[g].toLowerCase()),me=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",c,"Native modes only","The modes of the unit are those of the air conditioner, as Matter has them, and nothing more is added.",d),l?b("mode-control","select",c,"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. ${he}`,d):null,b("mode-control","switches",c,"Switches",`A switch for each mode picked below. On turns the unit on in that mode. ${u}`,d),c==="switches"?o("div",{class:"sub"},xe("mode-switch","Modes that get a switch",n,r,R,g=>f(e,{modeSwitches:g})),o("p",{class:"help"},w)):null),s.length>0?o("div",{class:"field"},o("h3",{},"Modes the unit lacks"),o("p",{class:"help"},`This unit has no ${me}. 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.`),Ee(e,t)):null)}function He(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 ${pe[n].title}`,pe[n].text,s=>f(e,{specialModeSwitches:t.specialModes.filter(r=>r===n?s:e.specialModeSwitches.includes(r))})))))}function Le(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=>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 Fe(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=>f(e,{isComposed:t}))))}function ue(){let e=v();if(e===void 0)return[S()];let t=e.controls??ee;return[$(),U(),K(e,`Options for the air conditioner at ${e.adapter.host}. Power, mode and temperature always appear in Matter: choose how the rest appears.`),ke(e,t),$e(e,t),Re(e),De(e,t),He(e,t),Le(e),Fe(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",x),h(e.isNew?`Add ${e.name}`:"Save options",()=>{ie(e)},"primary"))]}function fe(){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{}}oe({loading:()=>[o("p",{class:"notice working",role:"status"},o("span",{class:"spinner"}),"Loading\u2026")],home:de,find:le,connect:re,options:ue,done:ce});fe();p();W();
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.
@@ -11,6 +11,12 @@ async function b(e,t,n){try{let[i,r]=e.split(" "),a={method:i};t!==void 0&&(a.he
11
11
  * @author Calvin Che
12
12
  * @license Apache-2.0
13
13
  */
14
+ /**
15
+ * @file apps/frontend/src/presets.ts
16
+ * @description The presets of the Options step: each fills in the choices of how a device appears in Matter.
17
+ * @author Calvin Che
18
+ * @license Apache-2.0
19
+ */
14
20
  /**
15
21
  * @file apps/frontend/src/state.ts
16
22
  * @description What the setup page knows at any moment, and what it reads from that.
@@ -66,15 +72,9 @@ async function b(e,t,n){try{let[i,r]=e.split(" "),a={method:i};t!==void 0&&(a.he
66
72
  * @author Calvin Che
67
73
  * @license Apache-2.0
68
74
  */
69
- /**
70
- * @file apps/frontend/src/presets.ts
71
- * @description The presets of the Options step: each fills in the choices of how a device appears in Matter.
72
- * @author Calvin Che
73
- * @license Apache-2.0
74
- */
75
75
  /**
76
76
  * @file apps/frontend/src/screens/options.ts
77
- * @description The Options step: how the fan, the swing, the extra modes and the readings of a unit appear in Matter, one section each, and whether as one device.
77
+ * @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.
78
78
  * @author Calvin Che
79
79
  * @license Apache-2.0
80
80
  */