diff --git a/bundles/org.openhab.io.homekit/README.md b/bundles/org.openhab.io.homekit/README.md index cf399eb201b..fe562d006c7 100644 --- a/bundles/org.openhab.io.homekit/README.md +++ b/bundles/org.openhab.io.homekit/README.md @@ -688,6 +688,19 @@ All enum values can be customized via item metadata. I.e. `HEAT="heating", COOL= They are appropriately marked. Enums that are linked to Switches or Contacts have an `inverted` param that will reverse the sense of `ON`/`OFF` or `OPEN`/`CLOSED`. +All accessories support the following characteristics that can be set via metadata or linked to a String item: + * Name (defaults to item's label) + * Manufacturer (defaults to "none") + * Model (defaults to "none") + * SerialNumber (defaults to item's name) + * FirmwareRevision (defaults to "none") + * HardwareRevision (defaults to not present) + +Note that even though these characteristics can be linked to an item, they are not dynamic and cannot be updated once the Home app reads their initial values. + +All accessories also support the following optional characteristic that can be linked to a Switch item: + * Identify (receives `ON` command when the user wishes to identify the accessory) + | Accessory Tag | Mandatory Characteristics | Optional Characteristics | Supported openHAB item types | Description | Configuration Options | Valid Enum Values | |----------------------|-----------------------------|-----------------------------|-----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------| | AirQualitySensor | | | | Air Quality Sensor which can measure different parameters | | | @@ -695,7 +708,6 @@ Enums that are linked to Switches or Contacts have an `inverted` param that will | | | ActiveStatus | Contact, Switch | Working status | | | | | | BatteryLowStatus | Contact, Number, Switch | Battery status | inverted (false), lowThreshold (20) | | | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | -| | | Name | String | Name of the sensor | | | | | | NitrogenDioxideDensity | Number | NO2 density in micrograms/m3, max 1000 | | | | | | OzoneDensity | Number | Ozone density in micrograms/m3, max 1000 | | | | | | PM10Density | Number | PM10 micrometer particulate density in micrograms/m3, max 1000 | | | @@ -711,7 +723,6 @@ Enums that are linked to Switches or Contacts have an `inverted` param that will | | BatteryLevel | | Number | Battery level 0% to 100% | | | | | BatteryChargingState | | Contact, Dimmer, Switch | Mandatory only for chargeable battery. ON/OPEN = battery is charging | | | | | BatteryLowStatus | | Contact, Number, Switch | Battery low indicator. ON/OPEN = battery level is low; for number if the value is below the lowThreshold, then it is low. Default is 20. | inverted (false), lowThreshold (20) | | -| | | Name | String | Name of the battery accessory | | | | CarbonDioxideSensor | | | | Carbon Dioxide Sensor | | | | | CarbonDioxideDetectedState | | Contact, Dimmer, Switch, Number, String | carbon dioxide sensor state | inverted (false) | NORMAL (0, OFF, CLOSED), ABNORMAL (1, ON, OPEN) | | | | ActiveStatus | Contact, Switch | Working status | | | @@ -719,7 +730,6 @@ Enums that are linked to Switches or Contacts have an `inverted` param that will | | | CarbonDioxideLevel | Number | Carbon dioxide level in ppm, max 100000 | | | | | | CarbonDioxidePeakLevel | Number | highest detected level (ppm) of carbon dioxide detected by a sensor, max 100000 | | | | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | -| | | Name | String | Name of the sensor | | | | | | TamperedStatus | Contact, Number, String, Switch | Tampered status | inverted (false) | NOT_TAMPERED (0, OFF, CLOSED), TAMPERED (1, ON, OPEN) | | CarbonMonoxideSensor | | | | Carbon monoxide Sensor | | | | | CarbonMonoxideDetectedState | | Contact, Dimmer, Switch, Number, String | Carbon monoxide sensor state | inverted (false) | NORMAL (0, OFF, CLOSED), ABNORMAL (1, ON, OPEN) | @@ -728,21 +738,18 @@ Enums that are linked to Switches or Contacts have an `inverted` param that will | | | CarbonMonoxideLevel | Number | Carbon monoxide level in ppm, max 100 | | | | | | CarbonMonoxidePeakLevel | Number | highest detected level (ppm) of carbon monoxide detected by a sensor, max 100 | | | | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | -| | | Name | String | Name of the sensor | | | | | | TamperedStatus | Contact, Number, String, Switch | Tampered status | inverted (false) | NOT_TAMPERED (0, OFF, CLOSED), TAMPERED (1, ON, OPEN) | | ContactSensor | | | | Contact Sensor, An accessory with on/off state that can be viewed in HomeKit but not changed such as a contact sensor for a door or window | | | | | ContactSensorState | | Contact, Dimmer, Number, String, Switch | Contact sensor state | inverted (false) | DETECTED (0, OFF, CLOSED), NOT_DETECTED (1, ON, OPEN) | | | | ActiveStatus | Contact, Switch | Working status | | | | | | BatteryLowStatus | Contact, Number, Switch | Battery status | inverted (false), lowThreshold (20) | | | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | -| | | Name | String | Name of the sensor | | | | | | TamperedStatus | Contact, Number, String, Switch | Tampered status | inverted (false) | NOT_TAMPERED (0, OFF, CLOSED), TAMPERED (1, ON, OPEN) | | Door | | | | Motorized door. One Rollershutter item covers all mandatory characteristics. see examples below. | | | | | CurrentPosition | | Dimmer, Number, Rollershutter | Current position of motorized door | | | | | PositionState | | Number, Rollershutter, String | Position state. If no state is provided, "STOPPED" is used. | | DECREASING (0), INCREASING (1), STOPPED (2) | | | TargetPosition | | Dimmer, Number, Rollershutter | Target position of motorized door | | | | | | HoldPosition | Rollershutter, Switch | Motorized door should stop at its current position. ON is sent to Switch items. STOP is sent to Rollershutter items. Only supported by 3rd party Home apps (such as Elgato Eve) | | | -| | | Name | String | Name of the motorized door | | | | | | ObstructionStatus | Contact, Dimmer, Switch | Current status of obstruction sensor. ON-obstruction detected, OFF - no obstruction | | | | Fan | | | | Fan | | | | | ActiveStatus | | Dimmer, Switch | Accessory current working status. A value of "ON"/"OPEN" indicates that the accessory is active and is functioning without any errors. | | | @@ -755,17 +762,14 @@ Enums that are linked to Switches or Contacts have an `inverted` param that will | Faucet | | | | Faucet or shower. It should be used in combination with Valve or/and HeaterCooler. | | | | | Active | | Contact, Dimmer, Switch | Accessory current working status | inverted (false) | | | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | -| | | Name | String | Name of the Faucet | | | | Filter | | | | Accessory with filter maintenance indicator | | | | | FilterChangeIndication | | Contact, Dimmer, Number, String, Switch | Filter change indicator | inverted (false) | NO_CHANGED_NEEDED (0, OFF, CLOSED), CHANGE_NEEDED (1, ON, OPEN) | | | | FilterLifeLevel | Number | Current filter life level. 0% to 100% | | | | | | FilterResetIndication | Switch | Send "filter reset" action triggered by user in iOS Home app to openHAB ("ON" = reset requested by user). | | | -| | | Name | String | Name of the filter accessory | | | | GarageDoorOpener | | | | A garage door opener. | | | | | CurrentDoorState | | Contact, Switch, Number, String | Current door state. | inverted (false) | OPEN (0, ON, OPEN), CLOSED (1, OFF, CLOSED), OPENING (2), CLOSING (3), STOPPED (4) | | | ObstructionStatus | | Contact, Switch | Current status of obstruction sensor. ON-obstruction detected, OFF - no obstruction | inverted (false) | | | | TargetDoorState | | Contact, Switch, Number, String | Target door state. | inverted (false) | OPEN (0, ON, OPEN), CLOSED (1, OFF, CLOSED) | -| | | Name | String | Name of the garage door | | | | HeaterCooler | | | | Heater or/and cooler device | | | | | ActiveStatus | | Dimmer, Switch | Accessory current working status. A value of "ON"/"OPEN" indicates that the accessory is active and is functioning without any errors. | | | | | CurrentHeaterCoolerState | | Number, String | Current heater/cooler mode. | | INACTIVE (0), IDLE (1), HEATING (2), COOLING (3) | @@ -774,7 +778,6 @@ Enums that are linked to Switches or Contacts have an `inverted` param that will | | | CoolingThresholdTemperature | Number | Maximum temperature that must be reached before cooling is turned on | minValue (10), maxValue (35), step (0.1) | | | | | HeatingThresholdTemperature | Number | Minimum temperature that must be reached before heating is turned on | minValue (0), maxValue (25), step (0.1) | | | | | LockControl | Number, Switch, String | Status of physical control lock | inverted (false) | CONTROL_LOCK_DISABLED (0, OFF), CONTROL_LOCK_ENABLED (1, ON) | -| | | Name | String | Name of the heater/cooler | | | | | | RotationSpeed | Number | Fan rotation speed in % (1-100) | | | | | | SwingMode | Number, Switch, String | Swing mode | inverted (false) | SWING_DISABLED (0, OFF), SWING_ENABLED (1, ON) | | HumiditySensor | | | | Relative Humidity Sensor providing read-only values | | | @@ -782,10 +785,8 @@ Enums that are linked to Switches or Contacts have an `inverted` param that will | | | ActiveStatus | Contact, Switch | Working status | | | | | | BatteryLowStatus | Contact, Number, Switch | Battery status | inverted (false), lowThreshold (20) | | | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | -| | | Name | String | Name of the sensor | | | | | | TamperedStatus | Contact, Number, String, Switch | Tampered status | inverted (false) | NOT_TAMPERED (0, OFF, CLOSED), TAMPERED (1, ON, OPEN) | | InputSource | | | | Input source linked service. Can only be used with Television. | | | -| | | Name | String | Default name of the input source | | | | | | ConfiguredName | String | Name of the input source configured in the iOS Home app. User can rename the source in iOS Home app and this characteristic can be used to reflect change in openHAB and sync name changes from openHAB to Home app. | | | | | | Configured | Contact, Dimmer, Switch | If the source is configured on the device. Non-configured inputs will not show up in the Home app. - ON/OPEN = show, OFF/CLOSED = hide. Default is ON. Can also be configured via metadata, e.g. [Configured=true] | | | | | | CurrentVisibility | Contact, Dimmer, Number, String, Switch | If the source has been hidden by the user. Can also be configured via metadata, e.g. [CurrentVisibility=false] | inverted (false) | SHOWN (0, ON), HIDDEN (1, OFF) | @@ -804,58 +805,48 @@ Enums that are linked to Switches or Contacts have an `inverted` param that will | | | ActiveStatus | Contact, Switch | Working status | | | | | | BatteryLowStatus | Contact, Number, Switch | Battery status | inverted (false), lowThreshold (20) | | | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | -| | | Name | String | Name of the sensor | | | | | | TamperedStatus | Contact, Number, String, Switch | Tampered status | inverted (false) | NOT_TAMPERED (0, OFF, CLOSED), TAMPERED (1, ON, OPEN) | | LightSensor | | | | Light sensor | | | | | LightLevel | | Number | Light level in lux | minValue (0.0001), maxValue (100000) | | | | | ActiveStatus | Contact, Switch | Working status | | | | | | BatteryLowStatus | Contact, Number, Switch | Battery status | inverted (false), lowThreshold (20) | | | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | -| | | Name | String | Name of the sensor | | | | | | TamperedStatus | Contact, Number, String, Switch | Tampered status | inverted (false) | NOT_TAMPERED (0, OFF, CLOSED), TAMPERED (1, ON, OPEN) | | Lighting | | | | A lightbulb, can have further optional parameters for brightness, hue, etc | | | | | OnState | | Switch | State of the light - ON/OFF | | | | | | Brightness | Dimmer, Color | Brightness in % (1-100). See "Usage of dimmer modes" for configuration details. | | | | | | ColorTemperature | Dimmer, Number | Color temperature. If the item is a Number with no units, it is represented in mireds. The default value range is from 50 to 400 (2500 K to 20,000 K). If the item is a Dimmer, it will be transformed linearly to mireds. Color temperature should not be used in combination with hue, saturation and brightness. | minValue (50), maxValue (400), inverted | | | | | Hue | Dimmer, Color | Hue | | | -| | | Name | String | Name of the light | | | | | | Saturation | Dimmer, Color | Saturation in % (1-100) | | | | Lock | | | | A Lock Mechanism | inverted (false) | | | | LockCurrentState | | Contact, Number, String, Switch | Current state of lock mechanism | inverted (false) | UNSECURED (0, OFF, CLOSED), SECURED (1, ON, OPEN), JAMMED (2), UNKNOWN (3) | | | LockTargetState | | Number, String, Switch | Target state of lock mechanism | inverted (false) | UNSECURED (0, OFF), SECURED (1, ON) | -| | | Name | String | Name of the lock | | | | Microphone | | | | Microphone accessory | | | | | Mute | | Contact, Dimmer, Switch | Mute indication. ON/OPEN = microphone is muted | inverted (false) | | -| | | Name | String | Name of the microphone accessory | | | | | | Volume | Number | Microphone volume from 0% to 100% | | | | MotionSensor | | | | Motion Sensor | | | | | MotionDetectedState | | Contact, Dimmer, Switch | Motion sensor state (ON=motion detected, OFF=no motion) | inverted (false) | | | | | ActiveStatus | Contact, Switch | Working status | | | | | | BatteryLowStatus | Contact, Number, Switch | Battery status | inverted (false), lowThreshold (20) | | | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | -| | | Name | String | Name of the sensor | | | | | | TamperedStatus | Contact, Number, String, Switch | Tampered status | inverted (false) | NOT_TAMPERED (0, OFF, CLOSED), TAMPERED (1, ON, OPEN) | | OccupancySensor | | | | Occupancy Sensor | | | | | OccupancyDetectedState | | Contact, Dimmer, Number, String, Switch | Occupancy sensor state | inverted (false) | NOT_DETECTED (0, OFF, CLOSED), DETECTED (1, ON, OPEN) | | | | ActiveStatus | Contact, Switch | Working status | | | | | | BatteryLowStatus | Contact, Number, Switch | Battery status | inverted (false), lowThreshold (20) | | | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | -| | | Name | String | Name of the sensor | | | | | | TamperedStatus | Contact, Number, String, Switch | Tampered status | inverted (false) | NOT_TAMPERED (0, OFF, CLOSED), TAMPERED (1, ON, OPEN) | | Outlet | | | | An accessory that can be turned off and on. While similar to a lightbulb, this will be presented differently in the Siri grammar and iOS apps | | | | | InUseStatus | | Contact, Dimmer, Switch | Indicates whether the outlet has an appliance e.g., a floor lamp, physically plugged in. This characteristic is set to True even if the plugged-in appliance is off. | inverted (false) | | | | OnState | | Dimmer, Switch | State of the outlet - ON/OFF | | | -| | | Name | String | Name of the switch | | | | SecuritySystem | | | | Security system. | | | | | CurrentSecuritySystemState | | Number, String | Current state of the security system | | STAY_ARM (0), AWAY_ARM (1), NIGHT_ARM (2), DISARMED (3), TRIGGERED (4) | | | TargetSecuritySystemState | | Number, String | Requested state of the security system. While the requested state is not DISARM, and the current state is DISARMED, HomeKit will display "Arming...", for example during an exit delay. | | STAY_ARM (0), AWAY_ARM (1), NIGHT_ARM (2), DISARM (3) [*](#customizable-enum) | | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | -| | | Name | String | Name of the security system | | | | | | TamperedStatus | Contact, Number, String, Switch | Tampered status | inverted (false) | NOT_TAMPERED (0, OFF, CLOSED), TAMPERED (1, ON, OPEN) | | Slat | | | | Slat which tilts on a vertical or a horizontal axis. Configuration "type:horizontal" or "type:vertical" | | | | | CurrentSlatState | | Number, String | Current slat state. | | FIXED (0), JAMMED (1), SWINGING (2) | | | | CurrentTiltAngle | Dimmer, Number | Number Item = current angle of slats. values -90 to 90. A value of 0 indicates that the slats are rotated to a fully open position. Dimmer Item = the percentage of openness (0%-100%) | | | -| | | Name | String | Name of the slat | | | | | | SwingMode | Number, Switch, String | Swing mode | inverted (false) | SWING_DISABLED (0, OFF), SWING_ENABLED (1, ON) | | | | TargetTiltAngle | Dimmer, Number | Number Item = target angle of slats (-90 to +90). Dimmer Item = the percentage of openness (0%-100%) | | | | SmartSpeaker | | | | Smart speaker accessory with Play/Stop/Pause control | | | @@ -863,23 +854,19 @@ Enums that are linked to Switches or Contacts have an `inverted` param that will | | TargetMediaState | | Number, String | Target smart speaker state | | PLAY (0), PAUSE (1), STOP (2) | | | | ConfiguredName | String | Name of the speaker accessory configured in iOS Home app. User can rename the speaker in iOS Home app and this characteristic can be used to reflect change in openHAB and sync name changes from openHAB to Home app. | | | | | | Mute | Contact, Switch | Mute indication. ON/OPEN = speaker is muted | inverted (false) | | -| | | Name | String | Name of the speaker accessory | | | | | | Volume | Number | Speaker volume from 0% to 100% | | | | SmokeSensor | | | | Smoke Sensor | | | | | SmokeDetectedState | | Contact, Dimmer, Number, String, Switch | Smoke sensor state | inverted (false) | NOT_DETECTED (0, OFF, CLOSED), DETECTED (1, ON, OPEN) | | | | ActiveStatus | Contact, Switch | Working status | | | | | | BatteryLowStatus | Contact, Number, Switch | Battery status | inverted (false), lowThreshold (20) | | | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | -| | | Name | String | Name of the sensor | | | | | | TamperedStatus | Contact, Number, String, Switch | Tampered status | inverted (false) | NOT_TAMPERED (0, OFF, CLOSED), TAMPERED (1, ON, OPEN) | | Speaker | | | | Speaker accessory | | | | | Mute | | Contact, Dimmer, Switch | Mute indication. ON/OPEN = speaker is muted | inverted (false) | | | | | Active | Contact, Dimmer, Number, String, Switch | Accessory current working status | inverted (false) | INACTIVE (0, OFF), ACTIVE (1, ON) | -| | | Name | String | Name of the speaker accessory | | | | | | Volume | Number | Speaker volume from 0% to 100% | | | | Switchable | | | | An accessory that can be turned off and on. While similar to a lightbulb, this will be presented differently in the Siri grammar and iOS apps | | | | | OnState | | Dimmer, Switch | State of the switch - ON/OFF | | | -| | | Name | String | Name of the switch | | | | Television | | | | Television accessory with inputs | | | | | Active | | Contact, Dimmer, Number, String, Switch | State of the television (on/off) | inverted (false) | INACTIVE (0, OFF), ACTIVE (1, ON) | | | | ActiveIdentifier | Number | The input that is currently active (based on its identifier). Can also be configured via metadata, e.g. [ActiveIdentifier=1] | | | @@ -887,7 +874,6 @@ Enums that are linked to Switches or Contacts have an `inverted` param that will | | | ClosedCaptions | Contact, Dimmer, Number, String, Switch | Indicates closed captions are enabled. Can also be configured via metadata, e.g. [ClosedCaptions=true] | inverted (false) | DISABLED (0, OFF), ENABLED (1, ON) | | | | ConfiguredName | String | Name of the television accessory configured in the iOS Home app. User can rename the television in iOS Home app and this characteristic can be used to reflect change in openHAB and sync name changes from openHAB to Home app. | | | | | | CurrentMediaState | Number, String | Current television state. | | PLAY (0), PAUSE (1), STOP (2), UNKNOWN (3) | -| | | Name | String | Name of the television accessory | | | | | | PictureMode | Number, String | Selected picture mode. | | OTHER (0), STANDARD (1), CALIBRATED (2), CALIBRATED_DARK (3), VIVID (4), GAME (5), COMPUTER (6), CUSTOM (7) | | | | PowerMode | Switch, Number, String | This oddly named characteristic will receive an ON command when the user requests to open the TV's menu. | inverted (false) | SHOW (0, ON), HIDE (1, OFF) | | | | RemoteKey | String | Receives a keypress event. | | | @@ -904,7 +890,6 @@ Enums that are linked to Switches or Contacts have an `inverted` param that will | | | ActiveStatus | Contact, Switch | Working status | | | | | | BatteryLowStatus | Contact, Number, Switch | Battery status | inverted (false), lowThreshold (20) | | | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | -| | | Name | String | Name of the sensor | | | | | | TamperedStatus | Contact, Number, String, Switch | Tampered status | inverted (false) | NOT_TAMPERED (0, OFF, CLOSED), TAMPERED (1, ON, OPEN) | | Thermostat | | | | A thermostat requires all mandatory characteristics defined below | | | | | CurrentHeatingCoolingMode | | Number, String | Current heating cooling mode | | OFF (0, OFF), HEAT (1, ON), COOL (2) | @@ -913,20 +898,17 @@ Enums that are linked to Switches or Contacts have an `inverted` param that will | | TargetTemperature | | Number | Target temperature. | minValue (10), maxValue (38), step (0.1) | | | | | CoolingThresholdTemperature | Number | Maximum temperature that must be reached before cooling is turned on | minValue (10), maxValue (35), step (0.1) | | | | | HeatingThresholdTemperature | Number | Minimum temperature that must be reached before heating is turned on | minValue (0), maxValue (25), step (0.1) | | -| | | Name | String | Name of the thermostat | | | | | | RelativeHumidity | Number | Relative humidity in % between 0 and 100. | | | | Valve | | | | Valve | ValveType = ["Generic", "Irrigation", "Shower", "Faucet"] ("Generic") | | | | ActiveStatus | | Dimmer, Switch | Accessory current working status. A value of "ON"/"OPEN" indicates that the accessory is active and is functioning without any errors. | | | | | InUseStatus | | Contact, Dimmer, Switch | Indicates whether fluid flowing through the valve. A value of "ON"/"OPEN" indicates that fluid is flowing. | inverted (false) | | | | | Duration | Number | Defines how long a valve should be set to ʼIn Useʼ in second. | homekitDefaultDuration = {default duration in seconds} | | | | | FaultStatus | Contact, Number, String, Switch | Fault status | inverted (false) | NO_FAULT (0, OFF, CLOSED), GENERAL_FAULT (1, ON, OPEN) | -| | | Name | String | Name of the valve | | | | | | RemainingDuration | Number | Describes the remaining duration on the accessory. the remaining duration increases/decreases from the accessoryʼs usual countdown. i.e. changes from 90 to 80 in a second. | | | | Window | | | | Motorized window. One Rollershutter item covers all mandatory characteristics. see examples below. | | | | | CurrentPosition | | Dimmer, Number, Rollershutter | Current position of motorized window | | | | | PositionState | | Number, Rollershutter, String | Position state. If no state is provided, "STOPPED" is used. | | DECREASING (0), INCREASING (1), STOPPED (2) | | | TargetPosition | | Dimmer, Number, Rollershutter | Target position of motorized window | | | -| | | Name | String | Name of the motorized window | | | | | | HoldPosition | Rollershutter, Switch | Motorized door should stop at its current position. ON is sent to Switch items. STOP is sent to Rollershutter items. Only supported by 3rd party Home apps (such as Elgato Eve) | | | | | | ObstructionStatus | Contact, Dimmer, Switch | Current status of obstruction sensor. ON-obstruction detected, OFF - no obstruction | | | | WindowCovering | | | | Window covering / blinds. One Rollershutter item covers all mandatory characteristics. see examples below. | | | @@ -936,7 +918,6 @@ Enums that are linked to Switches or Contacts have an `inverted` param that will | | | CurrentHorizontalTiltAngle | Dimmer, Number | Number Item = current angle of horizontal slats. values -90 to 90. A value of 0 indicates that the slats are rotated to a fully open position. A value of -90 indicates that the slats are rotated all the way in a direction where the user-facing edge is higher than the window-facing edge. Dimmer Item = the percentage of openness (0%-100%) | | | | | | CurrentVerticalTiltAngle | Dimmer, Number | Number Item = current angle of vertical slats (-90 to +90) . Dimmer Item = the percentage of openness (0%-100%) | | | | | | HoldPosition | Rollershutter, Switch | Motorized door should stop at its current position. ON is sent to Switch items. STOP is sent to Rollershutter items. Only supported by 3rd party Home apps (such as Elgato Eve) | | | -| | | Name | String | Name of the windows covering | | | | | | ObstructionStatus | Contact, Dimmer, Switch | Current status of obstruction sensor. ON-obstruction detected, OFF - no obstruction | | | | | | TargetHorizontalTiltAngle | Dimmer, Number | Number Item = target angle of horizontal slats (-90 to +90). Dimmer Item = the percentage of openness (0%-100%) | | | | | | TargetVerticalTiltAngle | Dimmer, Number | Number Item = target angle of vertical slats. Dimmer Item = the percentage of openness (0%-100%) | | | diff --git a/bundles/org.openhab.io.homekit/pom.xml b/bundles/org.openhab.io.homekit/pom.xml index 73b23312f09..80d3e91cd2c 100644 --- a/bundles/org.openhab.io.homekit/pom.xml +++ b/bundles/org.openhab.io.homekit/pom.xml @@ -22,7 +22,7 @@ io.github.hap-java hap - 2.0.5 + 2.0.6 compile diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitChangeListener.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitChangeListener.java index 9b5ee21d5b3..8da0410312f 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitChangeListener.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitChangeListener.java @@ -12,7 +12,6 @@ */ package org.openhab.io.homekit.internal; -import java.lang.reflect.InvocationTargetException; import java.time.Clock; import java.time.Duration; import java.util.ArrayList; @@ -48,7 +47,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import io.github.hapjava.accessories.HomekitAccessory; -import io.github.hapjava.characteristics.impl.common.NameCharacteristic; import io.github.hapjava.server.impl.HomekitRoot; /** @@ -476,20 +474,7 @@ public class HomekitChangeListener implements ItemRegistryChangeListener { try { final AbstractHomekitAccessoryImpl additionalAccessory = HomekitAccessoryFactory .create(additionalTaggedItem, metadataRegistry, updater, settings); - // Secondary accessories that don't explicitly specify a name will implicitly - // get a name characteristic based on the item's name - if (!additionalAccessory.getCharacteristic(HomekitCharacteristicType.NAME).isPresent()) { - try { - additionalAccessory.addCharacteristic( - new NameCharacteristic(() -> additionalAccessory.getName())); - } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { - // This should never happen; all services should support NameCharacteristic as an - // optional Characteristic. - // If HAP-Java defined a service that doesn't support - // addOptionalCharacteristic(NameCharacteristic), then it's a bug there, and we're - // just going to ignore the exception here. - } - } + additionalAccessory.promoteNameCharacteristic(); accessory.getServices().add(additionalAccessory.getPrimaryService()); } catch (HomekitException e) { logger.warn("Cannot create additional accessory {}", additionalTaggedItem); diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitCharacteristicType.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitCharacteristicType.java index b8b83f630db..556b975faca 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitCharacteristicType.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitCharacteristicType.java @@ -27,7 +27,15 @@ public enum HomekitCharacteristicType { * It is illegal to have a characteristic type also be a device type */ EMPTY("Empty"), // used in case only accessory type but no characteristic provided + NAME("Name"), + MANUFACTURER("Manufacturer"), + MODEL("Model"), + SERIAL_NUMBER("SerialNumber"), + FIRMWARE_REVISION("FirmwareRevision"), + HARDWARE_REVISION("HardwareRevision"), + IDENTIFY("Identify"), + BATTERY_LOW_STATUS("BatteryLowStatus"), ACTIVE_STATUS("ActiveStatus"), ISCONFIGURED("IsConfigured"), diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/AbstractHomekitAccessoryImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/AbstractHomekitAccessoryImpl.java index b8f13071e45..228de13211e 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/AbstractHomekitAccessoryImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/AbstractHomekitAccessoryImpl.java @@ -45,8 +45,16 @@ import io.github.hapjava.accessories.HomekitAccessory; import io.github.hapjava.characteristics.Characteristic; import io.github.hapjava.characteristics.CharacteristicEnum; import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; +import io.github.hapjava.characteristics.impl.accessoryinformation.FirmwareRevisionCharacteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.HardwareRevisionCharacteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.IdentifyCharacteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.ManufacturerCharacteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.ModelCharacteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.SerialNumberCharacteristic; import io.github.hapjava.characteristics.impl.base.BaseCharacteristic; +import io.github.hapjava.characteristics.impl.common.NameCharacteristic; import io.github.hapjava.services.Service; +import io.github.hapjava.services.impl.AccessoryInformationService; /** * Abstract class for Homekit Accessory implementations, this provides the @@ -62,6 +70,7 @@ public abstract class AbstractHomekitAccessoryImpl implements HomekitAccessory { private final HomekitSettings settings; private final List services; private final Map, Characteristic> rawCharacteristics; + private boolean isLinkedService = false; public AbstractHomekitAccessoryImpl(HomekitTaggedItem accessory, List characteristics, HomekitAccessoryUpdater updater, HomekitSettings settings) { @@ -88,6 +97,52 @@ public abstract class AbstractHomekitAccessoryImpl implements HomekitAccessory { * @throws HomekitException */ public void init() throws HomekitException { + // initialize the AccessoryInformation Service with defaults if not specified + if (!rawCharacteristics.containsKey(NameCharacteristic.class)) { + rawCharacteristics.put(NameCharacteristic.class, new NameCharacteristic(() -> { + return CompletableFuture.completedFuture(accessory.getItem().getLabel()); + })); + } + + if (!isLinkedService()) { + if (!rawCharacteristics.containsKey(IdentifyCharacteristic.class)) { + rawCharacteristics.put(IdentifyCharacteristic.class, new IdentifyCharacteristic(v -> { + })); + } + if (!rawCharacteristics.containsKey(ManufacturerCharacteristic.class)) { + rawCharacteristics.put(ManufacturerCharacteristic.class, new ManufacturerCharacteristic(() -> { + return CompletableFuture.completedFuture("none"); + })); + } + if (!rawCharacteristics.containsKey(ModelCharacteristic.class)) { + rawCharacteristics.put(ModelCharacteristic.class, new ModelCharacteristic(() -> { + return CompletableFuture.completedFuture("none"); + })); + } + if (!rawCharacteristics.containsKey(SerialNumberCharacteristic.class)) { + rawCharacteristics.put(SerialNumberCharacteristic.class, new SerialNumberCharacteristic(() -> { + return CompletableFuture.completedFuture(accessory.getItem().getName()); + })); + } + if (!rawCharacteristics.containsKey(FirmwareRevisionCharacteristic.class)) { + rawCharacteristics.put(FirmwareRevisionCharacteristic.class, new FirmwareRevisionCharacteristic(() -> { + return CompletableFuture.completedFuture("none"); + })); + } + + var service = new AccessoryInformationService(getCharacteristic(IdentifyCharacteristic.class).get(), + getCharacteristic(ManufacturerCharacteristic.class).get(), + getCharacteristic(ModelCharacteristic.class).get(), + getCharacteristic(NameCharacteristic.class).get(), + getCharacteristic(SerialNumberCharacteristic.class).get(), + getCharacteristic(FirmwareRevisionCharacteristic.class).get()); + + getCharacteristic(HardwareRevisionCharacteristic.class) + .ifPresent(c -> service.addOptionalCharacteristic(c)); + + // make sure this is the first service + services.add(0, service); + } } /** @@ -99,6 +154,20 @@ public abstract class AbstractHomekitAccessoryImpl implements HomekitAccessory { return false; } + /** + * Sets if this accessory is being used as a linked service. + */ + public void setIsLinkedService(boolean value) { + isLinkedService = value; + } + + /** + * @return If this accessory is being used as a linked service. + */ + public boolean isLinkedService() { + return isLinkedService; + } + /** * @return If this accessory is only valid as a linked service, not as a standalone accessory. */ @@ -118,32 +187,36 @@ public abstract class AbstractHomekitAccessoryImpl implements HomekitAccessory { @Override public CompletableFuture getName() { - return CompletableFuture.completedFuture(accessory.getItem().getLabel()); + return getCharacteristic(NameCharacteristic.class).get().getValue(); } @Override public CompletableFuture getManufacturer() { - return CompletableFuture.completedFuture("none"); + return getCharacteristic(ManufacturerCharacteristic.class).get().getValue(); } @Override public CompletableFuture getModel() { - return CompletableFuture.completedFuture("none"); + return getCharacteristic(ModelCharacteristic.class).get().getValue(); } @Override public CompletableFuture getSerialNumber() { - return CompletableFuture.completedFuture(accessory.getItem().getName()); + return getCharacteristic(SerialNumberCharacteristic.class).get().getValue(); } @Override public CompletableFuture getFirmwareRevision() { - return CompletableFuture.completedFuture("none"); + return getCharacteristic(FirmwareRevisionCharacteristic.class).get().getValue(); } @Override public void identify() { - // We're not going to support this for now + try { + getCharacteristic(IdentifyCharacteristic.class).get().setValue(true); + } catch (Exception e) { + // ignore + } } public HomekitTaggedItem getRootAccessory() { @@ -356,6 +429,31 @@ public abstract class AbstractHomekitAccessoryImpl implements HomekitAccessory { } } + /** + * Takes the NameCharacteristic that normally exists on the AccessoryInformationService, + * and puts it on the primary service. + */ + public void promoteNameCharacteristic() { + var characteristic = getCharacteristic(NameCharacteristic.class); + if (!characteristic.isPresent()) { + return; + } + + var service = getPrimaryService(); + if (service != null) { + try { + // find the corresponding add method at service and call it. + service.getClass().getMethod("addOptionalCharacteristic", NameCharacteristic.class).invoke(service, + characteristic.get()); + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + // This should never happen; all services should support NameCharacteristic as an optional + // Characteristic. + // If HAP-Java defined a service that doesn't support addOptionalCharacteristic(NameCharacteristic), + // Then it's a bug there, and we're just going to ignore the exception here. + } + } + } + @NonNullByDefault public Optional getCharacteristic(Class klazz) { return Optional.ofNullable((T) rawCharacteristics.get(klazz)); diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java index 29a8cd44da0..9968d3e4db2 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAccessoryFactory.java @@ -52,7 +52,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import io.github.hapjava.characteristics.Characteristic; -import io.github.hapjava.characteristics.impl.common.NameCharacteristic; /** * Creates a HomekitAccessory for a given HomekitTaggedItem. @@ -211,13 +210,14 @@ public class HomekitAccessoryFactory { taggedItem.getName()); throw new HomekitException("Circular accessory references"); } - ancestorServices.add(taggedItem); accessoryImpl = accessoryImplClass.getConstructor(HomekitTaggedItem.class, List.class, HomekitAccessoryUpdater.class, HomekitSettings.class) .newInstance(taggedItem, foundCharacteristics, updater, settings); addOptionalCharacteristics(taggedItem, accessoryImpl, metadataRegistry); addOptionalMetadataCharacteristics(taggedItem, accessoryImpl); + accessoryImpl.setIsLinkedService(!ancestorServices.isEmpty()); accessoryImpl.init(); + ancestorServices.add(taggedItem); addLinkedServices(taggedItem, accessoryImpl, metadataRegistry, updater, settings, ancestorServices); return accessoryImpl; } else { @@ -467,15 +467,7 @@ public class HomekitAccessoryFactory { final var itemProxy = new HomekitOHItemProxy(groupMember); final var subTaggedItem = new HomekitTaggedItem(itemProxy, accessoryType, itemConfiguration); final var subAccessory = create(subTaggedItem, metadataRegistry, updater, settings, ancestorServices); - - try { - subAccessory.addCharacteristic(new NameCharacteristic(() -> subAccessory.getName())); - } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { - // This should never happen; all services should support NameCharacteristic as an optional - // Characteristic. - // If HAP-Java defined a service that doesn't support addOptionalCharacteristic(NameCharacteristic), - // Then it's a bug there, and we're just going to ignore the exception here. - } + subAccessory.promoteNameCharacteristic(); if (subAccessory.isLinkable(accessory)) { accessory.getPrimaryService().addLinkedService(subAccessory.getPrimaryService()); diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAirQualitySensorImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAirQualitySensorImpl.java index a95817337ba..36607ffd154 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAirQualitySensorImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitAirQualitySensorImpl.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -39,6 +40,11 @@ public class HomekitAirQualitySensorImpl extends AbstractHomekitAccessoryImpl im HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); qualityStateMapping = createMapping(AIR_QUALITY, AirQualityEnum.class); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new AirQualityService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitBasicFanImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitBasicFanImpl.java index 62ae9bbe80f..a8b33ca0f8c 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitBasicFanImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitBasicFanImpl.java @@ -19,6 +19,7 @@ import java.util.concurrent.CompletableFuture; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -39,6 +40,11 @@ class HomekitBasicFanImpl extends AbstractHomekitAccessoryImpl implements BasicF HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); onReader = createBooleanReader(ON_STATE); + } + + @Override + public void init() throws HomekitException { + super.init(); this.getServices().add(new BasicFanService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitBatteryImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitBatteryImpl.java index 7fdf75346df..4c9529fd3ce 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitBatteryImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitBatteryImpl.java @@ -24,6 +24,7 @@ import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.library.types.DecimalType; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -56,6 +57,11 @@ public class HomekitBatteryImpl extends AbstractHomekitAccessoryImpl implements if (isChargeable) { chargingBatteryReader = createBooleanReader(BATTERY_CHARGING_STATE); } + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new BatteryService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCarbonDioxideSensorImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCarbonDioxideSensorImpl.java index 66886a6b6e1..44b18ad4c21 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCarbonDioxideSensorImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCarbonDioxideSensorImpl.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -40,6 +41,11 @@ public class HomekitCarbonDioxideSensorImpl extends AbstractHomekitAccessoryImpl throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); mapping = createMapping(CARBON_DIOXIDE_DETECTED_STATE, CarbonDioxideDetectedEnum.class); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new CarbonDioxideSensorService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCarbonMonoxideSensorImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCarbonMonoxideSensorImpl.java index e97e51113e4..f1235a4c0fe 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCarbonMonoxideSensorImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCarbonMonoxideSensorImpl.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -40,6 +41,11 @@ public class HomekitCarbonMonoxideSensorImpl extends AbstractHomekitAccessoryImp throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); mapping = createMapping(CARBON_MONOXIDE_DETECTED_STATE, CarbonMonoxideDetectedEnum.class); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new CarbonMonoxideSensorService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCharacteristicFactory.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCharacteristicFactory.java index 1fb51259cc2..e4105859a05 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCharacteristicFactory.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitCharacteristicFactory.java @@ -68,6 +68,12 @@ import io.github.hapjava.characteristics.Characteristic; import io.github.hapjava.characteristics.CharacteristicEnum; import io.github.hapjava.characteristics.ExceptionalConsumer; import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; +import io.github.hapjava.characteristics.impl.accessoryinformation.FirmwareRevisionCharacteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.HardwareRevisionCharacteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.IdentifyCharacteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.ManufacturerCharacteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.ModelCharacteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.SerialNumberCharacteristic; import io.github.hapjava.characteristics.impl.airquality.NitrogenDioxideDensityCharacteristic; import io.github.hapjava.characteristics.impl.airquality.OzoneDensityCharacteristic; import io.github.hapjava.characteristics.impl.airquality.PM10DensityCharacteristic; @@ -165,6 +171,11 @@ public class HomekitCharacteristicFactory { private static final Map> OPTIONAL = new HashMap<>() { { put(NAME, HomekitCharacteristicFactory::createNameCharacteristic); + put(MODEL, HomekitCharacteristicFactory::createModelCharacteristic); + put(MANUFACTURER, HomekitCharacteristicFactory::createManufacturerCharacteristic); + put(SERIAL_NUMBER, HomekitCharacteristicFactory::createSerialNumberCharacteristic); + put(FIRMWARE_REVISION, HomekitCharacteristicFactory::createFirmwareRevisionCharacteristic); + put(HARDWARE_REVISION, HomekitCharacteristicFactory::createHardwareRevisionCharacteristic); put(BATTERY_LOW_STATUS, HomekitCharacteristicFactory::createStatusLowBatteryCharacteristic); put(FAULT_STATUS, HomekitCharacteristicFactory::createStatusFaultCharacteristic); put(TAMPERED_STATUS, HomekitCharacteristicFactory::createStatusTamperedCharacteristic); @@ -227,6 +238,7 @@ public class HomekitCharacteristicFactory { put(CURRENT_MEDIA_STATE, HomekitCharacteristicFactory::createCurrentMediaStateCharacteristic); put(TARGET_MEDIA_STATE, HomekitCharacteristicFactory::createTargetMediaStateCharacteristic); put(MUTE, HomekitCharacteristicFactory::createMuteCharacteristic); + put(IDENTIFY, HomekitCharacteristicFactory::createIdentifyCharacteristic); } }; @@ -632,6 +644,46 @@ public class HomekitCharacteristicFactory { }); } + private static ModelCharacteristic createModelCharacteristic(HomekitTaggedItem taggedItem, + HomekitAccessoryUpdater updater) { + return new ModelCharacteristic(() -> { + final State state = taggedItem.getItem().getState(); + return CompletableFuture.completedFuture(state instanceof UnDefType ? "" : state.toString()); + }); + } + + private static ManufacturerCharacteristic createManufacturerCharacteristic(HomekitTaggedItem taggedItem, + HomekitAccessoryUpdater updater) { + return new ManufacturerCharacteristic(() -> { + final State state = taggedItem.getItem().getState(); + return CompletableFuture.completedFuture(state instanceof UnDefType ? "" : state.toString()); + }); + } + + private static SerialNumberCharacteristic createSerialNumberCharacteristic(HomekitTaggedItem taggedItem, + HomekitAccessoryUpdater updater) { + return new SerialNumberCharacteristic(() -> { + final State state = taggedItem.getItem().getState(); + return CompletableFuture.completedFuture(state instanceof UnDefType ? "" : state.toString()); + }); + } + + private static FirmwareRevisionCharacteristic createFirmwareRevisionCharacteristic(HomekitTaggedItem taggedItem, + HomekitAccessoryUpdater updater) { + return new FirmwareRevisionCharacteristic(() -> { + final State state = taggedItem.getItem().getState(); + return CompletableFuture.completedFuture(state instanceof UnDefType ? "" : state.toString()); + }); + } + + private static HardwareRevisionCharacteristic createHardwareRevisionCharacteristic(HomekitTaggedItem taggedItem, + HomekitAccessoryUpdater updater) { + return new HardwareRevisionCharacteristic(() -> { + final State state = taggedItem.getItem().getState(); + return CompletableFuture.completedFuture(state instanceof UnDefType ? "" : state.toString()); + }); + } + private static HoldPositionCharacteristic createHoldPositionCharacteristic(HomekitTaggedItem taggedItem, HomekitAccessoryUpdater updater) { final Item item = taggedItem.getBaseItem(); @@ -1054,7 +1106,7 @@ public class HomekitCharacteristicFactory { private static ResetFilterIndicationCharacteristic createFilterResetCharacteristic(HomekitTaggedItem taggedItem, HomekitAccessoryUpdater updater) { return new ResetFilterIndicationCharacteristic( - (value) -> ((SwitchItem) taggedItem.getItem()).send(OnOffType.ON)); + (value) -> ((SwitchItem) taggedItem.getBaseItem()).send(OnOffType.ON)); } private static ActiveCharacteristic createActiveCharacteristic(HomekitTaggedItem taggedItem, @@ -1216,4 +1268,9 @@ public class HomekitCharacteristicFactory { (value) -> taggedItem.send(OnOffType.from(value)), getSubscriber(taggedItem, MUTE, updater), getUnsubscriber(taggedItem, MUTE, updater)); } + + private static IdentifyCharacteristic createIdentifyCharacteristic(HomekitTaggedItem taggedItem, + HomekitAccessoryUpdater updater) { + return new IdentifyCharacteristic((value) -> ((SwitchItem) taggedItem.getBaseItem()).send(OnOffType.ON)); + } } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitContactSensorImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitContactSensorImpl.java index be6e5955d50..3ff7c9a1916 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitContactSensorImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitContactSensorImpl.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -38,6 +39,11 @@ public class HomekitContactSensorImpl extends AbstractHomekitAccessoryImpl imple HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); mapping = createMapping(CONTACT_SENSOR_STATE, ContactStateEnum.class); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new ContactSensorService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitDoorImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitDoorImpl.java index 507f6d24e5d..021663004ef 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitDoorImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitDoorImpl.java @@ -17,6 +17,7 @@ import java.util.concurrent.CompletableFuture; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -35,6 +36,11 @@ public class HomekitDoorImpl extends AbstractHomekitPositionAccessoryImpl implem public HomekitDoorImpl(HomekitTaggedItem taggedItem, List mandatoryCharacteristics, HomekitAccessoryUpdater updater, HomekitSettings settings) { super(taggedItem, mandatoryCharacteristics, updater, settings); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new DoorService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitFanImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitFanImpl.java index 26a55a7dbd1..8fadfe9d734 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitFanImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitFanImpl.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -37,6 +38,11 @@ class HomekitFanImpl extends AbstractHomekitAccessoryImpl implements FanAccessor HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); activeReader = createBooleanReader(ACTIVE_STATUS); + } + + @Override + public void init() throws HomekitException { + super.init(); this.getServices().add(new FanService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitFaucetImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitFaucetImpl.java index a2ea89e7f43..beeab761801 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitFaucetImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitFaucetImpl.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -37,6 +38,11 @@ class HomekitFaucetImpl extends AbstractHomekitAccessoryImpl implements FaucetAc HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); activeReader = createBooleanReader(ACTIVE); + } + + @Override + public void init() throws HomekitException { + super.init(); this.getServices().add(new FaucetService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitFilterMaintenanceImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitFilterMaintenanceImpl.java index 2b3c7a86591..5918da1dca9 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitFilterMaintenanceImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitFilterMaintenanceImpl.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -39,6 +40,11 @@ public class HomekitFilterMaintenanceImpl extends AbstractHomekitAccessoryImpl i HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); mapping = createMapping(FILTER_CHANGE_INDICATION, FilterChangeIndicationEnum.class); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new FilterMaintenanceService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitGarageDoorOpenerImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitGarageDoorOpenerImpl.java index 19999565e6e..4284cbccd38 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitGarageDoorOpenerImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitGarageDoorOpenerImpl.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; import org.slf4j.Logger; @@ -49,7 +50,11 @@ public class HomekitGarageDoorOpenerImpl extends AbstractHomekitAccessoryImpl im obstructionReader = createBooleanReader(OBSTRUCTION_STATUS); currentDoorStateMapping = createMapping(CURRENT_DOOR_STATE, CurrentDoorStateEnum.class, true); targetDoorStateMapping = createMapping(TARGET_DOOR_STATE, TargetDoorStateEnum.class, true); + } + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new GarageDoorOpenerService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitHeaterCoolerImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitHeaterCoolerImpl.java index 0547b25e109..840e6ed0bd5 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitHeaterCoolerImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitHeaterCoolerImpl.java @@ -28,6 +28,7 @@ import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.OpenClosedType; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; import org.slf4j.Logger; @@ -66,6 +67,11 @@ public class HomekitHeaterCoolerImpl extends AbstractHomekitAccessoryImpl implem customCurrentStateList); targetStateMapping = createMapping(TARGET_HEATER_COOLER_STATE, TargetHeaterCoolerStateEnum.class, customTargetStateList); + } + + @Override + public void init() throws HomekitException { + super.init(); final HeaterCoolerService service = new HeaterCoolerService(this); service.addOptionalCharacteristic(new TemperatureDisplayUnitCharacteristic(this::getTemperatureDisplayUnit, this::setTemperatureDisplayUnit, this::subscribeTemperatureDisplayUnit, diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitHumiditySensorImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitHumiditySensorImpl.java index 2d98158274c..abd24f9bd31 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitHumiditySensorImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitHumiditySensorImpl.java @@ -20,6 +20,7 @@ import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.library.types.DecimalType; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -37,6 +38,11 @@ public class HomekitHumiditySensorImpl extends AbstractHomekitAccessoryImpl impl public HomekitHumiditySensorImpl(HomekitTaggedItem taggedItem, List mandatoryCharacteristics, HomekitAccessoryUpdater updater, HomekitSettings settings) { super(taggedItem, mandatoryCharacteristics, updater, settings); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new HumiditySensorService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitInputSourceImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitInputSourceImpl.java index 5039aa57da1..e3895545c82 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitInputSourceImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitInputSourceImpl.java @@ -26,7 +26,6 @@ import io.github.hapjava.characteristics.impl.common.ConfiguredNameCharacteristi import io.github.hapjava.characteristics.impl.common.IdentifierCharacteristic; import io.github.hapjava.characteristics.impl.common.IsConfiguredCharacteristic; import io.github.hapjava.characteristics.impl.common.IsConfiguredEnum; -import io.github.hapjava.characteristics.impl.common.NameCharacteristic; import io.github.hapjava.characteristics.impl.inputsource.CurrentVisibilityStateCharacteristic; import io.github.hapjava.characteristics.impl.inputsource.CurrentVisibilityStateEnum; import io.github.hapjava.characteristics.impl.inputsource.InputDeviceTypeCharacteristic; @@ -85,7 +84,6 @@ public class HomekitInputSourceImpl extends AbstractHomekitAccessoryImpl { var service = new InputSourceService(configuredNameCharacteristic, inputSourceTypeCharacteristic, isConfiguredCharacteristic, currentVisibilityStateCharacteristic); - getCharacteristic(NameCharacteristic.class).ifPresent(c -> service.addOptionalCharacteristic(c)); service.addOptionalCharacteristic(identifierCharacteristic); getCharacteristic(InputDeviceTypeCharacteristic.class).ifPresent(c -> service.addOptionalCharacteristic(c)); getCharacteristic(TargetVisibilityStateCharacteristic.class) diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitIrrigationSystemImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitIrrigationSystemImpl.java index e505e49883e..efc31cf0e4d 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitIrrigationSystemImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitIrrigationSystemImpl.java @@ -20,6 +20,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.library.types.OnOffType; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -58,7 +59,9 @@ public class HomekitIrrigationSystemImpl extends AbstractHomekitAccessoryImpl im } @Override - public void init() { + public void init() throws HomekitException { + super.init(); + String serviceLabelNamespaceConfig = getAccessoryConfiguration(SERVICE_LABEL, "ARABIC_NUMERALS"); ServiceLabelNamespaceEnum serviceLabelEnum; diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLeakSensorImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLeakSensorImpl.java index 4312840d0ce..577fa9b577f 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLeakSensorImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLeakSensorImpl.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -38,6 +39,11 @@ public class HomekitLeakSensorImpl extends AbstractHomekitAccessoryImpl implemen HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); mapping = createMapping(LEAK_DETECTED_STATE, LeakDetectedStateEnum.class); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new LeakSensorService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLightSensorImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLightSensorImpl.java index d791d9cb8db..491733e78d3 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLightSensorImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLightSensorImpl.java @@ -22,6 +22,7 @@ import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.library.types.DecimalType; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -40,6 +41,11 @@ public class HomekitLightSensorImpl extends AbstractHomekitAccessoryImpl impleme public HomekitLightSensorImpl(HomekitTaggedItem taggedItem, List mandatoryCharacteristics, HomekitAccessoryUpdater updater, HomekitSettings settings) { super(taggedItem, mandatoryCharacteristics, updater, settings); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new LightSensorService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLightbulbImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLightbulbImpl.java index 827f3695090..b769c9c018a 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLightbulbImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLightbulbImpl.java @@ -21,6 +21,7 @@ import org.openhab.core.library.types.OnOffType; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; import org.openhab.io.homekit.internal.HomekitCommandType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -38,7 +39,12 @@ class HomekitLightbulbImpl extends AbstractHomekitAccessoryImpl implements Light public HomekitLightbulbImpl(HomekitTaggedItem taggedItem, List mandatoryCharacteristics, HomekitAccessoryUpdater updater, HomekitSettings settings) { super(taggedItem, mandatoryCharacteristics, updater, settings); - this.getServices().add(new LightbulbService(this)); + } + + @Override + public void init() throws HomekitException { + super.init(); + getServices().add(new LightbulbService(this)); } @Override diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLockImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLockImpl.java index 96c804a26e6..80736a73c21 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLockImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLockImpl.java @@ -18,6 +18,7 @@ import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -43,6 +44,11 @@ public class HomekitLockImpl extends AbstractHomekitAccessoryImpl implements Loc currentStateMapping = createMapping(HomekitCharacteristicType.LOCK_CURRENT_STATE, LockCurrentStateEnum.class); targetStateMapping = createMapping(HomekitCharacteristicType.LOCK_TARGET_STATE, LockTargetStateEnum.class); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new LockMechanismService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitMetadataCharacteristicFactory.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitMetadataCharacteristicFactory.java index ba07a9cc5ef..582c5b9b539 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitMetadataCharacteristicFactory.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitMetadataCharacteristicFactory.java @@ -27,6 +27,11 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.io.homekit.internal.HomekitCharacteristicType; import io.github.hapjava.characteristics.Characteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.FirmwareRevisionCharacteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.HardwareRevisionCharacteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.ManufacturerCharacteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.ModelCharacteristic; +import io.github.hapjava.characteristics.impl.accessoryinformation.SerialNumberCharacteristic; import io.github.hapjava.characteristics.impl.airquality.AirQualityCharacteristic; import io.github.hapjava.characteristics.impl.airquality.AirQualityEnum; import io.github.hapjava.characteristics.impl.common.ActiveCharacteristic; @@ -83,11 +88,16 @@ public class HomekitMetadataCharacteristicFactory { put(CURRENT_HEATING_COOLING_STATE, HomekitMetadataCharacteristicFactory::createCurrentHeatingCoolingStateCharacteristic); put(CURRENT_VISIBILITY, HomekitMetadataCharacteristicFactory::createCurrentVisibilityCharacteristic); + put(FIRMWARE_REVISION, HomekitMetadataCharacteristicFactory::createFirmwareRevisionCharacteristic); + put(HARDWARE_REVISION, HomekitMetadataCharacteristicFactory::createHardwareRevisionCharacteristic); put(IDENTIFIER, HomekitMetadataCharacteristicFactory::createIdentifierCharacteristic); put(INPUT_DEVICE_TYPE, HomekitMetadataCharacteristicFactory::createInputDeviceTypeCharacteristic); put(INPUT_SOURCE_TYPE, HomekitMetadataCharacteristicFactory::createInputSourceTypeCharacteristic); + put(MANUFACTURER, HomekitMetadataCharacteristicFactory::createManufacturerCharacteristic); + put(MODEL, HomekitMetadataCharacteristicFactory::createModelCharacteristic); put(NAME, HomekitMetadataCharacteristicFactory::createNameCharacteristic); put(PICTURE_MODE, HomekitMetadataCharacteristicFactory::createPictureModeCharacteristic); + put(SERIAL_NUMBER, HomekitMetadataCharacteristicFactory::createSerialNumberCharacteristic); put(SERVICE_INDEX, HomekitMetadataCharacteristicFactory::createServiceIndexCharacteristic); put(SLEEP_DISCOVERY_MODE, HomekitMetadataCharacteristicFactory::createSleepDiscoveryModeCharacteristic); put(TARGET_HEATER_COOLER_STATE, @@ -221,6 +231,14 @@ public class HomekitMetadataCharacteristicFactory { }); } + private static Characteristic createFirmwareRevisionCharacteristic(Object value) { + return new FirmwareRevisionCharacteristic(getString(value)); + } + + private static Characteristic createHardwareRevisionCharacteristic(Object value) { + return new HardwareRevisionCharacteristic(getString(value)); + } + private static Characteristic createIdentifierCharacteristic(Object value) { return new IdentifierCharacteristic(getInteger(value)); } @@ -237,6 +255,14 @@ public class HomekitMetadataCharacteristicFactory { }); } + private static Characteristic createManufacturerCharacteristic(Object value) { + return new ManufacturerCharacteristic(getString(value)); + } + + private static Characteristic createModelCharacteristic(Object value) { + return new ModelCharacteristic(getString(value)); + } + private static Characteristic createNameCharacteristic(Object value) { return new NameCharacteristic(getString(value)); } @@ -248,6 +274,10 @@ public class HomekitMetadataCharacteristicFactory { }); } + private static Characteristic createSerialNumberCharacteristic(Object value) { + return new SerialNumberCharacteristic(getString(value)); + } + private static Characteristic createServiceIndexCharacteristic(Object value) { return new ServiceLabelIndexCharacteristic(getInteger(value)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitMicrophoneImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitMicrophoneImpl.java index 35f69ae286f..81c9ce05dab 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitMicrophoneImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitMicrophoneImpl.java @@ -17,6 +17,7 @@ import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -36,6 +37,11 @@ public class HomekitMicrophoneImpl extends AbstractHomekitAccessoryImpl implemen HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); muteReader = createBooleanReader(HomekitCharacteristicType.MUTE); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new MicrophoneService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitMotionSensorImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitMotionSensorImpl.java index 099944b65b0..174bb81866a 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitMotionSensorImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitMotionSensorImpl.java @@ -17,6 +17,7 @@ import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -35,6 +36,11 @@ public class HomekitMotionSensorImpl extends AbstractHomekitAccessoryImpl implem HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); motionSensedReader = createBooleanReader(HomekitCharacteristicType.MOTION_DETECTED_STATE); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new MotionSensorService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitOccupancySensorImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitOccupancySensorImpl.java index 0db4c347fec..59d3aebbcbb 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitOccupancySensorImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitOccupancySensorImpl.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -38,6 +39,11 @@ public class HomekitOccupancySensorImpl extends AbstractHomekitAccessoryImpl imp HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); mapping = createMapping(OCCUPANCY_DETECTED_STATE, OccupancyDetectedEnum.class); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new OccupancySensorService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitOutletImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitOutletImpl.java index cf61a3f47fb..b7d32a3b014 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitOutletImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitOutletImpl.java @@ -17,6 +17,7 @@ import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -37,6 +38,11 @@ public class HomekitOutletImpl extends AbstractHomekitAccessoryImpl implements O super(taggedItem, mandatoryCharacteristics, updater, settings); inUseReader = createBooleanReader(HomekitCharacteristicType.INUSE_STATUS); onReader = createBooleanReader(HomekitCharacteristicType.ON_STATE); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new OutletService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSecuritySystemImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSecuritySystemImpl.java index 5c5ebd4cdc7..7b21582cdea 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSecuritySystemImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSecuritySystemImpl.java @@ -22,6 +22,7 @@ import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -53,6 +54,11 @@ public class HomekitSecuritySystemImpl extends AbstractHomekitAccessoryImpl impl customCurrentStateList); targetStateMapping = createMapping(SECURITY_SYSTEM_TARGET_STATE, TargetSecuritySystemStateEnum.class, customTargetStateList); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new SecuritySystemService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSlatImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSlatImpl.java index 540c2a36544..f39a17b2c59 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSlatImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSlatImpl.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -43,6 +44,11 @@ public class HomekitSlatImpl extends AbstractHomekitAccessoryImpl implements Sla final String slatTypeConfig = getAccessoryConfiguration(CONFIG_TYPE, "horizontal"); slatType = "horizontal".equalsIgnoreCase(slatTypeConfig) ? SlatTypeEnum.HORIZONTAL : SlatTypeEnum.VERTICAL; currentSlatStateMapping = createMapping(CURRENT_SLAT_STATE, CurrentSlatStateEnum.class); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new SlatService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSmartSpeakerImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSmartSpeakerImpl.java index e236863d971..ae1704f099b 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSmartSpeakerImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSmartSpeakerImpl.java @@ -20,6 +20,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -42,6 +43,11 @@ public class HomekitSmartSpeakerImpl extends AbstractHomekitAccessoryImpl implem super(taggedItem, mandatoryCharacteristics, updater, settings); currentMediaState = createMapping(CURRENT_MEDIA_STATE, CurrentMediaStateEnum.class); targetMediaState = createMapping(TARGET_MEDIA_STATE, TargetMediaStateEnum.class); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new SmartSpeakerService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSmokeSensorImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSmokeSensorImpl.java index 2d124ec52f2..bf4a0661c0a 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSmokeSensorImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSmokeSensorImpl.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -38,6 +39,11 @@ public class HomekitSmokeSensorImpl extends AbstractHomekitAccessoryImpl impleme HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); mapping = createMapping(SMOKE_DETECTED_STATE, SmokeDetectedStateEnum.class); + } + + @Override + public void init() throws HomekitException { + super.init(); this.getServices().add(new SmokeSensorService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSpeakerImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSpeakerImpl.java index f0447f14793..98732de9016 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSpeakerImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSpeakerImpl.java @@ -17,6 +17,7 @@ import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -36,6 +37,11 @@ public class HomekitSpeakerImpl extends AbstractHomekitAccessoryImpl implements HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); muteReader = createBooleanReader(HomekitCharacteristicType.MUTE); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new SpeakerService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSwitchImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSwitchImpl.java index e5cd2df1b84..9e7ab5d157f 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSwitchImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitSwitchImpl.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -37,6 +38,11 @@ public class HomekitSwitchImpl extends AbstractHomekitAccessoryImpl implements S HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException { super(taggedItem, mandatoryCharacteristics, updater, settings); onReader = createBooleanReader(ON_STATE); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new SwitchService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitTelevisionImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitTelevisionImpl.java index ffa800b9bb4..10ce819421d 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitTelevisionImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitTelevisionImpl.java @@ -24,7 +24,6 @@ import org.openhab.io.homekit.internal.HomekitTaggedItem; import io.github.hapjava.characteristics.impl.common.ActiveCharacteristic; import io.github.hapjava.characteristics.impl.common.ActiveIdentifierCharacteristic; import io.github.hapjava.characteristics.impl.common.ConfiguredNameCharacteristic; -import io.github.hapjava.characteristics.impl.common.NameCharacteristic; import io.github.hapjava.characteristics.impl.lightbulb.BrightnessCharacteristic; import io.github.hapjava.characteristics.impl.television.ClosedCaptionsCharacteristic; import io.github.hapjava.characteristics.impl.television.CurrentMediaStateCharacteristic; @@ -82,7 +81,6 @@ public class HomekitTelevisionImpl extends AbstractHomekitAccessoryImpl { activeIdentifierCharacteristic, configuredNameCharacteristic, remoteKeyCharacteristic, sleepDiscoveryModeCharacteristic); - getCharacteristic(NameCharacteristic.class).ifPresent(c -> service.addOptionalCharacteristic(c)); getCharacteristic(BrightnessCharacteristic.class).ifPresent(c -> service.addOptionalCharacteristic(c)); getCharacteristic(PowerModeCharacteristic.class).ifPresent(c -> service.addOptionalCharacteristic(c)); getCharacteristic(ClosedCaptionsCharacteristic.class).ifPresent(c -> service.addOptionalCharacteristic(c)); diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitTemperatureSensorImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitTemperatureSensorImpl.java index b538b7d27a7..bf024b57e2b 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitTemperatureSensorImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitTemperatureSensorImpl.java @@ -19,6 +19,7 @@ import java.util.concurrent.CompletableFuture; import org.eclipse.jdt.annotation.Nullable; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -38,6 +39,11 @@ class HomekitTemperatureSensorImpl extends AbstractHomekitAccessoryImpl implemen public HomekitTemperatureSensorImpl(HomekitTaggedItem taggedItem, List mandatoryCharacteristics, HomekitAccessoryUpdater updater, HomekitSettings settings) { super(taggedItem, mandatoryCharacteristics, updater, settings); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new TemperatureSensorService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitThermostatImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitThermostatImpl.java index a3ce62e77c7..c851570316e 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitThermostatImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitThermostatImpl.java @@ -26,6 +26,7 @@ import org.openhab.core.library.items.NumberItem; import org.openhab.core.library.types.DecimalType; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; import org.slf4j.Logger; @@ -67,6 +68,11 @@ class HomekitThermostatImpl extends AbstractHomekitAccessoryImpl implements Ther CurrentHeatingCoolingStateEnum.class, customCurrentHeatingCoolingStateList); targetHeatingCoolingStateMapping = createMapping(TARGET_HEATING_COOLING_STATE, TargetHeatingCoolingStateEnum.class, customTargetHeatingCoolingStateList); + } + + @Override + public void init() throws HomekitException { + super.init(); this.getServices().add(new ThermostatService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitValveImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitValveImpl.java index f3a0141a188..479f9a12961 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitValveImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitValveImpl.java @@ -33,6 +33,7 @@ import org.openhab.core.library.types.OnOffType; import org.openhab.core.types.RefreshType; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; import org.openhab.io.homekit.internal.HomekitCharacteristicType; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; import org.slf4j.Logger; @@ -79,11 +80,16 @@ public class HomekitValveImpl extends AbstractHomekitAccessoryImpl implements Va super(taggedItem, mandatoryCharacteristics, updater, settings); inUseReader = createBooleanReader(INUSE_STATUS); activeReader = createBooleanReader(ACTIVE_STATUS); + homekitTimer = getAccessoryConfigurationAsBoolean(CONFIG_TIMER, false); + } + + @Override + public void init() throws HomekitException { + super.init(); ValveService service = new ValveService(this); getServices().add(service); - homekitTimer = getAccessoryConfigurationAsBoolean(CONFIG_TIMER, false); if (homekitTimer) { - addRemainingDurationCharacteristic(taggedItem, updater, service); + addRemainingDurationCharacteristic(getRootAccessory(), getUpdater(), service); } String valveTypeConfig = getAccessoryConfiguration(CONFIG_VALVE_TYPE, "GENERIC"); valveTypeConfig = getAccessoryConfiguration(CONFIG_VALVE_TYPE_DEPRECATED, valveTypeConfig); diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitWindowCoveringImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitWindowCoveringImpl.java index 622a6bb3d9d..dfe1b6ac519 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitWindowCoveringImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitWindowCoveringImpl.java @@ -17,6 +17,7 @@ import java.util.concurrent.CompletableFuture; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -35,6 +36,11 @@ public class HomekitWindowCoveringImpl extends AbstractHomekitPositionAccessoryI public HomekitWindowCoveringImpl(HomekitTaggedItem taggedItem, List mandatoryCharacteristics, HomekitAccessoryUpdater updater, HomekitSettings settings) { super(taggedItem, mandatoryCharacteristics, updater, settings); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new WindowCoveringService(this)); } diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitWindowImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitWindowImpl.java index 42abdd7ea06..21bf0e44e7e 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitWindowImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitWindowImpl.java @@ -17,6 +17,7 @@ import java.util.concurrent.CompletableFuture; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.io.homekit.internal.HomekitAccessoryUpdater; +import org.openhab.io.homekit.internal.HomekitException; import org.openhab.io.homekit.internal.HomekitSettings; import org.openhab.io.homekit.internal.HomekitTaggedItem; @@ -35,6 +36,11 @@ public class HomekitWindowImpl extends AbstractHomekitPositionAccessoryImpl impl public HomekitWindowImpl(HomekitTaggedItem taggedItem, List mandatoryCharacteristics, HomekitAccessoryUpdater updater, HomekitSettings settings) { super(taggedItem, mandatoryCharacteristics, updater, settings); + } + + @Override + public void init() throws HomekitException { + super.init(); getServices().add(new WindowService(this)); }