├── .github └── workflows │ ├── deploy.yml │ ├── maven.yml │ └── release.yml ├── .gitignore ├── .travis.yml ├── CHANGES.md ├── LICENSE ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── RELEASING.md ├── pom.xml └── src ├── main └── java │ └── io │ └── github │ └── hapjava │ ├── accessories │ ├── AirPurifierAccessory.java │ ├── AirQualityAccessory.java │ ├── BasicFanAccessory.java │ ├── BatteryAccessory.java │ ├── Bridge.java │ ├── CarbonDioxideSensorAccessory.java │ ├── CarbonMonoxideSensorAccessory.java │ ├── ContactSensorAccessory.java │ ├── DoorAccessory.java │ ├── DoorbellAccessory.java │ ├── FanAccessory.java │ ├── FaucetAccessory.java │ ├── FilterMaintenanceAccessory.java │ ├── GarageDoorOpenerAccessory.java │ ├── HeaterCoolerAccessory.java │ ├── HomekitAccessory.java │ ├── HumidifierDehumidifierAccessory.java │ ├── HumiditySensorAccessory.java │ ├── InputSourceAccessory.java │ ├── IrrigationSystemAccessory.java │ ├── LeakSensorAccessory.java │ ├── LightSensorAccessory.java │ ├── LightbulbAccessory.java │ ├── LockMechanismAccessory.java │ ├── MicrophoneAccessory.java │ ├── MotionSensorAccessory.java │ ├── OccupancySensorAccessory.java │ ├── OutletAccessory.java │ ├── SecuritySystemAccessory.java │ ├── SlatAccessory.java │ ├── SmartSpeakerAccessory.java │ ├── SmokeSensorAccessory.java │ ├── SpeakerAccessory.java │ ├── StatelessProgrammableSwitchAccessory.java │ ├── SwitchAccessory.java │ ├── TelevisionAccessory.java │ ├── TelevisionSpeakerAccessory.java │ ├── TemperatureSensorAccessory.java │ ├── ThermostatAccessory.java │ ├── ValveAccessory.java │ ├── WindowAccessory.java │ ├── WindowCoveringAccessory.java │ ├── optionalcharacteristic │ │ ├── AccessoryWithAccessoryFlags.java │ │ ├── AccessoryWithActive.java │ │ ├── AccessoryWithAirPlayEnable.java │ │ ├── AccessoryWithBrightness.java │ │ ├── AccessoryWithCarbonDioxideLevel.java │ │ ├── AccessoryWithCarbonMonoxideLevel.java │ │ ├── AccessoryWithClosedCaptions.java │ │ ├── AccessoryWithColor.java │ │ ├── AccessoryWithColorTemperature.java │ │ ├── AccessoryWithConfiguredName.java │ │ ├── AccessoryWithCoolingThresholdTemperature.java │ │ ├── AccessoryWithCurrentHorizontalTilting.java │ │ ├── AccessoryWithCurrentMediaState.java │ │ ├── AccessoryWithCurrentRelativeHumidity.java │ │ ├── AccessoryWithCurrentTilting.java │ │ ├── AccessoryWithCurrentVerticalTilting.java │ │ ├── AccessoryWithDuration.java │ │ ├── AccessoryWithFanState.java │ │ ├── AccessoryWithFilterLifeLevel.java │ │ ├── AccessoryWithHardwareRevision.java │ │ ├── AccessoryWithHeatingThresholdTemperature.java │ │ ├── AccessoryWithHoldPosition.java │ │ ├── AccessoryWithHumidityDehumidifierThreshold.java │ │ ├── AccessoryWithHumidityHumidifierThreshold.java │ │ ├── AccessoryWithIdentifier.java │ │ ├── AccessoryWithInputDeviceType.java │ │ ├── AccessoryWithIsConfigured.java │ │ ├── AccessoryWithLockCurrentState.java │ │ ├── AccessoryWithLockTargetState.java │ │ ├── AccessoryWithMute.java │ │ ├── AccessoryWithName.java │ │ ├── AccessoryWithNitrogenDioxideDensity.java │ │ ├── AccessoryWithObstructionDetection.java │ │ ├── AccessoryWithOzoneDensity.java │ │ ├── AccessoryWithPM10Density.java │ │ ├── AccessoryWithPM25Density.java │ │ ├── AccessoryWithPhysicalControlsLock.java │ │ ├── AccessoryWithPictureMode.java │ │ ├── AccessoryWithPowerMode.java │ │ ├── AccessoryWithRemainingDuration.java │ │ ├── AccessoryWithResetFilterIndication.java │ │ ├── AccessoryWithRotationDirection.java │ │ ├── AccessoryWithRotationSpeed.java │ │ ├── AccessoryWithSecurityAlarmType.java │ │ ├── AccessoryWithServiceLabelIndex.java │ │ ├── AccessoryWithStatusActive.java │ │ ├── AccessoryWithStatusFault.java │ │ ├── AccessoryWithStatusLowBattery.java │ │ ├── AccessoryWithStatusTampered.java │ │ ├── AccessoryWithSulphurDioxideDensity.java │ │ ├── AccessoryWithSwingMode.java │ │ ├── AccessoryWithTargetHorizontalTilting.java │ │ ├── AccessoryWithTargetMediaState.java │ │ ├── AccessoryWithTargetRelativeHumidity.java │ │ ├── AccessoryWithTargetTilting.java │ │ ├── AccessoryWithTargetVerticalTilting.java │ │ ├── AccessoryWithTargetVisibilityState.java │ │ ├── AccessoryWithTemperatureDisplayUnits.java │ │ ├── AccessoryWithVOCDensity.java │ │ ├── AccessoryWithVerticalTilting.java │ │ ├── AccessoryWithVolume.java │ │ ├── AccessoryWithVolumeControlType.java │ │ ├── AccessoryWithVolumeSelector.java │ │ └── AccessoryWithWaterLevel.java │ └── package-info.java │ ├── characteristics │ ├── Characteristic.java │ ├── CharacteristicEnum.java │ ├── EventableCharacteristic.java │ ├── ExceptionalConsumer.java │ ├── HomekitCharacteristicChangeCallback.java │ ├── impl │ │ ├── accessoryinformation │ │ │ ├── AccessoryFlagsCharacteristic.java │ │ │ ├── AccessoryFlagsEnum.java │ │ │ ├── FirmwareRevisionCharacteristic.java │ │ │ ├── HardwareRevisionCharacteristic.java │ │ │ ├── IdentifyCharacteristic.java │ │ │ ├── ManufacturerCharacteristic.java │ │ │ ├── ModelCharacteristic.java │ │ │ └── SerialNumberCharacteristic.java │ │ ├── airpurifier │ │ │ ├── CurrentAirPurifierCharacteristic.java │ │ │ ├── CurrentAirPurifierStateEnum.java │ │ │ ├── TargetAirPurifierStateCharacteristic.java │ │ │ └── TargetAirPurifierStateEnum.java │ │ ├── airquality │ │ │ ├── AirQualityCharacteristic.java │ │ │ ├── AirQualityEnum.java │ │ │ ├── NitrogenDioxideDensityCharacteristic.java │ │ │ ├── OzoneDensityCharacteristic.java │ │ │ ├── PM10DensityCharacteristic.java │ │ │ ├── PM25DensityCharacteristic.java │ │ │ ├── SulphurDioxideDensityCharacteristic.java │ │ │ └── VOCDensityCharacteristic.java │ │ ├── audio │ │ │ ├── MuteCharacteristic.java │ │ │ └── VolumeCharacteristic.java │ │ ├── base │ │ │ ├── BaseCharacteristic.java │ │ │ ├── BooleanCharacteristic.java │ │ │ ├── EnumCharacteristic.java │ │ │ ├── FloatCharacteristic.java │ │ │ ├── IntegerCharacteristic.java │ │ │ ├── StaticStringCharacteristic.java │ │ │ └── StringCharacteristic.java │ │ ├── battery │ │ │ ├── BatteryLevelCharacteristic.java │ │ │ ├── ChargingStateCharacteristic.java │ │ │ ├── ChargingStateEnum.java │ │ │ ├── StatusLowBatteryCharacteristic.java │ │ │ └── StatusLowBatteryEnum.java │ │ ├── carbondioxidesensor │ │ │ ├── CarbonDioxideDetectedCharacteristic.java │ │ │ ├── CarbonDioxideDetectedEnum.java │ │ │ ├── CarbonDioxideLevelCharacteristic.java │ │ │ └── CarbonDioxidePeakLevelCharacteristic.java │ │ ├── carbonmonoxidesensor │ │ │ ├── CarbonMonoxideDetectedCharacteristic.java │ │ │ ├── CarbonMonoxideDetectedEnum.java │ │ │ ├── CarbonMonoxideLevelCharacteristic.java │ │ │ └── CarbonMonoxidePeakLevelCharacteristic.java │ │ ├── common │ │ │ ├── ActiveCharacteristic.java │ │ │ ├── ActiveEnum.java │ │ │ ├── ActiveIdentifierCharacteristic.java │ │ │ ├── AirPlayEnableCharacteristic.java │ │ │ ├── ConfiguredNameCharacteristic.java │ │ │ ├── IdentifierCharacteristic.java │ │ │ ├── InUseCharacteristic.java │ │ │ ├── InUseEnum.java │ │ │ ├── IsConfiguredCharacteristic.java │ │ │ ├── IsConfiguredEnum.java │ │ │ ├── NameCharacteristic.java │ │ │ ├── ObstructionDetectedCharacteristic.java │ │ │ ├── OnCharacteristic.java │ │ │ ├── ProgramModeCharacteristic.java │ │ │ ├── ProgramModeEnum.java │ │ │ ├── ProgrammableSwitchEnum.java │ │ │ ├── ProgrammableSwitchEventCharacteristic.java │ │ │ ├── ServiceLabelIndexCharacteristic.java │ │ │ ├── ServiceLabelNamespaceCharacteristic.java │ │ │ ├── ServiceLabelNamespaceEnum.java │ │ │ ├── StatusActiveCharacteristic.java │ │ │ ├── StatusFaultCharacteristic.java │ │ │ ├── StatusFaultEnum.java │ │ │ ├── StatusTamperedCharacteristic.java │ │ │ ├── StatusTamperedEnum.java │ │ │ ├── VersionCharacteristic.java │ │ │ └── WaterLavelCharacteristic.java │ │ ├── contactsensor │ │ │ ├── ContactSensorStateCharacteristic.java │ │ │ └── ContactStateEnum.java │ │ ├── fan │ │ │ ├── CurrentFanStateCharacteristic.java │ │ │ ├── CurrentFanStateEnum.java │ │ │ ├── LockPhysicalControlsCharacteristic.java │ │ │ ├── LockPhysicalControlsEnum.java │ │ │ ├── RotationDirectionCharacteristic.java │ │ │ ├── RotationDirectionEnum.java │ │ │ ├── RotationSpeedCharacteristic.java │ │ │ ├── SwingModeCharacteristic.java │ │ │ ├── SwingModeEnum.java │ │ │ ├── TargetFanStateCharacteristic.java │ │ │ └── TargetFanStateEnum.java │ │ ├── filtermaintenance │ │ │ ├── FilterChangeIndicationCharacteristic.java │ │ │ ├── FilterChangeIndicationEnum.java │ │ │ ├── FilterLifeLevelCharacteristic.java │ │ │ └── ResetFilterIndicationCharacteristic.java │ │ ├── garagedoor │ │ │ ├── CurrentDoorStateCharacteristic.java │ │ │ ├── CurrentDoorStateEnum.java │ │ │ ├── TargetDoorStateCharacteristic.java │ │ │ └── TargetDoorStateEnum.java │ │ ├── heatercooler │ │ │ ├── CurrentHeaterCoolerStateCharacteristic.java │ │ │ ├── CurrentHeaterCoolerStateEnum.java │ │ │ ├── TargetHeaterCoolerStateCharacteristic.java │ │ │ └── TargetHeaterCoolerStateEnum.java │ │ ├── humidifier │ │ │ ├── CurrentHumidifierDehumidifierStateCharacteristic.java │ │ │ ├── CurrentHumidifierDehumidifierStateEnum.java │ │ │ ├── HumidityDehumidifierThresholdCharacteristic.java │ │ │ ├── HumidityHumidifierThresholdCharacteristic.java │ │ │ ├── TargetHumidifierDehumidifierStateCharacteristic.java │ │ │ └── TargetHumidifierDehumidifierStateEnum.java │ │ ├── humiditysensor │ │ │ ├── CurrentRelativeHumidityCharacteristic.java │ │ │ └── TargetRelativeHumidityCharacteristic.java │ │ ├── inputsource │ │ │ ├── CurrentVisibilityStateCharacteristic.java │ │ │ ├── CurrentVisibilityStateEnum.java │ │ │ ├── InputDeviceTypeCharacteristic.java │ │ │ ├── InputDeviceTypeEnum.java │ │ │ ├── InputSourceTypeCharacteristic.java │ │ │ ├── InputSourceTypeEnum.java │ │ │ ├── TargetVisibilityStateCharacteristic.java │ │ │ └── TargetVisibilityStateEnum.java │ │ ├── leaksensor │ │ │ ├── LeakDetectedStateCharacteristic.java │ │ │ └── LeakDetectedStateEnum.java │ │ ├── lightbulb │ │ │ ├── BrightnessCharacteristic.java │ │ │ ├── ColorTemperatureCharacteristic.java │ │ │ ├── HueCharacteristic.java │ │ │ └── SaturationCharacteristic.java │ │ ├── lightsensor │ │ │ └── CurrentAmbientLightLevelCharacteristic.java │ │ ├── lock │ │ │ ├── LockCurrentStateCharacteristic.java │ │ │ ├── LockCurrentStateEnum.java │ │ │ ├── LockTargetStateCharacteristic.java │ │ │ └── LockTargetStateEnum.java │ │ ├── motionsensor │ │ │ └── MotionDetectedCharacteristic.java │ │ ├── occupancysensor │ │ │ ├── OccupancyDetectedCharacteristic.java │ │ │ └── OccupancyDetectedEnum.java │ │ ├── outlet │ │ │ └── OutletInUseCharacteristic.java │ │ ├── securitysystem │ │ │ ├── CurrentSecuritySystemStateCharacteristic.java │ │ │ ├── CurrentSecuritySystemStateEnum.java │ │ │ ├── SecuritySystemAlarmTypeCharacteristic.java │ │ │ ├── SecuritySystemAlarmTypeEnum.java │ │ │ ├── TargetSecuritySystemStateCharacteristic.java │ │ │ └── TargetSecuritySystemStateEnum.java │ │ ├── slat │ │ │ ├── CurrentSlatStateCharacteristic.java │ │ │ ├── CurrentSlatStateEnum.java │ │ │ ├── CurrentTiltAngleCharacteristic.java │ │ │ ├── SlatTypeCharacteristic.java │ │ │ ├── SlatTypeEnum.java │ │ │ └── TargetTiltAngleCharacteristic.java │ │ ├── smokesensor │ │ │ ├── SmokeDetectedCharacteristic.java │ │ │ └── SmokeDetectedStateEnum.java │ │ ├── television │ │ │ ├── ClosedCaptionsCharacteristic.java │ │ │ ├── ClosedCaptionsEnum.java │ │ │ ├── CurrentMediaStateCharacteristic.java │ │ │ ├── CurrentMediaStateEnum.java │ │ │ ├── PictureModeCharacteristic.java │ │ │ ├── PictureModeEnum.java │ │ │ ├── PowerModeCharacteristic.java │ │ │ ├── PowerModeEnum.java │ │ │ ├── RemoteKeyCharacteristic.java │ │ │ ├── RemoteKeyEnum.java │ │ │ ├── SleepDiscoveryModeCharacteristic.java │ │ │ ├── SleepDiscoveryModeEnum.java │ │ │ ├── TargetMediaStateCharacteristic.java │ │ │ └── TargetMediaStateEnum.java │ │ ├── televisionspeaker │ │ │ ├── VolumeControlTypeCharacteristic.java │ │ │ ├── VolumeControlTypeEnum.java │ │ │ ├── VolumeSelectorCharacteristic.java │ │ │ └── VolumeSelectorEnum.java │ │ ├── thermostat │ │ │ ├── CoolingThresholdTemperatureCharacteristic.java │ │ │ ├── CurrentHeatingCoolingStateCharacteristic.java │ │ │ ├── CurrentHeatingCoolingStateEnum.java │ │ │ ├── CurrentTemperatureCharacteristic.java │ │ │ ├── HeatingThresholdTemperatureCharacteristic.java │ │ │ ├── TargetHeatingCoolingStateCharacteristic.java │ │ │ ├── TargetHeatingCoolingStateEnum.java │ │ │ ├── TargetTemperatureCharacteristic.java │ │ │ ├── TemperatureDisplayUnitCharacteristic.java │ │ │ └── TemperatureDisplayUnitEnum.java │ │ ├── valve │ │ │ ├── RemainingDurationCharacteristic.java │ │ │ ├── SetDurationCharacteristic.java │ │ │ ├── ValveTypeCharacteristic.java │ │ │ └── ValveTypeEnum.java │ │ └── windowcovering │ │ │ ├── CurrentHorizontalTiltAngleCharacteristic.java │ │ │ ├── CurrentPositionCharacteristic.java │ │ │ ├── CurrentVerticalTiltAngleCharacteristic.java │ │ │ ├── HoldPositionCharacteristic.java │ │ │ ├── PositionStateCharacteristic.java │ │ │ ├── PositionStateEnum.java │ │ │ ├── TargetHorizontalTiltAngleCharacteristic.java │ │ │ ├── TargetPositionCharacteristic.java │ │ │ └── TargetVerticalTiltAngleCharacteristic.java │ └── package-info.java │ ├── server │ ├── HomekitAccessoryCategories.java │ ├── HomekitAuthInfo.java │ ├── HomekitWebHandler.java │ └── impl │ │ ├── HomekitBridge.java │ │ ├── HomekitRegistry.java │ │ ├── HomekitRoot.java │ │ ├── HomekitServer.java │ │ ├── HomekitStandaloneAccessoryServer.java │ │ ├── HomekitUtils.java │ │ ├── connections │ │ ├── ConnectionImpl.java │ │ ├── HomekitClientConnectionFactoryImpl.java │ │ ├── HttpSession.java │ │ ├── LengthPrefixedByteArrayProcessor.java │ │ ├── PendingNotification.java │ │ └── SubscriptionManager.java │ │ ├── crypto │ │ ├── ChachaDecoder.java │ │ ├── ChachaEncoder.java │ │ ├── EdsaSigner.java │ │ ├── EdsaVerifier.java │ │ ├── HAPSetupCodeUtils.java │ │ └── PolyKeyCreator.java │ │ ├── http │ │ ├── HomekitClientConnection.java │ │ ├── HomekitClientConnectionFactory.java │ │ ├── HttpMethod.java │ │ ├── HttpRequest.java │ │ ├── HttpResponse.java │ │ └── impl │ │ │ ├── AccessoryHandler.java │ │ │ ├── BinaryHandler.java │ │ │ ├── DefaultHttpRequestImpl.java │ │ │ ├── FullRequestHttpRequestImpl.java │ │ │ ├── HomekitHttpServer.java │ │ │ ├── HttpResponseEncoderAggregate.java │ │ │ ├── LoggingHandler.java │ │ │ ├── NettyHomekitHttpService.java │ │ │ ├── NettyResponseUtil.java │ │ │ └── ServerInitializer.java │ │ ├── jmdns │ │ └── JmdnsHomekitAdvertiser.java │ │ ├── json │ │ ├── AccessoryController.java │ │ ├── CharacteristicsController.java │ │ ├── EventController.java │ │ ├── EventResponse.java │ │ ├── HapJsonNoContentResponse.java │ │ └── HapJsonResponse.java │ │ ├── pairing │ │ ├── ByteUtils.java │ │ ├── ClientEvidenceRoutineImpl.java │ │ ├── ErrorCode.java │ │ ├── ExchangeHandler.java │ │ ├── HomekitSRP6Routines.java │ │ ├── HomekitSRP6ServerSession.java │ │ ├── MessageType.java │ │ ├── PairSetupManager.java │ │ ├── PairSetupRequest.java │ │ ├── PairVerifyManager.java │ │ ├── PairVerifyRequest.java │ │ ├── PairingMethod.java │ │ ├── PairingResponse.java │ │ ├── PairingsManager.java │ │ ├── ServerEvidenceRoutineImpl.java │ │ ├── SrpHandler.java │ │ ├── TypeLengthValueUtils.java │ │ └── UpgradeResponse.java │ │ └── responses │ │ ├── ConflictResponse.java │ │ ├── InternalServerErrorResponse.java │ │ ├── NotFoundResponse.java │ │ ├── OkResponse.java │ │ └── UnauthorizedResponse.java │ └── services │ ├── Service.java │ └── impl │ ├── AbstractServiceImpl.java │ ├── AccessoryInformationService.java │ ├── AirPurifierService.java │ ├── AirQualityService.java │ ├── BasicFanService.java │ ├── BatteryService.java │ ├── CarbonDioxideSensorService.java │ ├── CarbonMonoxideSensorService.java │ ├── ContactSensorService.java │ ├── DoorService.java │ ├── DoorbellService.java │ ├── FanService.java │ ├── FaucetService.java │ ├── FilterMaintenanceService.java │ ├── GarageDoorOpenerService.java │ ├── HAPProtocolInformationService.java │ ├── HeaterCoolerService.java │ ├── HumidifierDehumidifierService.java │ ├── HumiditySensorService.java │ ├── InputSourceService.java │ ├── IrrigationSystemService.java │ ├── LeakSensorService.java │ ├── LightSensorService.java │ ├── LightbulbService.java │ ├── LockMechanismService.java │ ├── MicrophoneService.java │ ├── MotionSensorService.java │ ├── OccupancySensorService.java │ ├── OutletService.java │ ├── SecuritySystemService.java │ ├── ServiceLabelService.java │ ├── SlatService.java │ ├── SmartSpeakerService.java │ ├── SmokeSensorService.java │ ├── SpeakerService.java │ ├── StatelessProgrammableSwitchService.java │ ├── SwitchService.java │ ├── TelevisionService.java │ ├── TelevisionSpeakerService.java │ ├── TemperatureSensorService.java │ ├── ThermostatService.java │ ├── ValveService.java │ ├── WindowCoveringService.java │ └── WindowService.java └── test └── java └── io └── github └── hapjava └── server └── impl ├── HomekitRootTest.java └── jmdns └── JmdnsHomekitAdvertiserTest.java /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: Java CI with Maven 5 | 6 | on: 7 | pull_request: 8 | branches: [ master ] 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v3 17 | - name: Set up JDK 11 18 | uses: actions/setup-java@v3 19 | with: 20 | distribution: 'zulu' 21 | java-version: '11' 22 | architecture: x64 23 | - name: Build with Maven 24 | run: mvn -B package --file pom.xml 25 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: Stage Release on Master Branch 5 | 6 | on: 7 | workflow_dispatch: 8 | inputs: 9 | releaseVersion: 10 | description: Version to release 11 | required: true 12 | 13 | permissions: 14 | contents: write 15 | 16 | jobs: 17 | build: 18 | 19 | runs-on: ubuntu-latest 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | - uses: git-actions/set-user@v1 24 | - name: Set up JDK 11 25 | uses: actions/setup-java@v3 26 | with: 27 | distribution: 'zulu' 28 | java-version: '11' 29 | architecture: x64 30 | server-id: ossrh 31 | gpg-private-key: ${{ secrets.GPG_SECRET_KEY }} 32 | gpg-passphrase: MAVEN_GPG_PASSPHRASE 33 | server-username: MAVEN_USERNAME 34 | server-password: MAVEN_CENTRAL_TOKEN 35 | - name: Maven release 36 | run: mvn release:prepare release:perform -B -DreleaseVersion=${{ github.event.inputs.releaseVersion }} -Possrh 37 | env: 38 | MAVEN_USERNAME: hap-java-dev 39 | MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} 40 | MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | 14 | # Eclipse files 15 | .classpath 16 | .project 17 | .settings/ 18 | 19 | # Maven target folder 20 | target/ 21 | 22 | # Mac Files 23 | .DS_Store 24 | 25 | # IntelliJ 26 | **/.idea/ 27 | **/*.iml 28 | 29 | # Log files 30 | *.log 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Andy Lintner 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Pull Request Checklist 2 | 3 | Please confirm that you've done the following when opening a new pull request: 4 | 5 | - [ ] For fixes and other improvements, please reference the GitHub issue that your change addresses. 6 | - [ ] For fixes, optimizations and new features, please add an entry to the CHANGES.md file. 7 | - [ ] Run mvn compile before committing, so that the auto-code formatter will format your changes consistently with the rest of the project. 8 | 9 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | # How to release HAP-Java 2 | 3 | These actions can only be performed by someone with maintainer level access to the repository. 4 | 5 | 1. Run the [Stage Release on Master Branch](https://github.com/hap-java/HAP-Java/actions/workflows/release.yml) Action with a version such as `2.0.2` 6 | 2. After this completes, find the release on the [Releases page](https://github.com/hap-java/HAP-Java/releases) 7 | 3. Edit the release to include the changelog details 8 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/AirQualityAccessory.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.airquality.AirQualityEnum; 5 | import io.github.hapjava.services.Service; 6 | import io.github.hapjava.services.impl.AirQualityService; 7 | import java.util.Collection; 8 | import java.util.Collections; 9 | import java.util.concurrent.CompletableFuture; 10 | 11 | /** An air quality accessory which can include several sensors. */ 12 | public interface AirQualityAccessory extends HomekitAccessory { 13 | 14 | /** 15 | * Retrieves the state of the air quality 16 | * 17 | * @return a future that will contain the state 18 | */ 19 | CompletableFuture getAirQuality(); 20 | 21 | /** 22 | * Subscribes to changes in the air quality 23 | * 24 | * @param callback the function to call when the air quality changes. 25 | */ 26 | void subscribeAirQuality(HomekitCharacteristicChangeCallback callback); 27 | 28 | /** Unsubscribes from changes in the air quality. */ 29 | void unsubscribeAirQuality(); 30 | 31 | @Override 32 | default Collection getServices() { 33 | return Collections.singleton(new AirQualityService(this)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/Bridge.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories; 2 | 3 | /** HomeKit bridge service. */ 4 | public interface Bridge extends HomekitAccessory { 5 | 6 | @Override 7 | default void identify() {} 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/MotionSensorAccessory.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.services.Service; 5 | import io.github.hapjava.services.impl.MotionSensorService; 6 | import java.util.Collection; 7 | import java.util.Collections; 8 | import java.util.concurrent.CompletableFuture; 9 | 10 | /** 11 | * A motion sensor that reports whether motion has been detected. 12 | * 13 | * @author Gaston Dombiak 14 | */ 15 | public interface MotionSensorAccessory extends HomekitAccessory { 16 | 17 | /** 18 | * Retrieves the state of the motion sensor. If true then motion has been detected. 19 | * 20 | * @return a future that will contain the motion sensor's state 21 | */ 22 | CompletableFuture getMotionDetected(); 23 | 24 | /** 25 | * Subscribes to changes in the motion sensor. 26 | * 27 | * @param callback the function to call when the state changes. 28 | */ 29 | void subscribeMotionDetected(HomekitCharacteristicChangeCallback callback); 30 | 31 | /** Unsubscribes from changes in the motion sensor. */ 32 | void unsubscribeMotionDetected(); 33 | 34 | @Override 35 | default Collection getServices() { 36 | return Collections.singleton(new MotionSensorService(this)); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithAccessoryFlags.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.accessoryinformation.AccessoryFlagsEnum; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | /** Accessory with accessory flags, which indicates that additional setup is required */ 8 | public interface AccessoryWithAccessoryFlags { 9 | 10 | /** 11 | * When set indicates accessory requires additional setup. 12 | * 13 | * @return a future that will contain the accessory flags 14 | */ 15 | CompletableFuture getAccessoryFlags(); 16 | 17 | /** 18 | * Subscribes to changes in accessory flags 19 | * 20 | * @param callback the function to call when the accessory flags changes. 21 | */ 22 | void subscribeAccessoryFlags(HomekitCharacteristicChangeCallback callback); 23 | 24 | /** Unsubscribes from changes in the accessory flags . */ 25 | void unsubscribeAccessoryFlags(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithConfiguredName.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** Accessory with configured name. */ 7 | public interface AccessoryWithConfiguredName { 8 | 9 | /** 10 | * Retrieves configured name. 11 | * 12 | * @return configured name 13 | */ 14 | CompletableFuture getConfiguredName(); 15 | 16 | /** 17 | * Sets the configured name 18 | * 19 | * @param name configured name 20 | * @return a future that completes when the change is made 21 | * @throws Exception when the change cannot be made 22 | */ 23 | CompletableFuture setConfiguredName(String name) throws Exception; 24 | 25 | /** 26 | * Subscribes to changes in configured name. 27 | * 28 | * @param callback the function to call when the configureed name changes. 29 | */ 30 | void subscribeConfiguredName(HomekitCharacteristicChangeCallback callback); 31 | 32 | /** Unsubscribes from changes in the configured name state. */ 33 | void unsubscribeConfiguredName(); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithCurrentHorizontalTilting.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** 7 | * Accessory with current horizontal tilting characteristic. 8 | * 9 | * @author Andy Lintner 10 | */ 11 | public interface AccessoryWithCurrentHorizontalTilting { 12 | 13 | /** 14 | * Retrieves the current horizontal tilt angle 15 | * 16 | * @return a future that will contain the position as a value between -90 and 90 17 | */ 18 | CompletableFuture getCurrentHorizontalTiltAngle(); 19 | 20 | /** 21 | * Subscribes to changes in the current horizontal tilt angle. 22 | * 23 | * @param callback the function to call when the state changes. 24 | */ 25 | void subscribeCurrentHorizontalTiltAngle(HomekitCharacteristicChangeCallback callback); 26 | 27 | /** Unsubscribes from changes in the current horizontal tilt angle */ 28 | void unsubscribeCurrentHorizontalTiltAngle(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithCurrentMediaState.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.television.CurrentMediaStateEnum; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | /** 8 | * Accessory with current media state characteristic {@link 9 | * io.github.hapjava.characteristics.impl.television.CurrentMediaStateCharacteristic}. 10 | */ 11 | public interface AccessoryWithCurrentMediaState { 12 | 13 | /** 14 | * Retrieves the current media state (see {@link 15 | * io.github.hapjava.characteristics.impl.television.CurrentMediaStateEnum} for supported values). 16 | * 17 | * @return a future that will contain the current media state 18 | */ 19 | CompletableFuture getCurrentMediaState(); 20 | 21 | /** 22 | * Subscribes to changes in the current media state. 23 | * 24 | * @param callback the function to call when the current media state changes. 25 | */ 26 | void subscribeCurrentMediaState(HomekitCharacteristicChangeCallback callback); 27 | 28 | /** Unsubscribes from changes in the current media state. */ 29 | void unsubscribeCurrentMediaState(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithCurrentRelativeHumidity.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** accessory with current relative humidity. */ 7 | public interface AccessoryWithCurrentRelativeHumidity { 8 | 9 | /** 10 | * Retrieves the current relative humidity. 11 | * 12 | * @return a future that will contain the current relative humidity. 13 | */ 14 | CompletableFuture getCurrentRelativeHumidity(); 15 | 16 | /** 17 | * Subscribes to changes in current relative humidity. 18 | * 19 | * @param callback the function to call when the current relative humidity changes. 20 | */ 21 | void subscribeCurrentRelativeHumidity(HomekitCharacteristicChangeCallback callback); 22 | 23 | /** Unsubscribes from changes in the current relative humidity. */ 24 | void unsubscribeCurrentRelativeHumidity(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithCurrentTilting.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** Accessory with current tilting characteristic. */ 7 | public interface AccessoryWithCurrentTilting { 8 | 9 | /** 10 | * Retrieves the current tilt angle 11 | * 12 | * @return a future that will contain the position as a value between -90 and 90 13 | */ 14 | CompletableFuture getCurrentTiltAngle(); 15 | 16 | /** 17 | * Subscribes to changes in the current tilt angle. 18 | * 19 | * @param callback the function to call when the state changes. 20 | */ 21 | void subscribeCurrentTiltAngle(HomekitCharacteristicChangeCallback callback); 22 | 23 | /** Unsubscribes from changes in the current tilt angle */ 24 | void unsubscribeCurrentTiltAngle(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithCurrentVerticalTilting.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** Accessory with current vertical tilting characteristic. */ 7 | public interface AccessoryWithCurrentVerticalTilting { 8 | /** 9 | * Retrieves the current vertical tilt angle 10 | * 11 | * @return a future that will contain the position as a value between -90 and 90 12 | */ 13 | CompletableFuture getCurrentVerticalTiltAngle(); 14 | 15 | /** 16 | * Subscribes to changes in the current vertical tilt angle. 17 | * 18 | * @param callback the function to call when the state changes. 19 | */ 20 | void subscribeCurrentVerticalTiltAngle(HomekitCharacteristicChangeCallback callback); 21 | 22 | /** Unsubscribes from changes in the current vertical tilt angle */ 23 | void unsubscribeCurrentVerticalTiltAngle(); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithFilterLifeLevel.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** Accessory with filter level characteristics */ 7 | public interface AccessoryWithFilterLifeLevel { 8 | 9 | /** 10 | * what's the filter life level, percentage wise 11 | * 12 | * @return filter life level 13 | */ 14 | CompletableFuture getFilterLifeLevel(); 15 | 16 | /** 17 | * Subscribes to changes in the filter life level. 18 | * 19 | * @param callback the function to call when the level changes. 20 | */ 21 | void subscribeFilterLifeLevel(HomekitCharacteristicChangeCallback callback); 22 | 23 | /** Unsubscribes from changes in the current filter life level. */ 24 | void unsubscribeFilterLifeLevel(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithHardwareRevision.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | 5 | /** Accessory with hardware revision. */ 6 | public interface AccessoryWithHardwareRevision { 7 | 8 | /** 9 | * Returns a hardware revision to display in iOS. 10 | * 11 | * @return the hardware revision, or null. 12 | */ 13 | CompletableFuture getHardwareRevision(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithHoldPosition.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | 5 | /** Accessory with hold position */ 6 | public interface AccessoryWithHoldPosition { 7 | 8 | /** 9 | * Sets the hold position state 10 | * 11 | * @param hold whether or not to hold the current position state 12 | * @return a future that completes when the change is made 13 | * @throws Exception when the change cannot be made 14 | */ 15 | CompletableFuture setHoldPosition(boolean hold) throws Exception; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithHumidityDehumidifierThreshold.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** Dehumidifier with humidity threshold. */ 7 | public interface AccessoryWithHumidityDehumidifierThreshold { 8 | 9 | /** 10 | * Retrieves the humidity threshold. 11 | * 12 | * @return a future that will contain the humidity threshold. 13 | */ 14 | CompletableFuture getHumidityThreshold(); 15 | 16 | /** 17 | * Sets the humidity threshold above which the dehumidifier should be turned on. 18 | * 19 | * @param value the humidity threshold, in celsius degrees. 20 | * @throws Exception when the threshold cannot be changed. 21 | */ 22 | void setHumidityThreshold(Double value) throws Exception; 23 | 24 | /** 25 | * Subscribes to changes in the humidity threshold. 26 | * 27 | * @param callback the function to call when the state changes. 28 | */ 29 | void subscribeHumidityThreshold(HomekitCharacteristicChangeCallback callback); 30 | 31 | /** Unsubscribes from changes in the humidity threshold. */ 32 | void unsubscribeHumidityThreshold(); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithHumidityHumidifierThreshold.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** Humidifier with humidity threshold. */ 7 | public interface AccessoryWithHumidityHumidifierThreshold { 8 | 9 | /** 10 | * Retrieves the humidity threshold. 11 | * 12 | * @return a future that will contain the humidity threshold. 13 | */ 14 | CompletableFuture getHumidityThreshold(); 15 | 16 | /** 17 | * Sets the humidity threshold above which the humidifier should be turned on. 18 | * 19 | * @param value the humidity threshold, in celsius degrees. 20 | * @throws Exception when the threshold cannot be changed. 21 | */ 22 | void setHumidityThreshold(Double value) throws Exception; 23 | 24 | /** 25 | * Subscribes to changes in the humidity threshold. 26 | * 27 | * @param callback the function to call when the state changes. 28 | */ 29 | void subscribeHumidityThreshold(HomekitCharacteristicChangeCallback callback); 30 | 31 | /** Unsubscribes from changes in the humidity threshold. */ 32 | void unsubscribeHumidityThreshold(); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithIdentifier.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | 5 | /** 6 | * Accessory with identifier characteristic {@link 7 | * io.github.hapjava.characteristics.impl.common.IdentifierCharacteristic}. 8 | */ 9 | public interface AccessoryWithIdentifier { 10 | 11 | /** 12 | * Retrieves the identifier of service. 13 | * 14 | * @return a future with the identifier 15 | */ 16 | CompletableFuture getIdentifier(); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithInputDeviceType.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.inputsource.InputDeviceTypeEnum; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | /** 8 | * Accessory with input devices, e.g. television. {@link 9 | * io.github.hapjava.characteristics.impl.inputsource.InputDeviceTypeCharacteristic} 10 | */ 11 | public interface AccessoryWithInputDeviceType { 12 | 13 | /** 14 | * Retrieves the input device type. See {@link InputDeviceTypeEnum} for supported values. 15 | * 16 | * @return a future with the value 17 | */ 18 | CompletableFuture getInputDeviceType(); 19 | 20 | /** 21 | * Subscribes to changes in input device type. 22 | * 23 | * @param callback the function when the input device type changes 24 | */ 25 | void subscribeInputDeviceType(HomekitCharacteristicChangeCallback callback); 26 | 27 | /** Unsubscribes from changes */ 28 | void unsubscribeInputDeviceType(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithLockCurrentState.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.lock.LockCurrentStateEnum; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | /** Accessory with current lock state. */ 8 | public interface AccessoryWithLockCurrentState { 9 | 10 | /** 11 | * Retrieves the lock states. The current state of the physical security mechanism (e.g. deadbolt) 12 | * 13 | * @return a future with the value 14 | */ 15 | CompletableFuture getLockCurrentState(); 16 | 17 | /** 18 | * Subscribes to changes in lock current state. 19 | * 20 | * @param callback the function when the lock current state changes 21 | */ 22 | void subscribeLockCurrentState(HomekitCharacteristicChangeCallback callback); 23 | 24 | /** Unsubscribes from changes */ 25 | void unsubscribeLockCurrentState(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithMute.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** 7 | * Accessory with mute characteristic {@link 8 | * io.github.hapjava.characteristics.impl.audio.MuteCharacteristic}. 9 | */ 10 | public interface AccessoryWithMute { 11 | 12 | /** 13 | * Retrieves mute status. 14 | * 15 | * @return true if accessory is muted 16 | */ 17 | CompletableFuture isMuted(); 18 | 19 | /** 20 | * Sets the mute status 21 | * 22 | * @param mute true if accessory should be muted 23 | * @return a future that completes when the change is made 24 | * @throws Exception when the change cannot be made 25 | */ 26 | CompletableFuture setMute(boolean mute) throws Exception; 27 | 28 | /** 29 | * Subscribes to changes in mute state. 30 | * 31 | * @param callback the function to call when the state changes. 32 | */ 33 | void subscribeMuteState(HomekitCharacteristicChangeCallback callback); 34 | 35 | /** Unsubscribes from changes in the mute state. */ 36 | void unsubscribeMuteState(); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithName.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | 5 | /** Accessory with name. */ 6 | public interface AccessoryWithName { 7 | 8 | /** 9 | * Retrieves the name of service. 10 | * 11 | * @return a future with the name 12 | */ 13 | CompletableFuture getName(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithObstructionDetection.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** Accessory with hold position */ 7 | public interface AccessoryWithObstructionDetection { 8 | 9 | /** 10 | * Retrieves an indication obstructed is detected 11 | * 12 | * @return a future that will contain a boolean indicating whether an obstruction is present 13 | */ 14 | CompletableFuture getObstructionDetected(); 15 | 16 | /** 17 | * Subscribes to changes in the obstruction detected state 18 | * 19 | * @param callback the function to call when the state changes. 20 | */ 21 | void subscribeObstructionDetected(HomekitCharacteristicChangeCallback callback); 22 | 23 | /** Unsubscribes from changes in the obstruction detected state */ 24 | void unsubscribeObstructionDetected(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithPowerMode.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.impl.television.PowerModeEnum; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** An accessory with power mode. */ 7 | public interface AccessoryWithPowerMode { 8 | 9 | /** 10 | * Set the power mode. See {@link PowerModeEnum} for supported values 11 | * 12 | * @param mode target power mode 13 | * @return a future that completes when the change is made 14 | */ 15 | CompletableFuture setPowerMode(PowerModeEnum mode); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithResetFilterIndication.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | 5 | /** Accessory with filter reset characteristics */ 6 | public interface AccessoryWithResetFilterIndication { 7 | 8 | /** 9 | * Request to reset the filter level 10 | * 11 | * @param indication always 1, by HomeKit protocol. (to be ignored) 12 | * @return a future that completes when the change is made 13 | * @throws Exception when the change cannot be made 14 | */ 15 | CompletableFuture resetFilterIndication(Integer indication) throws Exception; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithRotationSpeed.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** accessory with rotation speed characteristics. */ 7 | public interface AccessoryWithRotationSpeed { 8 | 9 | /** 10 | * Retrieves the current speed of the rotation 11 | * 12 | * @return a future that will contain the speed, expressed as an integer between 0 and 100. 13 | */ 14 | CompletableFuture getRotationSpeed(); 15 | 16 | /** 17 | * Sets the speed of the rotation 18 | * 19 | * @param speed the speed to set, expressed as an integer between 0 and 100. 20 | * @return a future that completes when the change is made 21 | * @throws Exception when the change cannot be made 22 | */ 23 | CompletableFuture setRotationSpeed(Double speed) throws Exception; 24 | 25 | /** 26 | * Subscribes to changes in the rotation speed. 27 | * 28 | * @param callback the function to call when the speed changes. 29 | */ 30 | void subscribeRotationSpeed(HomekitCharacteristicChangeCallback callback); 31 | 32 | /** Unsubscribes from changes in the rotation speed. */ 33 | void unsubscribeRotationSpeed(); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithSecurityAlarmType.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.securitysystem.SecuritySystemAlarmTypeEnum; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | /** This characteristic describes the type of alarm triggered by a security system. */ 8 | public interface AccessoryWithSecurityAlarmType { 9 | 10 | /** 11 | * return alarm type See {@link SecuritySystemAlarmTypeEnum} for possible values 12 | * 13 | * @return a future with the value 14 | */ 15 | CompletableFuture getSecurityAlarmType(); 16 | 17 | /** 18 | * Subscribes to changes in status alarm type 19 | * 20 | * @param callback the function when the alarm type changes 21 | */ 22 | void subscribeSecurityAlarmType(HomekitCharacteristicChangeCallback callback); 23 | 24 | /** Unsubscribes from changes */ 25 | void unsubscribeSecurityAlarmType(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithServiceLabelIndex.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | 5 | /** Accessory with service label index. T */ 6 | public interface AccessoryWithServiceLabelIndex { 7 | 8 | /** 9 | * Retrieves the service label index. 10 | * 11 | * @return a future with the service label index 12 | */ 13 | CompletableFuture getServiceLabelIndex(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithStatusActive.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** Accessory with status active. */ 7 | public interface AccessoryWithStatusActive { 8 | 9 | /** 10 | * Retrieves the status active. A value of true indicates that the accessory is active and is 11 | * functioning without any errors. 12 | * 13 | * @return a future with the value 14 | */ 15 | CompletableFuture getStatusActive(); 16 | 17 | /** 18 | * Subscribes to changes in status active. 19 | * 20 | * @param callback the function when the status active changes 21 | */ 22 | void subscribeStatusActive(HomekitCharacteristicChangeCallback callback); 23 | 24 | /** Unsubscribes from changes */ 25 | void unsubscribeStatusActive(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithStatusFault.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.common.StatusFaultEnum; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | /** Accessory with characteristic that describes an accessory which has a fault. */ 8 | public interface AccessoryWithStatusFault { 9 | 10 | /** 11 | * Retrieves the status fault. A non-zero value indicates that the accessory has experienced a 12 | * fault that may be interfering with its intended functionality. A value of 0 indicates that 13 | * there is no fault. 14 | * 15 | * @return a future with the value 16 | */ 17 | CompletableFuture getStatusFault(); 18 | 19 | /** 20 | * Subscribes to changes in status fault. 21 | * 22 | * @param callback the function when the status fault changes 23 | */ 24 | void subscribeStatusFault(HomekitCharacteristicChangeCallback callback); 25 | 26 | /** Unsubscribes from changes */ 27 | void unsubscribeStatusFault(); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithStatusLowBattery.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.battery.StatusLowBatteryEnum; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | /** This characteristic describes an accessoryʼs battery status. */ 8 | public interface AccessoryWithStatusLowBattery { 9 | 10 | /** 11 | * A status of 1 indicates that the battery level of the accessory is low. Value should return to 12 | * 0 when the battery charges to a level thats above the low threshold. 13 | * 14 | * @return a future with the value 15 | */ 16 | CompletableFuture getStatusLowBattery(); 17 | 18 | /** 19 | * Subscribes to changes in status low battery. 20 | * 21 | * @param callback the function when the status low batter changes 22 | */ 23 | void subscribeStatusLowBattery(HomekitCharacteristicChangeCallback callback); 24 | 25 | /** Unsubscribes from changes */ 26 | void unsubscribeStatusLowBattery(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithStatusTampered.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.common.StatusTamperedEnum; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | /** This characteristic describes an accessory which has been tampered with. */ 8 | public interface AccessoryWithStatusTampered { 9 | 10 | /** 11 | * Retrieves the status tampered. 12 | * 13 | * @return a future with the value 14 | */ 15 | CompletableFuture getStatusTampered(); 16 | 17 | /** 18 | * Subscribes to changes in status tampered. 19 | * 20 | * @param callback the function when the status tampered changes 21 | */ 22 | void subscribeStatusTampered(HomekitCharacteristicChangeCallback callback); 23 | 24 | /** Unsubscribes from changes */ 25 | void unsubscribeStatusTampered(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithSwingMode.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.fan.SwingModeEnum; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | /** Accessory with Swing Mode characteristics. */ 8 | public interface AccessoryWithSwingMode { 9 | 10 | /** 11 | * Retrieves the swing mode. 12 | * 13 | * @return a future that will contain the swing mode 14 | */ 15 | CompletableFuture getSwingMode(); 16 | 17 | /** 18 | * Set the swing mode (DISABLED, ENABLED). 19 | * 20 | * @param swingMode swing mode 21 | * @return a future that completes when the change is made 22 | */ 23 | CompletableFuture setSwingMode(SwingModeEnum swingMode); 24 | 25 | /** 26 | * Subscribes to changes in the swing mode. 27 | * 28 | * @param callback the function to call when the swing mode changes. 29 | */ 30 | void subscribeSwingMode(HomekitCharacteristicChangeCallback callback); 31 | 32 | /** Unsubscribes from changes in the swing mode. */ 33 | void unsubscribeSwingMode(); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithTargetRelativeHumidity.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** accessory with target relative humidity. */ 7 | public interface AccessoryWithTargetRelativeHumidity { 8 | 9 | /** 10 | * Retrieves the target relative humidity. 11 | * 12 | * @return a future that will contain the target relative humidity. 13 | */ 14 | CompletableFuture getTargetRelativeHumidity(); 15 | 16 | /** 17 | * Sets the target relative humidity. 18 | * 19 | * @param value the target relative humidity. 20 | * @throws Exception when the target relative humidity cannot be changed. 21 | */ 22 | void setTargetRelativeHumidity(Double value) throws Exception; 23 | 24 | /** 25 | * Subscribes to changes in the target relative humidity. 26 | * 27 | * @param callback the function to call when the target relative humidity changes. 28 | */ 29 | void subscribeTargetRelativeHumidity(HomekitCharacteristicChangeCallback callback); 30 | 31 | /** Unsubscribes from changes in the target relative humidity. */ 32 | void unsubscribeTargetRelativeHumidity(); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithTargetTilting.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** Accessory with target tilting characteristic. */ 7 | public interface AccessoryWithTargetTilting { 8 | 9 | /** 10 | * Retrieves the target tilt angle 11 | * 12 | * @return a future that will contain the target position as a value between -90 and 90 13 | */ 14 | CompletableFuture getTargetTiltAngle(); 15 | 16 | /** 17 | * Sets the target tilt angle 18 | * 19 | * @param angle the target angle to set, as a value between -90 and 90 20 | * @return a future that completes when the change is made 21 | * @throws Exception when the change cannot be made 22 | */ 23 | CompletableFuture setTargetTiltAngle(int angle) throws Exception; 24 | 25 | /** 26 | * Subscribes to changes in the target tilt angle. 27 | * 28 | * @param callback the function to call when the state changes. 29 | */ 30 | void subscribeTargetTiltAngle(HomekitCharacteristicChangeCallback callback); 31 | 32 | /** Unsubscribes from changes in the target tilt angle */ 33 | void unsubscribeTargetTiltAngle(); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithVolume.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** Accessory with volume values. */ 7 | public interface AccessoryWithVolume { 8 | 9 | /** 10 | * Retrieves the current volume 11 | * 12 | * @return a future that will contain the volume, expressed as an integer between 0 and 100. 13 | */ 14 | CompletableFuture getVolume(); 15 | 16 | /** 17 | * Sets the current volume 18 | * 19 | * @param value the volume, on a scale of 0 to 100, to set 20 | * @return a future that completes when the volume is changed 21 | * @throws Exception when the volume cannot be set 22 | */ 23 | CompletableFuture setVolume(Integer value) throws Exception; 24 | 25 | /** 26 | * Subscribes to changes in the volume. 27 | * 28 | * @param callback the function to call when the state changes. 29 | */ 30 | void subscribeVolume(HomekitCharacteristicChangeCallback callback); 31 | 32 | /** Unsubscribes from changes in the volume. */ 33 | void unsubscribeVolume(); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithVolumeControlType.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.televisionspeaker.VolumeControlTypeEnum; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | /** 8 | * Accessory with volume control type {@link 9 | * io.github.hapjava.characteristics.impl.televisionspeaker.VolumeControlTypeCharacteristic} 10 | */ 11 | public interface AccessoryWithVolumeControlType { 12 | 13 | /** 14 | * Retrieves the current volume control type. see {@link VolumeControlTypeEnum} for possible 15 | * values 16 | * 17 | * @return a future that will contain the type. 18 | */ 19 | CompletableFuture getVolumeControlType(); 20 | 21 | /** 22 | * Subscribes to changes in the volume. 23 | * 24 | * @param callback the function to call when the state changes. 25 | */ 26 | void subscribeVolumeControlType(HomekitCharacteristicChangeCallback callback); 27 | 28 | /** Unsubscribes from changes in the volume. */ 29 | void unsubscribeVolumeControlType(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithVolumeSelector.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.impl.televisionspeaker.VolumeSelectorEnum; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** 7 | * Accessory with volume selector {@link 8 | * io.github.hapjava.characteristics.impl.televisionspeaker.VolumeSelectorCharacteristic} 9 | */ 10 | public interface AccessoryWithVolumeSelector { 11 | 12 | /** 13 | * Sets the volume selector 14 | * 15 | * @param value the volume selector 16 | * @return a future that completes when the volume selector is changed 17 | * @throws Exception when the volume selector cannot be set 18 | */ 19 | CompletableFuture setVolumeSelector(VolumeSelectorEnum value) throws Exception; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithWaterLevel.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.accessories.optionalcharacteristic; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** Accessory with water level. */ 7 | public interface AccessoryWithWaterLevel { 8 | 9 | /** 10 | * Retrieves the water level in percent. 11 | * 12 | * @return a future that will contain the water level, expressed as an double between 0 and 100. 13 | */ 14 | CompletableFuture getWaterLevel(); 15 | 16 | /** 17 | * Subscribes to changes in the water level. 18 | * 19 | * @param callback the function to call when the state changes. 20 | */ 21 | void subscribeWaterLevel(HomekitCharacteristicChangeCallback callback); 22 | 23 | /** Unsubscribes from changes in the water level. */ 24 | void unsubscribeWaterLevel(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/accessories/package-info.java: -------------------------------------------------------------------------------- 1 | /** Contains interfaces that can be implemented to represent an exposed accessory. */ 2 | package io.github.hapjava.accessories; 3 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/CharacteristicEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics; 2 | 3 | public interface CharacteristicEnum { 4 | int getCode(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/EventableCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics; 2 | 3 | /** 4 | * A characteristic that can be listened to by the connected iOS device. 5 | * 6 | * @author Andy Lintner 7 | */ 8 | public interface EventableCharacteristic extends Characteristic { 9 | 10 | /** 11 | * Begin listening to changes to this characteristic. When a change is made, call the provided 12 | * function. 13 | * 14 | * @param callback a function to call when a change is made to the characteristic value. 15 | */ 16 | void subscribe(HomekitCharacteristicChangeCallback callback); 17 | 18 | /** Stop listening to changes to this characteristic. */ 19 | void unsubscribe(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/ExceptionalConsumer.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics; 2 | 3 | public interface ExceptionalConsumer { 4 | void accept(T t) throws Exception; 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/HomekitCharacteristicChangeCallback.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics; 2 | 3 | /** 4 | * A callback interface for notifying subscribers that a characteristic value has changed. 5 | * 6 | *

{@link EventableCharacteristic}s can be subscribed to, and in doing so, are supplied an 7 | * instance of this class. Implementors should call the {@link #changed()} method on the passed 8 | * object when a subscribed characteristic changes. 9 | * 10 | * @author Andy Lintner 11 | */ 12 | @FunctionalInterface 13 | public interface HomekitCharacteristicChangeCallback { 14 | 15 | /** 16 | * Call when the value of the characteristic that was subscribed to when this object was passed 17 | * changes. 18 | */ 19 | void changed(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/accessoryinformation/AccessoryFlagsCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.accessoryinformation; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * This characteristic indicates whether accessory requires additional setup. See {@link 12 | * AccessoryFlagsEnum} for possible values. 13 | */ 14 | public class AccessoryFlagsCharacteristic extends EnumCharacteristic { 15 | 16 | public AccessoryFlagsCharacteristic( 17 | Supplier> getter, 18 | Consumer subscriber, 19 | Runnable unsubscriber) { 20 | super( 21 | "000000A6-0000-1000-8000-0026BB765291", 22 | "accessory flags", 23 | AccessoryFlagsEnum.values(), 24 | Optional.of(getter), 25 | Optional.empty(), 26 | Optional.of(subscriber), 27 | Optional.of(unsubscriber)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/accessoryinformation/AccessoryFlagsEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.accessoryinformation; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0x0001 (bit0) ”Requires additional setup” 0x0002 - 0xFFFF ”Reserved” */ 9 | public enum AccessoryFlagsEnum implements CharacteristicEnum { 10 | NO_FLAGS(0), 11 | REQUIRES_ADDITIONAL_SETUP(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(AccessoryFlagsEnum.values()) 18 | .collect(Collectors.toMap(AccessoryFlagsEnum::getCode, t -> t)); 19 | } 20 | 21 | public static AccessoryFlagsEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | AccessoryFlagsEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/accessoryinformation/FirmwareRevisionCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.accessoryinformation; 2 | 3 | import io.github.hapjava.characteristics.impl.base.StaticStringCharacteristic; 4 | import java.util.Optional; 5 | import java.util.concurrent.CompletableFuture; 6 | import java.util.function.Supplier; 7 | 8 | /** This characteristic describes a firmware revision string */ 9 | public class FirmwareRevisionCharacteristic extends StaticStringCharacteristic { 10 | 11 | public FirmwareRevisionCharacteristic(Supplier> getter) { 12 | super( 13 | "00000052-0000-1000-8000-0026BB765291", 14 | "firmware revision", 15 | Optional.of(getter), 16 | Optional.empty(), 17 | Optional.empty()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/accessoryinformation/HardwareRevisionCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.accessoryinformation; 2 | 3 | import io.github.hapjava.characteristics.impl.base.StaticStringCharacteristic; 4 | import java.util.Optional; 5 | import java.util.concurrent.CompletableFuture; 6 | import java.util.function.Supplier; 7 | 8 | /** This characteristic describes a hardware revision in a form x[.y[.z]] (e.g. ”100.1.1”) */ 9 | public class HardwareRevisionCharacteristic extends StaticStringCharacteristic { 10 | 11 | public HardwareRevisionCharacteristic(Supplier> getter) { 12 | super( 13 | "00000053-0000-1000-8000-0026BB765291", 14 | "hardware revision", 15 | Optional.of(getter), 16 | Optional.empty(), 17 | Optional.empty()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/accessoryinformation/IdentifyCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.accessoryinformation; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.impl.base.BooleanCharacteristic; 5 | import java.util.Optional; 6 | 7 | /** This characteristic enables accessory to run its identify routine. */ 8 | public class IdentifyCharacteristic extends BooleanCharacteristic { 9 | 10 | public IdentifyCharacteristic(ExceptionalConsumer setter) { 11 | super( 12 | "00000014-0000-1000-8000-0026BB765291", 13 | "identifies the accessory", 14 | Optional.empty(), 15 | Optional.of(setter), 16 | Optional.empty(), 17 | Optional.empty()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/accessoryinformation/ManufacturerCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.accessoryinformation; 2 | 3 | import io.github.hapjava.characteristics.impl.base.StaticStringCharacteristic; 4 | import java.util.Optional; 5 | import java.util.concurrent.CompletableFuture; 6 | import java.util.function.Supplier; 7 | 8 | /** This characteristic contains the name of the company whose brand will appear on the accessory */ 9 | public class ManufacturerCharacteristic extends StaticStringCharacteristic { 10 | 11 | public ManufacturerCharacteristic(Supplier> getter) { 12 | super( 13 | "00000020-0000-1000-8000-0026BB765291", 14 | "manufacturer", 15 | Optional.of(getter), 16 | Optional.empty(), 17 | Optional.empty()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/accessoryinformation/ModelCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.accessoryinformation; 2 | 3 | import io.github.hapjava.characteristics.impl.base.StaticStringCharacteristic; 4 | import java.util.Optional; 5 | import java.util.concurrent.CompletableFuture; 6 | import java.util.function.Supplier; 7 | 8 | /** This characteristic contains the manufacturer-specific model of the accessory */ 9 | public class ModelCharacteristic extends StaticStringCharacteristic { 10 | 11 | public ModelCharacteristic(Supplier> getter) { 12 | super( 13 | "00000021-0000-1000-8000-0026BB765291", 14 | "model", 15 | Optional.of(getter), 16 | Optional.empty(), 17 | Optional.empty()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/accessoryinformation/SerialNumberCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.accessoryinformation; 2 | 3 | import io.github.hapjava.characteristics.impl.base.StaticStringCharacteristic; 4 | import java.util.Optional; 5 | import java.util.concurrent.CompletableFuture; 6 | import java.util.function.Supplier; 7 | 8 | /** This characteristic contains the manufacturer-specific serial number of the accessory. */ 9 | public class SerialNumberCharacteristic extends StaticStringCharacteristic { 10 | 11 | public SerialNumberCharacteristic(Supplier> getter) { 12 | super( 13 | "00000030-0000-1000-8000-0026BB765291", 14 | "serial number", 15 | Optional.of(getter), 16 | Optional.empty(), 17 | Optional.empty()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/airpurifier/CurrentAirPurifierCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.airpurifier; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * This characteristic describes the current state of the air purifier. See {@link 12 | * CurrentAirPurifierStateEnum} for possible values. 13 | */ 14 | public class CurrentAirPurifierCharacteristic 15 | extends EnumCharacteristic { 16 | 17 | public CurrentAirPurifierCharacteristic( 18 | Supplier> getter, 19 | Consumer subscriber, 20 | Runnable unsubscriber) { 21 | super( 22 | "000000A9-0000-1000-8000-0026BB765291", 23 | "current air purifier state", 24 | CurrentAirPurifierStateEnum.values(), 25 | Optional.of(getter), 26 | Optional.empty(), 27 | Optional.of(subscriber), 28 | Optional.of(unsubscriber)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/airpurifier/CurrentAirPurifierStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.airpurifier; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Inactive” 1 ”Idle” 2 ”Purifying Air” */ 9 | public enum CurrentAirPurifierStateEnum implements CharacteristicEnum { 10 | INACTIVE(0), 11 | IDLE(1), 12 | PURIFYING_AIR(2); 13 | 14 | private static final Map reverse; 15 | 16 | static { 17 | reverse = 18 | Arrays.stream(CurrentAirPurifierStateEnum.values()) 19 | .collect(Collectors.toMap(CurrentAirPurifierStateEnum::getCode, t -> t)); 20 | } 21 | 22 | public static CurrentAirPurifierStateEnum fromCode(Integer code) { 23 | return reverse.get(code); 24 | } 25 | 26 | private final int code; 27 | 28 | CurrentAirPurifierStateEnum(int code) { 29 | this.code = code; 30 | } 31 | 32 | @Override 33 | public int getCode() { 34 | return code; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/airpurifier/TargetAirPurifierStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.airpurifier; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Manual” 1 ”Auto” */ 9 | public enum TargetAirPurifierStateEnum implements CharacteristicEnum { 10 | MANUAL(0), 11 | AUTO(1); 12 | private static final Map reverse; 13 | 14 | static { 15 | reverse = 16 | Arrays.stream(TargetAirPurifierStateEnum.values()) 17 | .collect(Collectors.toMap(t -> t.getCode(), t -> t)); 18 | } 19 | 20 | public static TargetAirPurifierStateEnum fromCode(Integer code) { 21 | return reverse.get(code); 22 | } 23 | 24 | private final int code; 25 | 26 | private TargetAirPurifierStateEnum(int code) { 27 | this.code = code; 28 | } 29 | 30 | public int getCode() { 31 | return code; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/airquality/AirQualityCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.airquality; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * This characteristic describes the air quality. See {@link AirQualityEnum} for possible values. 12 | */ 13 | public class AirQualityCharacteristic extends EnumCharacteristic { 14 | 15 | public AirQualityCharacteristic( 16 | Supplier> getter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "00000095-0000-1000-8000-0026BB765291", 21 | "air quality", 22 | AirQualityEnum.values(), 23 | Optional.of(getter), 24 | Optional.empty(), 25 | Optional.of(subscriber), 26 | Optional.of(unsubscriber)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/airquality/AirQualityEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.airquality; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Unknown” 1 ”Excellent” 2 ”Good” 3 ”Fair” 4 ”Inferior” 5 ”Poor” */ 9 | public enum AirQualityEnum implements CharacteristicEnum { 10 | UNKNOWN(0), 11 | EXCELLENT(1), 12 | GOOD(2), 13 | FAIR(3), 14 | INFERIOR(4), 15 | POOR(5); 16 | 17 | private static final Map reverse; 18 | 19 | static { 20 | reverse = 21 | Arrays.stream(AirQualityEnum.values()) 22 | .collect(Collectors.toMap(AirQualityEnum::getCode, t -> t)); 23 | } 24 | 25 | public static AirQualityEnum fromCode(Integer code) { 26 | return reverse.get(code); 27 | } 28 | 29 | private final int code; 30 | 31 | AirQualityEnum(int code) { 32 | this.code = code; 33 | } 34 | 35 | @Override 36 | public int getCode() { 37 | return code; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/audio/MuteCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.audio; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.BooleanCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** Mute characteristic to control audio input or output accessory. */ 12 | public class MuteCharacteristic extends BooleanCharacteristic { 13 | public MuteCharacteristic( 14 | Supplier> getter, 15 | ExceptionalConsumer setter, 16 | Consumer subscriber, 17 | Runnable unsubscriber) { 18 | super( 19 | "0000011A-0000-1000-8000-0026BB765291", 20 | "Mute", 21 | Optional.of(getter), 22 | Optional.of(setter), 23 | Optional.of(subscriber), 24 | Optional.of(unsubscriber)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/audio/VolumeCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.audio; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.ExceptionalConsumer; 5 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 6 | import io.github.hapjava.characteristics.impl.base.IntegerCharacteristic; 7 | import java.util.Optional; 8 | import java.util.concurrent.CompletableFuture; 9 | import java.util.function.Consumer; 10 | import java.util.function.Supplier; 11 | 12 | /** Volume characteristic to control audio volume. */ 13 | public class VolumeCharacteristic extends IntegerCharacteristic implements EventableCharacteristic { 14 | 15 | public VolumeCharacteristic( 16 | Supplier> getter, 17 | ExceptionalConsumer setter, 18 | Consumer subscriber, 19 | Runnable unsubscriber) { 20 | super( 21 | "00000119-0000-1000-8000-0026BB765291", 22 | "volume", 23 | 0, 24 | 100, 25 | "percentage", 26 | Optional.of(getter), 27 | Optional.of(setter), 28 | Optional.of(subscriber), 29 | Optional.of(unsubscriber)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/battery/BatteryLevelCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.battery; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.IntegerCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** This characteristic describes the current level of the battery. */ 12 | public class BatteryLevelCharacteristic extends IntegerCharacteristic 13 | implements EventableCharacteristic { 14 | 15 | public BatteryLevelCharacteristic( 16 | Supplier> getter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "00000068-0000-1000-8000-0026BB765291", 21 | "battery level", 22 | 0, 23 | 100, 24 | "%", 25 | Optional.of(getter), 26 | Optional.empty(), 27 | Optional.of(subscriber), 28 | Optional.of(unsubscriber)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/battery/ChargingStateCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.battery; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * This characteristic describes the charging state of a battery or an accessory. See {@link 12 | * ChargingStateEnum} for possible values. 13 | */ 14 | public class ChargingStateCharacteristic extends EnumCharacteristic { 15 | 16 | public ChargingStateCharacteristic( 17 | Supplier> getter, 18 | Consumer subscriber, 19 | Runnable unsubscriber) { 20 | super( 21 | "0000008F-0000-1000-8000-0026BB765291", 22 | "Charging state", 23 | ChargingStateEnum.values(), 24 | Optional.of(getter), 25 | Optional.empty(), 26 | Optional.of(subscriber), 27 | Optional.of(unsubscriber)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/battery/ChargingStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.battery; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Not Charging” 1 ”Charging” 2 ”Not Chargeable” */ 9 | public enum ChargingStateEnum implements CharacteristicEnum { 10 | NOT_CHARGING(0), 11 | CHARGING(1), 12 | NOT_CHARABLE(2); 13 | 14 | private static final Map reverse; 15 | 16 | static { 17 | reverse = 18 | Arrays.stream(ChargingStateEnum.values()) 19 | .collect(Collectors.toMap(ChargingStateEnum::getCode, t -> t)); 20 | } 21 | 22 | public static ChargingStateEnum fromCode(Integer code) { 23 | return reverse.get(code); 24 | } 25 | 26 | private final int code; 27 | 28 | ChargingStateEnum(int code) { 29 | this.code = code; 30 | } 31 | 32 | @Override 33 | public int getCode() { 34 | return code; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/battery/StatusLowBatteryCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.battery; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * This characteristic describes an accessory battery status. See {@link StatusLowBatteryEnum} for 12 | * possible values 13 | */ 14 | public class StatusLowBatteryCharacteristic extends EnumCharacteristic { 15 | 16 | public StatusLowBatteryCharacteristic( 17 | Supplier> getter, 18 | Consumer subscriber, 19 | Runnable unsubscriber) { 20 | super( 21 | "00000079-0000-1000-8000-0026BB765291", 22 | "Status Low Battery", 23 | StatusLowBatteryEnum.values(), 24 | Optional.of(getter), 25 | Optional.empty(), 26 | Optional.of(subscriber), 27 | Optional.of(unsubscriber)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/battery/StatusLowBatteryEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.battery; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Battery level is normal” 1 ”Battery level is low” */ 9 | public enum StatusLowBatteryEnum implements CharacteristicEnum { 10 | NORMAL(0), 11 | LOW(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(StatusLowBatteryEnum.values()) 18 | .collect(Collectors.toMap(StatusLowBatteryEnum::getCode, t -> t)); 19 | } 20 | 21 | public static StatusLowBatteryEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | StatusLowBatteryEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/carbondioxidesensor/CarbonDioxideDetectedEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.carbondioxidesensor; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Carbon Dioxide levels are normal” 1 ”Carbon Dioxide levels are abnormal” */ 9 | public enum CarbonDioxideDetectedEnum implements CharacteristicEnum { 10 | NORMAL(0), 11 | ABNORMAL(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(CarbonDioxideDetectedEnum.values()) 18 | .collect(Collectors.toMap(CarbonDioxideDetectedEnum::getCode, t -> t)); 19 | } 20 | 21 | public static CarbonDioxideDetectedEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | CarbonDioxideDetectedEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/carbonmonoxidesensor/CarbonMonoxideDetectedEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.carbonmonoxidesensor; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Carbon Monoxide levels are normal” 1 ”Carbon Monoxide levels are abnormal” */ 9 | public enum CarbonMonoxideDetectedEnum implements CharacteristicEnum { 10 | NORMAL(0), 11 | ABNORMAL(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(CarbonMonoxideDetectedEnum.values()) 18 | .collect(Collectors.toMap(CarbonMonoxideDetectedEnum::getCode, t -> t)); 19 | } 20 | 21 | public static CarbonMonoxideDetectedEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | CarbonMonoxideDetectedEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/ActiveCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** 12 | * Active characteristic indicates whether the service is currently active. See {@link ActiveEnum} 13 | * for possible values. 14 | */ 15 | public class ActiveCharacteristic extends EnumCharacteristic { 16 | 17 | public ActiveCharacteristic( 18 | Supplier> getter, 19 | ExceptionalConsumer setter, 20 | Consumer subscriber, 21 | Runnable unsubscriber) { 22 | super( 23 | "000000B0-0000-1000-8000-0026BB765291", 24 | "Active", 25 | ActiveEnum.values(), 26 | Optional.of(getter), 27 | Optional.of(setter), 28 | Optional.of(subscriber), 29 | Optional.of(unsubscriber)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/ActiveEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Inactive” 1 ”Active” 2-255 ”Reserved” */ 9 | public enum ActiveEnum implements CharacteristicEnum { 10 | INACTIVE(0), 11 | ACTIVE(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(ActiveEnum.values()).collect(Collectors.toMap(ActiveEnum::getCode, t -> t)); 18 | } 19 | 20 | public static ActiveEnum fromCode(Integer code) { 21 | return reverse.get(code); 22 | } 23 | 24 | private final int code; 25 | 26 | ActiveEnum(int code) { 27 | this.code = code; 28 | } 29 | 30 | @Override 31 | public int getCode() { 32 | return code; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/ActiveIdentifierCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.IntegerCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | public class ActiveIdentifierCharacteristic extends IntegerCharacteristic { 12 | 13 | public ActiveIdentifierCharacteristic( 14 | Supplier> getter, 15 | ExceptionalConsumer setter, 16 | Consumer subscriber, 17 | Runnable unsubscriber) { 18 | super( 19 | "000000E7-0000-1000-8000-0026BB765291", 20 | "active identifier", 21 | 0, 22 | 1000, 23 | "", 24 | Optional.of(getter), 25 | Optional.of(setter), 26 | Optional.of(subscriber), 27 | Optional.of(unsubscriber)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/AirPlayEnableCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.ExceptionalConsumer; 5 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 6 | import io.github.hapjava.characteristics.impl.base.IntegerCharacteristic; 7 | import java.util.Optional; 8 | import java.util.concurrent.CompletableFuture; 9 | import java.util.function.Consumer; 10 | import java.util.function.Supplier; 11 | 12 | /** characteristic to control air play. */ 13 | public class AirPlayEnableCharacteristic extends IntegerCharacteristic 14 | implements EventableCharacteristic { 15 | 16 | public AirPlayEnableCharacteristic( 17 | Supplier> getter, 18 | ExceptionalConsumer setter, 19 | Consumer subscriber, 20 | Runnable unsubscriber) { 21 | super( 22 | "0000025B-0000-1000-8000-0026BB765291", 23 | "AirPlay enable", 24 | 0, 25 | 1, 26 | "", 27 | Optional.of(getter), 28 | Optional.of(setter), 29 | Optional.of(subscriber), 30 | Optional.of(unsubscriber)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/ConfiguredNameCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.StringCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** This characteristic describes a configured name. */ 12 | public class ConfiguredNameCharacteristic extends StringCharacteristic { 13 | 14 | public ConfiguredNameCharacteristic( 15 | Supplier> getter, 16 | ExceptionalConsumer setter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "000000E3-0000-1000-8000-0026BB765291", 21 | "configured name", 22 | Optional.of(getter), 23 | Optional.of(setter), 24 | Optional.of(subscriber), 25 | Optional.of(unsubscriber)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/IdentifierCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.impl.base.IntegerCharacteristic; 4 | import java.util.Optional; 5 | import java.util.concurrent.CompletableFuture; 6 | import java.util.function.Supplier; 7 | 8 | public class IdentifierCharacteristic extends IntegerCharacteristic { 9 | 10 | public IdentifierCharacteristic(Supplier> getter) { 11 | super( 12 | "000000E6-0000-1000-8000-0026BB765291", 13 | "identifier", 14 | 0, 15 | 1000, 16 | "", 17 | Optional.of(getter), 18 | Optional.empty(), 19 | Optional.empty(), 20 | Optional.empty()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/InUseCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * This characteristic indicates whether the service is in use. See {@link InUseEnum} for possible 12 | * values. 13 | */ 14 | public class InUseCharacteristic extends EnumCharacteristic { 15 | public InUseCharacteristic( 16 | Supplier> getter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "000000D2-0000-1000-8000-0026BB765291", 21 | "In Use", 22 | InUseEnum.values(), 23 | Optional.of(getter), 24 | Optional.empty(), 25 | Optional.of(subscriber), 26 | Optional.of(unsubscriber)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/InUseEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Not in use” 1 ”In use” 2-255 ”Reserved” */ 9 | public enum InUseEnum implements CharacteristicEnum { 10 | NOT_IN_USE(0), 11 | IN_USE(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(InUseEnum.values()).collect(Collectors.toMap(InUseEnum::getCode, t -> t)); 18 | } 19 | 20 | public static InUseEnum fromCode(Integer code) { 21 | return reverse.get(code); 22 | } 23 | 24 | private final int code; 25 | 26 | InUseEnum(int code) { 27 | this.code = code; 28 | } 29 | 30 | @Override 31 | public int getCode() { 32 | return code; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/IsConfiguredCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** 12 | * This characteristic describes whether the service is configured for use. See {@link 13 | * IsConfiguredEnum} for possible values. 14 | */ 15 | public class IsConfiguredCharacteristic extends EnumCharacteristic { 16 | public IsConfiguredCharacteristic( 17 | Supplier> getter, 18 | ExceptionalConsumer setter, 19 | Consumer subscriber, 20 | Runnable unsubscriber) { 21 | super( 22 | "000000D6-0000-1000-8000-0026BB765291", 23 | "Is Configured", 24 | IsConfiguredEnum.values(), 25 | Optional.of(getter), 26 | Optional.of(setter), 27 | Optional.of(subscriber), 28 | Optional.of(unsubscriber)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/IsConfiguredEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Not Configured” 1 ”Configured” 2-255 ”Reserved” */ 9 | public enum IsConfiguredEnum implements CharacteristicEnum { 10 | NOT_CONFIGURED(0), 11 | CONFIGURED(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(IsConfiguredEnum.values()) 18 | .collect(Collectors.toMap(IsConfiguredEnum::getCode, t -> t)); 19 | } 20 | 21 | public static IsConfiguredEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | IsConfiguredEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/NameCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.impl.base.StaticStringCharacteristic; 4 | import java.util.Optional; 5 | import java.util.concurrent.CompletableFuture; 6 | import java.util.function.Supplier; 7 | 8 | /** This characteristic describes a name and must not be a null value. */ 9 | public class NameCharacteristic extends StaticStringCharacteristic { 10 | 11 | public NameCharacteristic(Supplier> getter) { 12 | super( 13 | "00000023-0000-1000-8000-0026BB765291", 14 | "name", 15 | Optional.of(getter), 16 | Optional.empty(), 17 | Optional.empty()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/ObstructionDetectedCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.BooleanCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** This characteristic describes the current state of an obstruction sensor. */ 11 | public class ObstructionDetectedCharacteristic extends BooleanCharacteristic { 12 | public ObstructionDetectedCharacteristic( 13 | Supplier> getter, 14 | Consumer subscriber, 15 | Runnable unsubscriber) { 16 | super( 17 | "00000024-0000-1000-8000-0026BB765291", 18 | "Obstruction", 19 | Optional.of(getter), 20 | Optional.empty(), 21 | Optional.of(subscriber), 22 | Optional.of(unsubscriber)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/OnCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.BooleanCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** This characteristic represents the states for “on” and “off”. */ 12 | public class OnCharacteristic extends BooleanCharacteristic { 13 | 14 | public OnCharacteristic( 15 | Supplier> getter, 16 | ExceptionalConsumer setter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "00000025-0000-1000-8000-0026BB765291", 21 | "On / Off state", 22 | Optional.of(getter), 23 | Optional.of(setter), 24 | Optional.of(subscriber), 25 | Optional.of(unsubscriber)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/ProgramModeCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * This characteristic describes if there are programs scheduled on the accessory. See {@link 12 | * ProgramModeEnum} for possible values. 13 | */ 14 | public class ProgramModeCharacteristic extends EnumCharacteristic { 15 | public ProgramModeCharacteristic( 16 | Supplier> getter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "000000D1-0000-1000-8000-0026BB765291", 21 | "Program Mode", 22 | ProgramModeEnum.values(), 23 | Optional.of(getter), 24 | Optional.empty(), 25 | Optional.of(subscriber), 26 | Optional.of(unsubscriber)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/ProgramModeEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 9 | * 0 ”No Programs Scheduled” 1 ”Program Scheduled” 2 ”Program Scheduled, currently overriden to 10 | * manual mode” 11 | */ 12 | public enum ProgramModeEnum implements CharacteristicEnum { 13 | NO_SCHEDULED(0), 14 | SCHEDULED(1), 15 | SCHEDULED_MANUAL(2); 16 | 17 | private static final Map reverse; 18 | 19 | static { 20 | reverse = 21 | Arrays.stream(ProgramModeEnum.values()) 22 | .collect(Collectors.toMap(ProgramModeEnum::getCode, t -> t)); 23 | } 24 | 25 | public static ProgramModeEnum fromCode(Integer code) { 26 | return reverse.get(code); 27 | } 28 | 29 | private final int code; 30 | 31 | ProgramModeEnum(int code) { 32 | this.code = code; 33 | } 34 | 35 | @Override 36 | public int getCode() { 37 | return code; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/ProgrammableSwitchEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Single Press” 1 ”Double Press” 2 ”Long Press” 3-255 ”Reserved” */ 9 | public enum ProgrammableSwitchEnum implements CharacteristicEnum { 10 | SINGLE_PRESS(0), 11 | DOUBLE_PRESS(1), 12 | LONG_PRESS(2); 13 | 14 | private static final Map reverse; 15 | 16 | static { 17 | reverse = 18 | Arrays.stream(ProgrammableSwitchEnum.values()) 19 | .collect(Collectors.toMap(ProgrammableSwitchEnum::getCode, t -> t)); 20 | } 21 | 22 | public static ProgrammableSwitchEnum fromCode(Integer code) { 23 | return reverse.get(code); 24 | } 25 | 26 | private final int code; 27 | 28 | ProgrammableSwitchEnum(int code) { 29 | this.code = code; 30 | } 31 | 32 | @Override 33 | public int getCode() { 34 | return code; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/ServiceLabelIndexCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.impl.base.IntegerCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Supplier; 8 | 9 | /** 10 | * This characteristic is used to identify the index of the label according to {@link 11 | * ServiceLabelNamespaceCharacteristic} 12 | */ 13 | public class ServiceLabelIndexCharacteristic extends IntegerCharacteristic 14 | implements EventableCharacteristic { 15 | 16 | public ServiceLabelIndexCharacteristic(Supplier> getter) { 17 | super( 18 | "000000CB-0000-1000-8000-0026BB765291", 19 | "service label index", 20 | 0, 21 | 100, 22 | "%", 23 | Optional.of(getter), 24 | Optional.empty(), 25 | Optional.empty(), 26 | Optional.empty()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/ServiceLabelNamespaceCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 4 | import java.util.Optional; 5 | import java.util.concurrent.CompletableFuture; 6 | import java.util.function.Supplier; 7 | 8 | /** 9 | * This characteristic describes the naming schema for an accessory. See {@link 10 | * ServiceLabelNamespaceEnum} for possible values. 11 | */ 12 | public class ServiceLabelNamespaceCharacteristic 13 | extends EnumCharacteristic { 14 | public ServiceLabelNamespaceCharacteristic( 15 | Supplier> getter) { 16 | super( 17 | "000000CD-0000-1000-8000-0026BB765291", 18 | "service label namespace", 19 | ServiceLabelNamespaceEnum.values(), 20 | Optional.of(getter), 21 | Optional.empty(), 22 | Optional.empty(), 23 | Optional.empty()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/ServiceLabelNamespaceEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Dots. For e.g ”.” ”..” ”...” ”....”” 1 ”Arabic numerals. For e.g. 0,1,2,3” */ 9 | public enum ServiceLabelNamespaceEnum implements CharacteristicEnum { 10 | DOTS(0), 11 | ARABIC_NUMERALS(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(ServiceLabelNamespaceEnum.values()) 18 | .collect(Collectors.toMap(ServiceLabelNamespaceEnum::getCode, t -> t)); 19 | } 20 | 21 | public static ServiceLabelNamespaceEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | ServiceLabelNamespaceEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/StatusActiveCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.BooleanCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** This characteristic describes current working (active and functional) status of accessory. */ 11 | public class StatusActiveCharacteristic extends BooleanCharacteristic { 12 | public StatusActiveCharacteristic( 13 | Supplier> getter, 14 | Consumer subscriber, 15 | Runnable unsubscriber) { 16 | super( 17 | "00000075-0000-1000-8000-0026BB765291", 18 | "Active status", 19 | Optional.of(getter), 20 | Optional.empty(), 21 | Optional.of(subscriber), 22 | Optional.of(unsubscriber)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/StatusFaultCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** This characteristic describes fault status. See {@link StatusFaultEnum} for possible values. */ 11 | public class StatusFaultCharacteristic extends EnumCharacteristic { 12 | 13 | public StatusFaultCharacteristic( 14 | Supplier> getter, 15 | Consumer subscriber, 16 | Runnable unsubscriber) { 17 | super( 18 | "00000077-0000-1000-8000-0026BB765291", 19 | "Status Fault", 20 | StatusFaultEnum.values(), 21 | Optional.of(getter), 22 | Optional.empty(), 23 | Optional.of(subscriber), 24 | Optional.of(unsubscriber)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/StatusFaultEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”No Fault” 1 ”General Fault” */ 9 | public enum StatusFaultEnum implements CharacteristicEnum { 10 | NO_FAULT(0), 11 | GENERAL_FAULT(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(StatusFaultEnum.values()) 18 | .collect(Collectors.toMap(StatusFaultEnum::getCode, t -> t)); 19 | } 20 | 21 | public static StatusFaultEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | StatusFaultEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/StatusTamperedCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * This characteristic describes tampered status. See {@link StatusTamperedEnum} for possible 12 | * values. 13 | */ 14 | public class StatusTamperedCharacteristic extends EnumCharacteristic { 15 | 16 | public StatusTamperedCharacteristic( 17 | Supplier> getter, 18 | Consumer subscriber, 19 | Runnable unsubscriber) { 20 | super( 21 | "0000007A-0000-1000-8000-0026BB765291", 22 | "Status Tampered", 23 | StatusTamperedEnum.values(), 24 | Optional.of(getter), 25 | Optional.empty(), 26 | Optional.of(subscriber), 27 | Optional.of(unsubscriber)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/StatusTamperedEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Accessory is not tampered” 1 ”Accessory is tampered with” */ 9 | public enum StatusTamperedEnum implements CharacteristicEnum { 10 | NOT_TAMPERED(0), 11 | TAMPERED(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(StatusTamperedEnum.values()) 18 | .collect(Collectors.toMap(StatusTamperedEnum::getCode, t -> t)); 19 | } 20 | 21 | public static StatusTamperedEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | StatusTamperedEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/VersionCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.impl.base.StaticStringCharacteristic; 4 | import java.util.Optional; 5 | import java.util.concurrent.CompletableFuture; 6 | import java.util.function.Supplier; 7 | 8 | /** This characteristic describes HAP version. */ 9 | public class VersionCharacteristic extends StaticStringCharacteristic { 10 | 11 | public VersionCharacteristic(Supplier> getter) { 12 | super( 13 | "00000037-0000-1000-8000-0026BB765291", 14 | "HAP version", 15 | Optional.of(getter), 16 | Optional.empty(), 17 | Optional.empty()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/common/WaterLavelCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.common; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.FloatCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** This characteristic describes the water level. */ 12 | public class WaterLavelCharacteristic extends FloatCharacteristic 13 | implements EventableCharacteristic { 14 | 15 | public WaterLavelCharacteristic( 16 | Supplier> getter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "000000B5-0000-1000-8000-0026BB765291", 21 | "water level", 22 | 0, 23 | 100, 24 | 1, 25 | "%", 26 | Optional.of(getter), 27 | Optional.empty(), 28 | Optional.of(subscriber), 29 | Optional.of(unsubscriber)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/contactsensor/ContactSensorStateCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.contactsensor; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** 12 | * This characteristic describes the state of a door/window contact sensor. See {@link 13 | * ContactStateEnum} for possible values. 14 | */ 15 | public class ContactSensorStateCharacteristic extends EnumCharacteristic 16 | implements EventableCharacteristic { 17 | 18 | public ContactSensorStateCharacteristic( 19 | Supplier> getter, 20 | Consumer subscriber, 21 | Runnable unsubscriber) { 22 | super( 23 | "0000006A-0000-1000-8000-0026BB765291", 24 | "Contact Sensor", 25 | ContactStateEnum.values(), 26 | Optional.of(getter), 27 | Optional.empty(), 28 | Optional.of(subscriber), 29 | Optional.of(unsubscriber)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/contactsensor/ContactStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.contactsensor; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /* 9 | * 0 ”Contact is detected” 10 | * 1 ”Contact is not detected” 11 | */ 12 | public enum ContactStateEnum implements CharacteristicEnum { 13 | DETECTED(0), 14 | NOT_DETECTED(1); 15 | 16 | private static final Map reverse; 17 | 18 | static { 19 | reverse = 20 | Arrays.stream(ContactStateEnum.values()) 21 | .collect(Collectors.toMap(ContactStateEnum::getCode, t -> t)); 22 | } 23 | 24 | public static ContactStateEnum fromCode(Integer code) { 25 | return reverse.get(code); 26 | } 27 | 28 | private final int code; 29 | 30 | ContactStateEnum(int code) { 31 | this.code = code; 32 | } 33 | 34 | public int getCode() { 35 | return code; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/fan/CurrentFanStateCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.fan; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** 12 | * This characteristic describes the current state of the fan. See {@link CurrentFanStateEnum} for 13 | * possible values. 14 | */ 15 | public class CurrentFanStateCharacteristic extends EnumCharacteristic 16 | implements EventableCharacteristic { 17 | 18 | public CurrentFanStateCharacteristic( 19 | Supplier> getter, 20 | Consumer subscriber, 21 | Runnable unsubscriber) { 22 | super( 23 | "000000AF-0000-1000-8000-0026BB765291", 24 | "Current Fan State", 25 | CurrentFanStateEnum.values(), 26 | Optional.of(getter), 27 | Optional.empty(), 28 | Optional.of(subscriber), 29 | Optional.of(unsubscriber)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/fan/CurrentFanStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.fan; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | public enum CurrentFanStateEnum implements CharacteristicEnum { 9 | INACTIVE(0), 10 | IDLE(1), 11 | BLOWING_AIR(2); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(CurrentFanStateEnum.values()) 18 | .collect(Collectors.toMap(CurrentFanStateEnum::getCode, t -> t)); 19 | } 20 | 21 | public static CurrentFanStateEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | CurrentFanStateEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/fan/LockPhysicalControlsEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.fan; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Control lock disabled” 1 ”Control lock enabled” */ 9 | public enum LockPhysicalControlsEnum implements CharacteristicEnum { 10 | CONTROL_LOCK_DISABLED(0), 11 | CONTROL_LOCK_ENABLED(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(LockPhysicalControlsEnum.values()) 18 | .collect(Collectors.toMap(LockPhysicalControlsEnum::getCode, t -> t)); 19 | } 20 | 21 | public static LockPhysicalControlsEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | LockPhysicalControlsEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/fan/RotationDirectionEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.fan; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Clockwise” 1 ”Counter-clockwise” 2-255 ”Reserved” */ 9 | public enum RotationDirectionEnum implements CharacteristicEnum { 10 | CLOCKWISE(0), 11 | COUNTER_CLOCKWISE(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(RotationDirectionEnum.values()) 18 | .collect(Collectors.toMap(RotationDirectionEnum::getCode, t -> t)); 19 | } 20 | 21 | public static RotationDirectionEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | RotationDirectionEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/fan/SwingModeCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.fan; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.ExceptionalConsumer; 5 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 6 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 7 | import java.util.Optional; 8 | import java.util.concurrent.CompletableFuture; 9 | import java.util.function.Consumer; 10 | import java.util.function.Supplier; 11 | 12 | /** This characteristic describes if swing mode is enabled. */ 13 | public class SwingModeCharacteristic extends EnumCharacteristic 14 | implements EventableCharacteristic { 15 | 16 | public SwingModeCharacteristic( 17 | Supplier> getter, 18 | ExceptionalConsumer setter, 19 | Consumer subscriber, 20 | Runnable unsubscriber) { 21 | super( 22 | "000000B6-0000-1000-8000-0026BB765291", 23 | "Swing Mode", 24 | SwingModeEnum.values(), 25 | Optional.of(getter), 26 | Optional.of(setter), 27 | Optional.of(subscriber), 28 | Optional.of(unsubscriber)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/fan/SwingModeEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.fan; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Swing disabled” 1 ”Swing enabled” */ 9 | public enum SwingModeEnum implements CharacteristicEnum { 10 | SWING_DISABLED(0), 11 | SWING_ENABLED(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(SwingModeEnum.values()) 18 | .collect(Collectors.toMap(SwingModeEnum::getCode, t -> t)); 19 | } 20 | 21 | public static SwingModeEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | SwingModeEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/fan/TargetFanStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.fan; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Manual” 1 ”Auto” */ 9 | public enum TargetFanStateEnum implements CharacteristicEnum { 10 | MANUAL(0), 11 | AUTO(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(TargetFanStateEnum.values()) 18 | .collect(Collectors.toMap(TargetFanStateEnum::getCode, t -> t)); 19 | } 20 | 21 | public static TargetFanStateEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | TargetFanStateEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/filtermaintenance/FilterChangeIndicationCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.filtermaintenance; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | public class FilterChangeIndicationCharacteristic 12 | extends EnumCharacteristic implements EventableCharacteristic { 13 | 14 | public FilterChangeIndicationCharacteristic( 15 | Supplier> getter, 16 | Consumer subscriber, 17 | Runnable unsubscriber) { 18 | super( 19 | "000000AC-0000-1000-8000-0026BB765291", 20 | "filter change indication", 21 | FilterChangeIndicationEnum.values(), 22 | Optional.of(getter), 23 | Optional.empty(), 24 | Optional.of(subscriber), 25 | Optional.of(unsubscriber)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/filtermaintenance/FilterChangeIndicationEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.filtermaintenance; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | public enum FilterChangeIndicationEnum implements CharacteristicEnum { 9 | NO_CHANGE_NEEDED(0), 10 | CHANGE_NEEDED(1); 11 | 12 | private static final Map reverse; 13 | 14 | static { 15 | reverse = 16 | Arrays.stream(FilterChangeIndicationEnum.values()) 17 | .collect(Collectors.toMap(FilterChangeIndicationEnum::getCode, t -> t)); 18 | } 19 | 20 | public static FilterChangeIndicationEnum fromCode(Integer code) { 21 | return reverse.get(code); 22 | } 23 | 24 | private final int code; 25 | 26 | FilterChangeIndicationEnum(int code) { 27 | this.code = code; 28 | } 29 | 30 | @Override 31 | public int getCode() { 32 | return code; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/filtermaintenance/FilterLifeLevelCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.filtermaintenance; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.FloatCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | public class FilterLifeLevelCharacteristic extends FloatCharacteristic 12 | implements EventableCharacteristic { 13 | 14 | public FilterLifeLevelCharacteristic( 15 | Supplier> getter, 16 | Consumer subscriber, 17 | Runnable unsubscriber) { 18 | super( 19 | "000000AB-0000-1000-8000-0026BB765291", 20 | "Filter Life Level", 21 | 0, 22 | 100, 23 | 1, 24 | "%", 25 | Optional.of(getter), 26 | Optional.empty(), 27 | Optional.of(subscriber), 28 | Optional.of(unsubscriber)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/filtermaintenance/ResetFilterIndicationCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.filtermaintenance; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.impl.base.IntegerCharacteristic; 5 | import java.util.Optional; 6 | 7 | public class ResetFilterIndicationCharacteristic extends IntegerCharacteristic { 8 | 9 | public ResetFilterIndicationCharacteristic(ExceptionalConsumer setter) { 10 | super( 11 | "000000AD-0000-1000-8000-0026BB765291", 12 | "Reset Filter Indication", 13 | 1, 14 | 1, 15 | null, 16 | Optional.empty(), 17 | Optional.of(setter), 18 | Optional.empty(), 19 | Optional.empty()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/garagedoor/CurrentDoorStateCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.garagedoor; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** This characteristic describes the current state of a door. */ 12 | public class CurrentDoorStateCharacteristic extends EnumCharacteristic 13 | implements EventableCharacteristic { 14 | 15 | public CurrentDoorStateCharacteristic( 16 | Supplier> getter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "0000000E-0000-1000-8000-0026BB765291", 21 | "Current Door State", 22 | CurrentDoorStateEnum.values(), 23 | Optional.of(getter), 24 | Optional.empty(), 25 | Optional.of(subscriber), 26 | Optional.of(unsubscriber)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/garagedoor/CurrentDoorStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.garagedoor; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 9 | * 0 ”Open. The door is fully open.” 1 ”Closed. The door is fully closed.” 2 ”Opening. The door is 10 | * actively opening.” 3 ”Closing. The door is actively closing.” 4 ”Stopped. The door is not moving, 11 | * and it is not fully open nor fully closed.” 12 | */ 13 | public enum CurrentDoorStateEnum implements CharacteristicEnum { 14 | OPEN(0), 15 | CLOSED(1), 16 | OPENING(2), 17 | CLOSING(3), 18 | STOPPED(4); 19 | 20 | private static final Map reverse; 21 | 22 | static { 23 | reverse = 24 | Arrays.stream(CurrentDoorStateEnum.values()) 25 | .collect(Collectors.toMap(CurrentDoorStateEnum::getCode, t -> t)); 26 | } 27 | 28 | public static CurrentDoorStateEnum fromCode(Integer code) { 29 | return reverse.get(code); 30 | } 31 | 32 | private final int code; 33 | 34 | CurrentDoorStateEnum(int code) { 35 | this.code = code; 36 | } 37 | 38 | @Override 39 | public int getCode() { 40 | return code; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/garagedoor/TargetDoorStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.garagedoor; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Open” 1 ”Closed” 2-255 ”Reserved” */ 9 | public enum TargetDoorStateEnum implements CharacteristicEnum { 10 | OPEN(0), 11 | CLOSED(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(TargetDoorStateEnum.values()) 18 | .collect(Collectors.toMap(TargetDoorStateEnum::getCode, t -> t)); 19 | } 20 | 21 | public static TargetDoorStateEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | TargetDoorStateEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/heatercooler/CurrentHeaterCoolerStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.heatercooler; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Inactive” 1 ”Idle” 2 ”Heating” 3 ”Cooling” */ 9 | public enum CurrentHeaterCoolerStateEnum implements CharacteristicEnum { 10 | INACTIVE(0), 11 | IDLE(1), 12 | HEATING(2), 13 | COOLING(3); 14 | 15 | private static final Map reverse; 16 | 17 | static { 18 | reverse = 19 | Arrays.stream(CurrentHeaterCoolerStateEnum.values()) 20 | .collect(Collectors.toMap(CurrentHeaterCoolerStateEnum::getCode, t -> t)); 21 | } 22 | 23 | public static CurrentHeaterCoolerStateEnum fromCode(Integer code) { 24 | return reverse.get(code); 25 | } 26 | 27 | private final int code; 28 | 29 | CurrentHeaterCoolerStateEnum(int code) { 30 | this.code = code; 31 | } 32 | 33 | @Override 34 | public int getCode() { 35 | return code; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/heatercooler/TargetHeaterCoolerStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.heatercooler; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 AUTO - ”Heat or Cool” 1 ”Heat” 2 ”Cool” */ 9 | public enum TargetHeaterCoolerStateEnum implements CharacteristicEnum { 10 | AUTO(0), 11 | HEAT(1), 12 | COOL(2); 13 | 14 | private static final Map reverse; 15 | 16 | static { 17 | reverse = 18 | Arrays.stream(TargetHeaterCoolerStateEnum.values()) 19 | .collect(Collectors.toMap(TargetHeaterCoolerStateEnum::getCode, t -> t)); 20 | } 21 | 22 | public static TargetHeaterCoolerStateEnum fromCode(Integer code) { 23 | return reverse.get(code); 24 | } 25 | 26 | private final int code; 27 | 28 | TargetHeaterCoolerStateEnum(int code) { 29 | this.code = code; 30 | } 31 | 32 | @Override 33 | public int getCode() { 34 | return code; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/humidifier/CurrentHumidifierDehumidifierStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.humidifier; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Inactive” 1 ”Idle” 2 ”Humidifying” 3 ”Dehumidifying” */ 9 | public enum CurrentHumidifierDehumidifierStateEnum implements CharacteristicEnum { 10 | INACTIVE(0), 11 | IDLE(1), 12 | HUMIDIFYING(2), 13 | DEHUMIDIFYING(3); 14 | 15 | private static final Map reverse; 16 | 17 | static { 18 | reverse = 19 | Arrays.stream(CurrentHumidifierDehumidifierStateEnum.values()) 20 | .collect(Collectors.toMap(CurrentHumidifierDehumidifierStateEnum::getCode, t -> t)); 21 | } 22 | 23 | public static CurrentHumidifierDehumidifierStateEnum fromCode(Integer code) { 24 | return reverse.get(code); 25 | } 26 | 27 | private final int code; 28 | 29 | CurrentHumidifierDehumidifierStateEnum(int code) { 30 | this.code = code; 31 | } 32 | 33 | @Override 34 | public int getCode() { 35 | return code; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/humidifier/TargetHumidifierDehumidifierStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.humidifier; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 - Auto - ”Humidifier or Dehumidifier” 1 ”Humidifier” 2 ”Dehumidifier” */ 9 | public enum TargetHumidifierDehumidifierStateEnum implements CharacteristicEnum { 10 | AUTO(0), 11 | HUMIDIFIER(1), 12 | DEHUMIDIFIER(2); 13 | 14 | private static final Map reverse; 15 | 16 | static { 17 | reverse = 18 | Arrays.stream(TargetHumidifierDehumidifierStateEnum.values()) 19 | .collect(Collectors.toMap(TargetHumidifierDehumidifierStateEnum::getCode, t -> t)); 20 | } 21 | 22 | public static TargetHumidifierDehumidifierStateEnum fromCode(Integer code) { 23 | return reverse.get(code); 24 | } 25 | 26 | private final int code; 27 | 28 | TargetHumidifierDehumidifierStateEnum(int code) { 29 | this.code = code; 30 | } 31 | 32 | @Override 33 | public int getCode() { 34 | return code; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/humiditysensor/CurrentRelativeHumidityCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.humiditysensor; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.FloatCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** This characteristic describes the current relative humidity. */ 11 | public class CurrentRelativeHumidityCharacteristic extends FloatCharacteristic { 12 | 13 | public CurrentRelativeHumidityCharacteristic( 14 | Supplier> getter, 15 | Consumer subscriber, 16 | Runnable unsubscriber) { 17 | super( 18 | "00000010-0000-1000-8000-0026BB765291", 19 | "Current Relative Humidity", 20 | 0, 21 | 100, 22 | 1, 23 | "%", 24 | Optional.of(getter), 25 | Optional.empty(), 26 | Optional.of(subscriber), 27 | Optional.of(unsubscriber)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/humiditysensor/TargetRelativeHumidityCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.humiditysensor; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.FloatCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** This characteristic describes the target relative humidity. */ 12 | public class TargetRelativeHumidityCharacteristic extends FloatCharacteristic { 13 | 14 | public TargetRelativeHumidityCharacteristic( 15 | Supplier> getter, 16 | ExceptionalConsumer setter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "00000034-0000-1000-8000-0026BB765291", 21 | "Target Relative Humidity", 22 | 0, 23 | 100, 24 | 1, 25 | "%", 26 | Optional.of(getter), 27 | Optional.of(setter), 28 | Optional.of(subscriber), 29 | Optional.of(unsubscriber)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/inputsource/CurrentVisibilityStateCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.inputsource; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** This characteristic describes current visibility state. */ 11 | public class CurrentVisibilityStateCharacteristic 12 | extends EnumCharacteristic { 13 | 14 | public CurrentVisibilityStateCharacteristic( 15 | Supplier> getter, 16 | Consumer subscriber, 17 | Runnable unsubscriber) { 18 | super( 19 | "00000135-0000-1000-8000-0026BB765291", 20 | "current visibility state", 21 | CurrentVisibilityStateEnum.values(), 22 | Optional.of(getter), 23 | Optional.empty(), 24 | Optional.of(subscriber), 25 | Optional.of(unsubscriber)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/inputsource/CurrentVisibilityStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.inputsource; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | public enum CurrentVisibilityStateEnum implements CharacteristicEnum { 9 | SHOWN(0), 10 | HIDDEN(1), 11 | UNKNOWN_1(2), 12 | UNKNOWN_2(3); 13 | 14 | private static final Map reverse; 15 | 16 | static { 17 | reverse = 18 | Arrays.stream(CurrentVisibilityStateEnum.values()) 19 | .collect(Collectors.toMap(CurrentVisibilityStateEnum::getCode, t -> t)); 20 | } 21 | 22 | public static CurrentVisibilityStateEnum fromCode(Integer code) { 23 | return reverse.get(code); 24 | } 25 | 26 | private final int code; 27 | 28 | CurrentVisibilityStateEnum(int code) { 29 | this.code = code; 30 | } 31 | 32 | @Override 33 | public int getCode() { 34 | return code; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/inputsource/InputDeviceTypeCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.inputsource; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** This characteristic describes input device type. */ 11 | public class InputDeviceTypeCharacteristic extends EnumCharacteristic { 12 | 13 | public InputDeviceTypeCharacteristic( 14 | Supplier> getter, 15 | Consumer subscriber, 16 | Runnable unsubscriber) { 17 | super( 18 | "000000DC-0000-1000-8000-0026BB765291", 19 | "input device type", 20 | InputDeviceTypeEnum.values(), 21 | Optional.of(getter), 22 | Optional.empty(), 23 | Optional.of(subscriber), 24 | Optional.of(unsubscriber)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/inputsource/InputDeviceTypeEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.inputsource; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | public enum InputDeviceTypeEnum implements CharacteristicEnum { 9 | OTHER(0), 10 | TV(1), 11 | RECORDING(2), 12 | TUNER(3), 13 | PLAYBACK(4), 14 | AUDIO_SYSTEM(5); 15 | 16 | private static final Map reverse; 17 | 18 | static { 19 | reverse = 20 | Arrays.stream(InputDeviceTypeEnum.values()) 21 | .collect(Collectors.toMap(InputDeviceTypeEnum::getCode, t -> t)); 22 | } 23 | 24 | public static InputDeviceTypeEnum fromCode(Integer code) { 25 | return reverse.get(code); 26 | } 27 | 28 | private final int code; 29 | 30 | InputDeviceTypeEnum(int code) { 31 | this.code = code; 32 | } 33 | 34 | @Override 35 | public int getCode() { 36 | return code; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/inputsource/InputSourceTypeCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.inputsource; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** This characteristic describes input source type. */ 11 | public class InputSourceTypeCharacteristic extends EnumCharacteristic { 12 | 13 | public InputSourceTypeCharacteristic( 14 | Supplier> getter, 15 | Consumer subscriber, 16 | Runnable unsubscriber) { 17 | super( 18 | "000000DB-0000-1000-8000-0026BB765291", 19 | "input source type", 20 | InputSourceTypeEnum.values(), 21 | Optional.of(getter), 22 | Optional.empty(), 23 | Optional.of(subscriber), 24 | Optional.of(unsubscriber)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/inputsource/InputSourceTypeEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.inputsource; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | public enum InputSourceTypeEnum implements CharacteristicEnum { 9 | OTHER(0), 10 | HOME_SCREEN(1), 11 | TUNER(2), 12 | HDMI(3), 13 | COMPOSITE_VIDEO(4), 14 | S_VIDEO(5), 15 | COMPONENT_VIDEO(6), 16 | DVI(7), 17 | AIRPLAY(8), 18 | USB(9), 19 | APPLICATION(10); 20 | 21 | private static final Map reverse; 22 | 23 | static { 24 | reverse = 25 | Arrays.stream(InputSourceTypeEnum.values()) 26 | .collect(Collectors.toMap(InputSourceTypeEnum::getCode, t -> t)); 27 | } 28 | 29 | public static InputSourceTypeEnum fromCode(Integer code) { 30 | return reverse.get(code); 31 | } 32 | 33 | private final int code; 34 | 35 | InputSourceTypeEnum(int code) { 36 | this.code = code; 37 | } 38 | 39 | @Override 40 | public int getCode() { 41 | return code; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/inputsource/TargetVisibilityStateCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.inputsource; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** This characteristic describes target visibility state. */ 12 | public class TargetVisibilityStateCharacteristic 13 | extends EnumCharacteristic { 14 | 15 | public TargetVisibilityStateCharacteristic( 16 | Supplier> getter, 17 | ExceptionalConsumer setter, 18 | Consumer subscriber, 19 | Runnable unsubscriber) { 20 | super( 21 | "00000134-0000-1000-8000-0026BB765291", 22 | "target visibility state", 23 | TargetVisibilityStateEnum.values(), 24 | Optional.of(getter), 25 | Optional.of(setter), 26 | Optional.of(subscriber), 27 | Optional.of(unsubscriber)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/inputsource/TargetVisibilityStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.inputsource; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | public enum TargetVisibilityStateEnum implements CharacteristicEnum { 9 | SHOWN(0), 10 | HIDDEN(1); 11 | 12 | private static final Map reverse; 13 | 14 | static { 15 | reverse = 16 | Arrays.stream(TargetVisibilityStateEnum.values()) 17 | .collect(Collectors.toMap(TargetVisibilityStateEnum::getCode, t -> t)); 18 | } 19 | 20 | public static TargetVisibilityStateEnum fromCode(Integer code) { 21 | return reverse.get(code); 22 | } 23 | 24 | private final int code; 25 | 26 | TargetVisibilityStateEnum(int code) { 27 | this.code = code; 28 | } 29 | 30 | @Override 31 | public int getCode() { 32 | return code; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/leaksensor/LeakDetectedStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.leaksensor; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Leak is not detected” 1 ”Leak is detected” */ 9 | public enum LeakDetectedStateEnum implements CharacteristicEnum { 10 | LEAK_NOT_DETECTED(0), 11 | LEAK_DETECTED(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(LeakDetectedStateEnum.values()) 18 | .collect(Collectors.toMap(LeakDetectedStateEnum::getCode, t -> t)); 19 | } 20 | 21 | public static LeakDetectedStateEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | LeakDetectedStateEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/lightbulb/HueCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.lightbulb; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.FloatCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** This characteristic describes hue or color. */ 12 | public class HueCharacteristic extends FloatCharacteristic { 13 | public HueCharacteristic( 14 | Supplier> getter, 15 | ExceptionalConsumer setter, 16 | Consumer subscriber, 17 | Runnable unsubscriber) { 18 | super( 19 | "00000013-0000-1000-8000-0026BB765291", 20 | "hue or color", 21 | 0, 22 | 360, 23 | 1, 24 | "arcdegrees", 25 | Optional.of(getter), 26 | Optional.of(setter), 27 | Optional.of(subscriber), 28 | Optional.of(unsubscriber)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/lightbulb/SaturationCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.lightbulb; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.ExceptionalConsumer; 5 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 6 | import io.github.hapjava.characteristics.impl.base.FloatCharacteristic; 7 | import java.util.Optional; 8 | import java.util.concurrent.CompletableFuture; 9 | import java.util.function.Consumer; 10 | import java.util.function.Supplier; 11 | 12 | /** This characteristic describes color saturation. */ 13 | public class SaturationCharacteristic extends FloatCharacteristic 14 | implements EventableCharacteristic { 15 | 16 | public SaturationCharacteristic( 17 | Supplier> getter, 18 | ExceptionalConsumer setter, 19 | Consumer subscriber, 20 | Runnable unsubscriber) { 21 | super( 22 | "0000002F-0000-1000-8000-0026BB765291", 23 | "color saturation", 24 | 0, 25 | 100, 26 | 1, 27 | "%", 28 | Optional.of(getter), 29 | Optional.of(setter), 30 | Optional.of(subscriber), 31 | Optional.of(unsubscriber)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/lock/LockCurrentStateCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.lock; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** The current state of the physical security mechanism (e.g. deadbolt). */ 11 | public class LockCurrentStateCharacteristic extends EnumCharacteristic { 12 | 13 | public LockCurrentStateCharacteristic( 14 | Supplier> getter, 15 | Consumer subscriber, 16 | Runnable unsubscriber) { 17 | super( 18 | "0000001D-0000-1000-8000-0026BB765291", 19 | "Current Lock State", 20 | LockCurrentStateEnum.values(), 21 | Optional.of(getter), 22 | Optional.empty(), 23 | Optional.of(subscriber), 24 | Optional.of(unsubscriber)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/lock/LockCurrentStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.lock; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Unsecured” 1 ”Secured” 2 ”Jammed” 3 ”Unknown” 4-255 ”Reserved” */ 9 | public enum LockCurrentStateEnum implements CharacteristicEnum { 10 | UNSECURED(0), 11 | SECURED(1), 12 | JAMMED(2), 13 | UNKNOWN(3); 14 | 15 | private static final Map reverse; 16 | 17 | static { 18 | reverse = 19 | Arrays.stream(LockCurrentStateEnum.values()) 20 | .collect(Collectors.toMap(LockCurrentStateEnum::getCode, t -> t)); 21 | } 22 | 23 | public static LockCurrentStateEnum fromCode(Integer code) { 24 | return reverse.get(code); 25 | } 26 | 27 | private final int code; 28 | 29 | LockCurrentStateEnum(int code) { 30 | this.code = code; 31 | } 32 | 33 | @Override 34 | public int getCode() { 35 | return code; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/lock/LockTargetStateCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.lock; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** The target state of the physical security mechanism (e.g. deadbolt). */ 12 | public class LockTargetStateCharacteristic extends EnumCharacteristic { 13 | 14 | public LockTargetStateCharacteristic( 15 | Supplier> getter, 16 | ExceptionalConsumer setter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "0000001E-0000-1000-8000-0026BB765291", 21 | "Target Lock State", 22 | LockTargetStateEnum.values(), 23 | Optional.of(getter), 24 | Optional.of(setter), 25 | Optional.of(subscriber), 26 | Optional.of(unsubscriber)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/lock/LockTargetStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.lock; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Unsecured” 1 ”Secured” 4-255 ”Reserved” */ 9 | public enum LockTargetStateEnum implements CharacteristicEnum { 10 | UNSECURED(0), 11 | SECURED(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(LockTargetStateEnum.values()) 18 | .collect(Collectors.toMap(LockTargetStateEnum::getCode, t -> t)); 19 | } 20 | 21 | public static LockTargetStateEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | LockTargetStateEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/motionsensor/MotionDetectedCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.motionsensor; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.BooleanCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** This characteristic indicates if motion (e.g. a person moving) was detected. */ 11 | public class MotionDetectedCharacteristic extends BooleanCharacteristic { 12 | 13 | public MotionDetectedCharacteristic( 14 | Supplier> getter, 15 | Consumer subscriber, 16 | Runnable unsubscriber) { 17 | super( 18 | "00000022-0000-1000-8000-0026BB765291", 19 | "Motion detection", 20 | Optional.of(getter), 21 | Optional.empty(), 22 | Optional.of(subscriber), 23 | Optional.of(unsubscriber)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/occupancysensor/OccupancyDetectedCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.occupancysensor; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** This characteristic indicates if occupancy was detected (e.g. a person present). */ 11 | public class OccupancyDetectedCharacteristic extends EnumCharacteristic { 12 | 13 | public OccupancyDetectedCharacteristic( 14 | Supplier> getter, 15 | Consumer subscriber, 16 | Runnable unsubscriber) { 17 | super( 18 | "00000071-0000-1000-8000-0026BB765291", 19 | "Occupancy Detected", 20 | OccupancyDetectedEnum.values(), 21 | Optional.of(getter), 22 | Optional.empty(), 23 | Optional.of(subscriber), 24 | Optional.of(unsubscriber)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/occupancysensor/OccupancyDetectedEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.occupancysensor; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Occupancy is not detected” 1 ”Occupancy is detected” */ 9 | public enum OccupancyDetectedEnum implements CharacteristicEnum { 10 | NOT_DETECTED(0), 11 | DETECTED(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(OccupancyDetectedEnum.values()) 18 | .collect(Collectors.toMap(OccupancyDetectedEnum::getCode, t -> t)); 19 | } 20 | 21 | public static OccupancyDetectedEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | OccupancyDetectedEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/outlet/OutletInUseCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.outlet; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.BooleanCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * This characteristic describes if the power outlet has an appliance physically plugged in. This 12 | * characteristic is set to True even if the plugged-in appliance is off. 13 | */ 14 | public class OutletInUseCharacteristic extends BooleanCharacteristic { 15 | 16 | public OutletInUseCharacteristic( 17 | Supplier> getter, 18 | Consumer subscriber, 19 | Runnable unsubscriber) { 20 | super( 21 | "00000026-0000-1000-8000-0026BB765291", 22 | "Outlet in Use", 23 | Optional.of(getter), 24 | Optional.empty(), 25 | Optional.of(subscriber), 26 | Optional.of(unsubscriber)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/securitysystem/CurrentSecuritySystemStateCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.securitysystem; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** This characteristic describes the state of a security system */ 11 | public class CurrentSecuritySystemStateCharacteristic 12 | extends EnumCharacteristic { 13 | 14 | public CurrentSecuritySystemStateCharacteristic( 15 | CurrentSecuritySystemStateEnum[] validValues, 16 | Supplier> getter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "00000066-0000-1000-8000-0026BB765291", 21 | "Current Security System State", 22 | validValues, 23 | Optional.of(getter), 24 | Optional.empty(), 25 | Optional.of(subscriber), 26 | Optional.of(unsubscriber)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/securitysystem/SecuritySystemAlarmTypeCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.securitysystem; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * This characteristic describes the type of alarm triggered by a security system. See {@link 12 | * SecuritySystemAlarmTypeEnum} for possible values. 13 | */ 14 | public class SecuritySystemAlarmTypeCharacteristic 15 | extends EnumCharacteristic { 16 | 17 | public SecuritySystemAlarmTypeCharacteristic( 18 | Supplier> getter, 19 | Consumer subscriber, 20 | Runnable unsubscriber) { 21 | super( 22 | "0000008E-0000-1000-8000-0026BB765291", 23 | "Alert Type", 24 | SecuritySystemAlarmTypeEnum.values(), 25 | Optional.of(getter), 26 | Optional.empty(), 27 | Optional.of(subscriber), 28 | Optional.of(unsubscriber)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/slat/CurrentSlatStateCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.slat; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** This characteristic describes the current state of the slats. */ 11 | public class CurrentSlatStateCharacteristic extends EnumCharacteristic { 12 | 13 | public CurrentSlatStateCharacteristic( 14 | Supplier> getter, 15 | Consumer subscriber, 16 | Runnable unsubscriber) { 17 | super( 18 | "000000AA-0000-1000-8000-0026BB765291", 19 | "current slat state", 20 | CurrentSlatStateEnum.values(), 21 | Optional.of(getter), 22 | Optional.empty(), 23 | Optional.of(subscriber), 24 | Optional.of(unsubscriber)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/slat/CurrentSlatStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.slat; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Fixed” 1 ”Jammed” 2 ”Swinging” */ 9 | public enum CurrentSlatStateEnum implements CharacteristicEnum { 10 | FIXED(0), 11 | JAMMED(1), 12 | SWINGING(2); 13 | 14 | private static final Map reverse; 15 | 16 | static { 17 | reverse = 18 | Arrays.stream(CurrentSlatStateEnum.values()) 19 | .collect(Collectors.toMap(CurrentSlatStateEnum::getCode, t -> t)); 20 | } 21 | 22 | public static CurrentSlatStateEnum fromCode(Integer code) { 23 | return reverse.get(code); 24 | } 25 | 26 | private final int code; 27 | 28 | CurrentSlatStateEnum(int code) { 29 | this.code = code; 30 | } 31 | 32 | @Override 33 | public int getCode() { 34 | return code; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/slat/CurrentTiltAngleCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.slat; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.IntegerCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** This characteristic describe current tilt angle (between -90 and 90) */ 12 | public class CurrentTiltAngleCharacteristic extends IntegerCharacteristic 13 | implements EventableCharacteristic { 14 | 15 | public CurrentTiltAngleCharacteristic( 16 | Supplier> getter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "000000C1-0000-1000-8000-0026BB765291", 21 | "current tilt angle", 22 | -90, 23 | 90, 24 | "arcdegrees", 25 | Optional.of(getter), 26 | Optional.empty(), 27 | Optional.of(subscriber), 28 | Optional.of(unsubscriber)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/slat/SlatTypeCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.slat; 2 | 3 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 4 | import java.util.Optional; 5 | import java.util.concurrent.CompletableFuture; 6 | import java.util.function.Supplier; 7 | 8 | /** 9 | * This characteristic describes the type of the slats. See {@link SlatTypeEnum} for possible values 10 | */ 11 | public class SlatTypeCharacteristic extends EnumCharacteristic { 12 | 13 | public SlatTypeCharacteristic(Supplier> getter) { 14 | super( 15 | "000000C0-0000-1000-8000-0026BB765291", 16 | "slat type", 17 | SlatTypeEnum.values(), 18 | Optional.of(getter), 19 | Optional.empty(), 20 | Optional.empty(), 21 | Optional.empty()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/slat/SlatTypeEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.slat; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Horizontal” 1 ”Vertical” */ 9 | public enum SlatTypeEnum implements CharacteristicEnum { 10 | HORIZONTAL(0), 11 | VERTICAL(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(SlatTypeEnum.values()) 18 | .collect(Collectors.toMap(SlatTypeEnum::getCode, t -> t)); 19 | } 20 | 21 | public static SlatTypeEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | SlatTypeEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/smokesensor/SmokeDetectedCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.smokesensor; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** This characteristic indicates if a sensor detects smoke. */ 11 | public class SmokeDetectedCharacteristic extends EnumCharacteristic { 12 | 13 | public SmokeDetectedCharacteristic( 14 | Supplier> getter, 15 | Consumer subscriber, 16 | Runnable unsubscriber) { 17 | super( 18 | "00000076-0000-1000-8000-0026BB765291", 19 | "Smoke Detected", 20 | SmokeDetectedStateEnum.values(), 21 | Optional.of(getter), 22 | Optional.empty(), 23 | Optional.of(subscriber), 24 | Optional.of(unsubscriber)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/smokesensor/SmokeDetectedStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.smokesensor; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Smoke is not detected” 1 ”Smoke is detected” */ 9 | public enum SmokeDetectedStateEnum implements CharacteristicEnum { 10 | NOT_DETECTED(0), 11 | DETECTED(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(SmokeDetectedStateEnum.values()) 18 | .collect(Collectors.toMap(SmokeDetectedStateEnum::getCode, t -> t)); 19 | } 20 | 21 | public static SmokeDetectedStateEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | SmokeDetectedStateEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | public int getCode() { 32 | return code; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/television/ClosedCaptionsCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.television; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** 12 | * Characteristic indicates whether the service provides closed captions. See {@link 13 | * ClosedCaptionsEnum} for possible values. 14 | */ 15 | public class ClosedCaptionsCharacteristic extends EnumCharacteristic { 16 | 17 | public ClosedCaptionsCharacteristic( 18 | Supplier> getter, 19 | ExceptionalConsumer setter, 20 | Consumer subscriber, 21 | Runnable unsubscriber) { 22 | super( 23 | "000000DD-0000-1000-8000-0026BB765291", 24 | "closed captions", 25 | ClosedCaptionsEnum.values(), 26 | Optional.of(getter), 27 | Optional.of(setter), 28 | Optional.of(subscriber), 29 | Optional.of(unsubscriber)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/television/ClosedCaptionsEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.television; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Disabled” 1 ”Enabled” 2-255 ”Reserved” */ 9 | public enum ClosedCaptionsEnum implements CharacteristicEnum { 10 | DISABLED(0), 11 | ENABLED(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(ClosedCaptionsEnum.values()) 18 | .collect(Collectors.toMap(ClosedCaptionsEnum::getCode, t -> t)); 19 | } 20 | 21 | public static ClosedCaptionsEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | ClosedCaptionsEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/television/CurrentMediaStateCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.television; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * This characteristic indicates current media state. See {@link CurrentMediaStateEnum} for possible 12 | * values. 13 | */ 14 | public class CurrentMediaStateCharacteristic extends EnumCharacteristic { 15 | public CurrentMediaStateCharacteristic( 16 | Supplier> getter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "000000E0-0000-1000-8000-0026BB765291", 21 | "current media state", 22 | CurrentMediaStateEnum.values(), 23 | Optional.of(getter), 24 | Optional.empty(), 25 | Optional.of(subscriber), 26 | Optional.of(unsubscriber)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/television/CurrentMediaStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.television; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Play” 1 ”Pause” 2 "Stop" 3 "Unknown" 4-255 ”Reserved” */ 9 | public enum CurrentMediaStateEnum implements CharacteristicEnum { 10 | PLAY(0), 11 | PAUSE(1), 12 | STOP(2), 13 | UNKNOWN(3); 14 | 15 | private static final Map reverse; 16 | 17 | static { 18 | reverse = 19 | Arrays.stream(CurrentMediaStateEnum.values()) 20 | .collect(Collectors.toMap(CurrentMediaStateEnum::getCode, t -> t)); 21 | } 22 | 23 | public static CurrentMediaStateEnum fromCode(Integer code) { 24 | return reverse.get(code); 25 | } 26 | 27 | private final int code; 28 | 29 | CurrentMediaStateEnum(int code) { 30 | this.code = code; 31 | } 32 | 33 | @Override 34 | public int getCode() { 35 | return code; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/television/PictureModeCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.television; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** 12 | * This characteristic retrieves / sets picture mode. See {@link PictureModeEnum} for possible 13 | * values. 14 | */ 15 | public class PictureModeCharacteristic extends EnumCharacteristic { 16 | public PictureModeCharacteristic( 17 | Supplier> getter, 18 | ExceptionalConsumer setter, 19 | Consumer subscriber, 20 | Runnable unsubscriber) { 21 | super( 22 | "000000E2-0000-1000-8000-0026BB765291", 23 | "picture mode", 24 | PictureModeEnum.values(), 25 | Optional.of(getter), 26 | Optional.of(setter), 27 | Optional.of(subscriber), 28 | Optional.of(unsubscriber)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/television/PictureModeEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.television; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 9 | * 0 ”Other” 1 ”Standard” 2 "Calibrated" 3 "CalibratedDark" 4 "Vivid" 5 "Game" 6 "Computer" 7 10 | * "Custom" 8-255 ”Reserved” 11 | */ 12 | public enum PictureModeEnum implements CharacteristicEnum { 13 | OTHER(0), 14 | STANDARD(1), 15 | CALIBRATED(2), 16 | CALIBRATED_DARK(3), 17 | VIVID(4), 18 | GAME(5), 19 | COMPUTER(6), 20 | CUSTOM(7); 21 | 22 | private static final Map reverse; 23 | 24 | static { 25 | reverse = 26 | Arrays.stream(PictureModeEnum.values()) 27 | .collect(Collectors.toMap(PictureModeEnum::getCode, t -> t)); 28 | } 29 | 30 | public static PictureModeEnum fromCode(Integer code) { 31 | return reverse.get(code); 32 | } 33 | 34 | private final int code; 35 | 36 | PictureModeEnum(int code) { 37 | this.code = code; 38 | } 39 | 40 | @Override 41 | public int getCode() { 42 | return code; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/television/PowerModeCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.television; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | 7 | /** characteristic sets power mode. See {@link PowerModeEnum} for possible values. */ 8 | public class PowerModeCharacteristic extends EnumCharacteristic { 9 | 10 | public PowerModeCharacteristic(ExceptionalConsumer setter) { 11 | super( 12 | "000000DF-0000-1000-8000-0026BB765291", 13 | "power mode selection", 14 | PowerModeEnum.values(), 15 | Optional.empty(), 16 | Optional.of(setter), 17 | Optional.empty(), 18 | Optional.empty()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/television/PowerModeEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.television; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Show” 1 ”Hide” 2-255 ”Reserved” */ 9 | public enum PowerModeEnum implements CharacteristicEnum { 10 | SHOW(0), 11 | HIDE(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(PowerModeEnum.values()) 18 | .collect(Collectors.toMap(PowerModeEnum::getCode, t -> t)); 19 | } 20 | 21 | public static PowerModeEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | PowerModeEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/television/RemoteKeyCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.television; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | 7 | /** 8 | * This characteristic sends information about pressed key on tv remote. See {@link RemoteKeyEnum} 9 | * for possible values. 10 | */ 11 | public class RemoteKeyCharacteristic extends EnumCharacteristic { 12 | public RemoteKeyCharacteristic(ExceptionalConsumer setter) { 13 | super( 14 | "000000E1-0000-1000-8000-0026BB765291", 15 | "remote key", 16 | RemoteKeyEnum.values(), 17 | Optional.empty(), 18 | Optional.of(setter), 19 | Optional.empty(), 20 | Optional.empty()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/television/RemoteKeyEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.television; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | public enum RemoteKeyEnum implements CharacteristicEnum { 9 | REWIND(0), 10 | FAST_FORWARD(1), 11 | NEXT_TRACK(2), 12 | PREV_TRACK(3), 13 | ARROW_UP(4), 14 | ARROW_DOWN(5), 15 | ARROW_LEFT(6), 16 | ARROW_RIGHT(7), 17 | SELECT(8), 18 | BACK(9), 19 | EXIT(10), 20 | PLAY_PAUSE(11), 21 | INFO(15); 22 | 23 | private static final Map reverse; 24 | 25 | static { 26 | reverse = 27 | Arrays.stream(RemoteKeyEnum.values()) 28 | .collect(Collectors.toMap(RemoteKeyEnum::getCode, t -> t)); 29 | } 30 | 31 | public static RemoteKeyEnum fromCode(Integer code) { 32 | return reverse.get(code); 33 | } 34 | 35 | private final int code; 36 | 37 | RemoteKeyEnum(int code) { 38 | this.code = code; 39 | } 40 | 41 | @Override 42 | public int getCode() { 43 | return code; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/television/SleepDiscoveryModeCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.television; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * This characteristic indicates whether the service can be discovered. See {@link 12 | * SleepDiscoveryModeEnum} for possible values. 13 | */ 14 | public class SleepDiscoveryModeCharacteristic extends EnumCharacteristic { 15 | public SleepDiscoveryModeCharacteristic( 16 | Supplier> getter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "000000E8-0000-1000-8000-0026BB765291", 21 | "sleep discovery mode", 22 | SleepDiscoveryModeEnum.values(), 23 | Optional.of(getter), 24 | Optional.empty(), 25 | Optional.of(subscriber), 26 | Optional.of(unsubscriber)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/television/SleepDiscoveryModeEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.television; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Not discoverable” 1 ”Always discoverable” 2-255 ”Reserved” */ 9 | public enum SleepDiscoveryModeEnum implements CharacteristicEnum { 10 | NOT_DISCOVERABLE(0), 11 | ALWAYS_DISCOVERABLE(1); 12 | 13 | private static final Map reverse; 14 | 15 | static { 16 | reverse = 17 | Arrays.stream(SleepDiscoveryModeEnum.values()) 18 | .collect(Collectors.toMap(SleepDiscoveryModeEnum::getCode, t -> t)); 19 | } 20 | 21 | public static SleepDiscoveryModeEnum fromCode(Integer code) { 22 | return reverse.get(code); 23 | } 24 | 25 | private final int code; 26 | 27 | SleepDiscoveryModeEnum(int code) { 28 | this.code = code; 29 | } 30 | 31 | @Override 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/television/TargetMediaStateCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.television; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** This characteristic sets media state. See {@link TargetMediaStateEnum} for possible values. */ 12 | public class TargetMediaStateCharacteristic extends EnumCharacteristic { 13 | public TargetMediaStateCharacteristic( 14 | Supplier> getter, 15 | ExceptionalConsumer setter, 16 | Consumer subscriber, 17 | Runnable unsubscriber) { 18 | super( 19 | "00000137-0000-1000-8000-0026BB765291", 20 | "current media state", 21 | TargetMediaStateEnum.values(), 22 | Optional.of(getter), 23 | Optional.of(setter), 24 | Optional.of(subscriber), 25 | Optional.of(unsubscriber)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/television/TargetMediaStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.television; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Play” 1 ”Pause” 2 "Stop" 3-255 ”Reserved” */ 9 | public enum TargetMediaStateEnum implements CharacteristicEnum { 10 | PLAY(0), 11 | PAUSE(1), 12 | STOP(2); 13 | 14 | private static final Map reverse; 15 | 16 | static { 17 | reverse = 18 | Arrays.stream(TargetMediaStateEnum.values()) 19 | .collect(Collectors.toMap(TargetMediaStateEnum::getCode, t -> t)); 20 | } 21 | 22 | public static TargetMediaStateEnum fromCode(Integer code) { 23 | return reverse.get(code); 24 | } 25 | 26 | private final int code; 27 | 28 | TargetMediaStateEnum(int code) { 29 | this.code = code; 30 | } 31 | 32 | @Override 33 | public int getCode() { 34 | return code; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/televisionspeaker/VolumeControlTypeCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.televisionspeaker; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * This characteristic indicates volume control type. See {@link VolumeControlTypeEnum} for possible 12 | * values. 13 | */ 14 | public class VolumeControlTypeCharacteristic extends EnumCharacteristic { 15 | public VolumeControlTypeCharacteristic( 16 | Supplier> getter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "000000E9-0000-1000-8000-0026BB765291", 21 | "volume control type", 22 | VolumeControlTypeEnum.values(), 23 | Optional.of(getter), 24 | Optional.empty(), 25 | Optional.of(subscriber), 26 | Optional.of(unsubscriber)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/televisionspeaker/VolumeControlTypeEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.televisionspeaker; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | public enum VolumeControlTypeEnum implements CharacteristicEnum { 9 | NONE(0), 10 | RELATIVE(1), 11 | RELATIVE_WITH_CURRENT(2), 12 | ABSOLUTE(3); 13 | 14 | private static final Map reverse; 15 | 16 | static { 17 | reverse = 18 | Arrays.stream(VolumeControlTypeEnum.values()) 19 | .collect(Collectors.toMap(VolumeControlTypeEnum::getCode, t -> t)); 20 | } 21 | 22 | public static VolumeControlTypeEnum fromCode(Integer code) { 23 | return reverse.get(code); 24 | } 25 | 26 | private final int code; 27 | 28 | VolumeControlTypeEnum(int code) { 29 | this.code = code; 30 | } 31 | 32 | @Override 33 | public int getCode() { 34 | return code; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/televisionspeaker/VolumeSelectorCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.televisionspeaker; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | 7 | /** 8 | * This characteristic sends information about volume changes. See {@link VolumeSelectorEnum} for 9 | * possible values. 10 | */ 11 | public class VolumeSelectorCharacteristic extends EnumCharacteristic { 12 | public VolumeSelectorCharacteristic(ExceptionalConsumer setter) { 13 | super( 14 | "000000EA-0000-1000-8000-0026BB765291", 15 | "volume selector", 16 | VolumeSelectorEnum.values(), 17 | Optional.empty(), 18 | Optional.of(setter), 19 | Optional.empty(), 20 | Optional.empty()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/televisionspeaker/VolumeSelectorEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.televisionspeaker; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | public enum VolumeSelectorEnum implements CharacteristicEnum { 9 | INCREMENT(0), 10 | DECREMENT(1); 11 | 12 | private static final Map reverse; 13 | 14 | static { 15 | reverse = 16 | Arrays.stream(VolumeSelectorEnum.values()) 17 | .collect(Collectors.toMap(VolumeSelectorEnum::getCode, t -> t)); 18 | } 19 | 20 | public static VolumeSelectorEnum fromCode(Integer code) { 21 | return reverse.get(code); 22 | } 23 | 24 | private final int code; 25 | 26 | VolumeSelectorEnum(int code) { 27 | this.code = code; 28 | } 29 | 30 | @Override 31 | public int getCode() { 32 | return code; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/thermostat/CurrentHeatingCoolingStateCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.thermostat; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * This characteristic describes the current mode of an accessory that supports cooling or heating 12 | */ 13 | public class CurrentHeatingCoolingStateCharacteristic 14 | extends EnumCharacteristic { 15 | 16 | public CurrentHeatingCoolingStateCharacteristic( 17 | CurrentHeatingCoolingStateEnum[] validValues, 18 | Supplier> getter, 19 | Consumer subscriber, 20 | Runnable unsubscriber) { 21 | super( 22 | "0000000F-0000-1000-8000-0026BB765291", 23 | "Current heating cooling mode", 24 | validValues, 25 | Optional.of(getter), 26 | Optional.empty(), 27 | Optional.of(subscriber), 28 | Optional.of(unsubscriber)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/thermostat/CurrentHeatingCoolingStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.thermostat; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 0 ”Off.” 1 ”Heat. The Heater is currently on.” 2 ”Cool. Cooler is currently on.” */ 9 | public enum CurrentHeatingCoolingStateEnum implements CharacteristicEnum { 10 | OFF(0), 11 | HEAT(1), 12 | COOL(2); 13 | 14 | private static final Map reverse; 15 | 16 | static { 17 | reverse = 18 | Arrays.stream(CurrentHeatingCoolingStateEnum.values()) 19 | .collect(Collectors.toMap(CurrentHeatingCoolingStateEnum::getCode, t -> t)); 20 | } 21 | 22 | public static CurrentHeatingCoolingStateEnum fromCode(Integer code) { 23 | return reverse.get(code); 24 | } 25 | 26 | private final int code; 27 | 28 | CurrentHeatingCoolingStateEnum(int code) { 29 | this.code = code; 30 | } 31 | 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/thermostat/TargetHeatingCoolingStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.thermostat; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 9 | * 0 ”Off” 1 ”Heat.” 2 ”Cool." 3 ”Auto. Turn on heating or cooling to maintain depending on the 10 | * temperature” 11 | * 12 | * @author Andy Lintner 13 | */ 14 | public enum TargetHeatingCoolingStateEnum implements CharacteristicEnum { 15 | OFF(0), 16 | HEAT(1), 17 | COOL(2), 18 | AUTO(3); 19 | 20 | private static final Map reverse; 21 | 22 | static { 23 | reverse = 24 | Arrays.stream(TargetHeatingCoolingStateEnum.values()) 25 | .collect(Collectors.toMap(t -> t.getCode(), t -> t)); 26 | } 27 | 28 | public static TargetHeatingCoolingStateEnum fromCode(Integer code) { 29 | return reverse.get(code); 30 | } 31 | 32 | private final int code; 33 | 34 | private TargetHeatingCoolingStateEnum(int code) { 35 | this.code = code; 36 | } 37 | 38 | public int getCode() { 39 | return code; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/thermostat/TemperatureDisplayUnitEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.thermostat; 2 | 3 | import io.github.hapjava.accessories.TemperatureSensorAccessory; 4 | import io.github.hapjava.characteristics.CharacteristicEnum; 5 | import java.util.Arrays; 6 | import java.util.Map; 7 | import java.util.stream.Collectors; 8 | 9 | /** 10 | * The temperature unit used by a {@link TemperatureSensorAccessory}. 11 | * 12 | *

0 ”Celsius” 1 ”Fahrenheit” 13 | * 14 | * @author Andy Lintner 15 | */ 16 | public enum TemperatureDisplayUnitEnum implements CharacteristicEnum { 17 | CELSIUS(0), 18 | FAHRENHEIT(1); 19 | 20 | private static final Map reverse; 21 | 22 | static { 23 | reverse = 24 | Arrays.stream(TemperatureDisplayUnitEnum.values()) 25 | .collect(Collectors.toMap(t -> t.getCode(), t -> t)); 26 | } 27 | 28 | static TemperatureDisplayUnitEnum fromCode(Integer code) { 29 | return reverse.get(code); 30 | } 31 | 32 | private final int code; 33 | 34 | private TemperatureDisplayUnitEnum(int code) { 35 | this.code = code; 36 | } 37 | 38 | public int getCode() { 39 | return code; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/valve/ValveTypeCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.valve; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** This characteristic describes the type of valve. */ 11 | public class ValveTypeCharacteristic extends EnumCharacteristic { 12 | 13 | public ValveTypeCharacteristic( 14 | Supplier> getter, 15 | Consumer subscriber, 16 | Runnable unsubscriber) { 17 | super( 18 | "000000D5-0000-1000-8000-0026BB765291", 19 | "Valve type", 20 | ValveTypeEnum.values(), 21 | Optional.of(getter), 22 | Optional.empty(), 23 | Optional.of(subscriber), 24 | Optional.of(unsubscriber)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/valve/ValveTypeEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.valve; 2 | 3 | import io.github.hapjava.accessories.ValveAccessory; 4 | import io.github.hapjava.characteristics.CharacteristicEnum; 5 | import java.util.Arrays; 6 | import java.util.Map; 7 | import java.util.stream.Collectors; 8 | 9 | /** 10 | * The mode used by a {@link ValveAccessory} 11 | * 12 | *

0 ”Generic valve” 1 ”Irrigation” 2 ”Shower head” 3 ”Water faucet” 4-255 ”Reserved” 13 | * 14 | * @author Tim Harper 15 | */ 16 | public enum ValveTypeEnum implements CharacteristicEnum { 17 | GENERIC(0), 18 | IRRIGATION(1), 19 | SHOWER(2), 20 | WATER_FAUCET(3); 21 | 22 | private static final Map reverse; 23 | 24 | static { 25 | reverse = 26 | Arrays.stream(ValveTypeEnum.values()).collect(Collectors.toMap(t -> t.getCode(), t -> t)); 27 | } 28 | 29 | public static ValveTypeEnum fromCode(Integer code) { 30 | return reverse.get(code); 31 | } 32 | 33 | private final int code; 34 | 35 | private ValveTypeEnum(int code) { 36 | this.code = code; 37 | } 38 | 39 | public int getCode() { 40 | return code; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/windowcovering/CurrentHorizontalTiltAngleCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.windowcovering; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.IntegerCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** This characteristic describes the current angle of horizontal slats. */ 12 | public class CurrentHorizontalTiltAngleCharacteristic extends IntegerCharacteristic 13 | implements EventableCharacteristic { 14 | 15 | public CurrentHorizontalTiltAngleCharacteristic( 16 | Supplier> getter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "0000006C-0000-1000-8000-0026BB765291", 21 | "current horizontal tilt angle", 22 | -90, 23 | 90, 24 | "arcdegrees", 25 | Optional.of(getter), 26 | Optional.empty(), 27 | Optional.of(subscriber), 28 | Optional.of(unsubscriber)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/windowcovering/CurrentPositionCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.windowcovering; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.IntegerCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** This characteristic describes the current position of accessories. */ 12 | public class CurrentPositionCharacteristic extends IntegerCharacteristic 13 | implements EventableCharacteristic { 14 | 15 | public CurrentPositionCharacteristic( 16 | Supplier> getter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "0000006D-0000-1000-8000-0026BB765291", 21 | "current position", 22 | 0, 23 | 100, 24 | "%", 25 | Optional.of(getter), 26 | Optional.empty(), 27 | Optional.of(subscriber), 28 | Optional.of(unsubscriber)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/windowcovering/CurrentVerticalTiltAngleCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.windowcovering; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 5 | import io.github.hapjava.characteristics.impl.base.IntegerCharacteristic; 6 | import java.util.Optional; 7 | import java.util.concurrent.CompletableFuture; 8 | import java.util.function.Consumer; 9 | import java.util.function.Supplier; 10 | 11 | /** This characteristic describes the current angle of vertical slats for accessory. */ 12 | public class CurrentVerticalTiltAngleCharacteristic extends IntegerCharacteristic 13 | implements EventableCharacteristic { 14 | 15 | public CurrentVerticalTiltAngleCharacteristic( 16 | Supplier> getter, 17 | Consumer subscriber, 18 | Runnable unsubscriber) { 19 | super( 20 | "0000006E-0000-1000-8000-0026BB765291", 21 | "current vertical tilt angle", 22 | -90, 23 | 90, 24 | "arcdegrees", 25 | Optional.of(getter), 26 | Optional.empty(), 27 | Optional.of(subscriber), 28 | Optional.of(unsubscriber)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/windowcovering/HoldPositionCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.windowcovering; 2 | 3 | import io.github.hapjava.characteristics.ExceptionalConsumer; 4 | import io.github.hapjava.characteristics.impl.base.BooleanCharacteristic; 5 | import java.util.Optional; 6 | 7 | /** This characteristic causes the accessories like window covering to stop at its current */ 8 | public class HoldPositionCharacteristic extends BooleanCharacteristic { 9 | 10 | public HoldPositionCharacteristic(ExceptionalConsumer setter) { 11 | super( 12 | "0000006F-0000-1000-8000-0026BB765291", 13 | "Hold Position", 14 | Optional.empty(), 15 | Optional.of(setter), 16 | Optional.empty(), 17 | Optional.empty()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/windowcovering/PositionStateCharacteristic.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.windowcovering; 2 | 3 | import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback; 4 | import io.github.hapjava.characteristics.impl.base.EnumCharacteristic; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | /** This characteristic describes the state of the position of accessories. */ 11 | public class PositionStateCharacteristic extends EnumCharacteristic { 12 | 13 | public PositionStateCharacteristic( 14 | Supplier> getter, 15 | Consumer subscriber, 16 | Runnable unsubscriber) { 17 | super( 18 | "00000072-0000-1000-8000-0026BB765291", 19 | "Position state", 20 | PositionStateEnum.values(), 21 | Optional.of(getter), 22 | Optional.empty(), 23 | Optional.of(subscriber), 24 | Optional.of(unsubscriber)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/impl/windowcovering/PositionStateEnum.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.characteristics.impl.windowcovering; 2 | 3 | import io.github.hapjava.characteristics.CharacteristicEnum; 4 | import java.util.Arrays; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | /** 9 | * 0 ”Going to the minimum value specified in metadata” 1 ”Going to the maximum value specified in 10 | * metadata” 2 ”Stopped” 11 | */ 12 | public enum PositionStateEnum implements CharacteristicEnum { 13 | DECREASING(0), 14 | INCREASING(1), 15 | STOPPED(2); 16 | 17 | private static final Map reverse; 18 | 19 | static { 20 | reverse = 21 | Arrays.stream(PositionStateEnum.values()) 22 | .collect(Collectors.toMap(PositionStateEnum::getCode, t -> t)); 23 | } 24 | 25 | public static PositionStateEnum fromCode(Integer code) { 26 | return reverse.get(code); 27 | } 28 | 29 | private final int code; 30 | 31 | PositionStateEnum(int code) { 32 | this.code = code; 33 | } 34 | 35 | @Override 36 | public int getCode() { 37 | return code; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/characteristics/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains the basic characteristic types that can be supplied over the HomeKit Accessory Protocol. 3 | */ 4 | package io.github.hapjava.characteristics; 5 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/HomekitWebHandler.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server; 2 | 3 | import io.github.hapjava.server.impl.http.HomekitClientConnectionFactory; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | public interface HomekitWebHandler { 7 | 8 | CompletableFuture start(HomekitClientConnectionFactory clientConnectionFactory); 9 | 10 | void stop(); 11 | 12 | void resetConnections(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/connections/PendingNotification.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.connections; 2 | 3 | import io.github.hapjava.characteristics.EventableCharacteristic; 4 | 5 | public class PendingNotification { 6 | public int aid; 7 | public int iid; 8 | public EventableCharacteristic characteristic; 9 | 10 | public PendingNotification(int aid, int iid, EventableCharacteristic characteristic) { 11 | this.aid = aid; 12 | this.iid = iid; 13 | this.characteristic = characteristic; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/crypto/EdsaVerifier.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.crypto; 2 | 3 | import java.security.MessageDigest; 4 | import java.security.PublicKey; 5 | import java.security.Signature; 6 | import net.i2p.crypto.eddsa.EdDSAEngine; 7 | import net.i2p.crypto.eddsa.EdDSAPublicKey; 8 | import net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable; 9 | import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; 10 | import net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec; 11 | 12 | public class EdsaVerifier { 13 | 14 | private final PublicKey publicKey; 15 | 16 | public EdsaVerifier(byte[] publicKey) { 17 | EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName("ed25519-sha-512"); 18 | EdDSAPublicKeySpec pubKey = new EdDSAPublicKeySpec(publicKey, spec); 19 | this.publicKey = new EdDSAPublicKey(pubKey); 20 | } 21 | 22 | public boolean verify(byte[] data, byte[] signature) throws Exception { 23 | Signature sgr = new EdDSAEngine(MessageDigest.getInstance("SHA-512")); 24 | sgr.initVerify(publicKey); 25 | sgr.update(data); 26 | 27 | return sgr.verify(signature); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/http/HomekitClientConnection.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.http; 2 | 3 | import java.io.IOException; 4 | 5 | public interface HomekitClientConnection { 6 | 7 | HttpResponse handleRequest(HttpRequest request) throws IOException; 8 | 9 | byte[] decryptRequest(byte[] ciphertext); 10 | 11 | byte[] encryptResponse(byte[] plaintext) throws IOException; 12 | 13 | void close(); 14 | 15 | void outOfBand(HttpResponse message); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/http/HomekitClientConnectionFactory.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.http; 2 | 3 | import java.util.function.Consumer; 4 | 5 | public interface HomekitClientConnectionFactory { 6 | 7 | HomekitClientConnection createConnection(Consumer outOfBandMessageCallback); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/http/HttpMethod.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.http; 2 | 3 | public enum HttpMethod { 4 | GET, 5 | POST, 6 | PUT 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/http/HttpRequest.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.http; 2 | 3 | public interface HttpRequest { 4 | 5 | String getUri(); 6 | 7 | byte[] getBody(); 8 | 9 | HttpMethod getMethod(); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/http/HttpResponse.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.http; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.util.Collections; 5 | import java.util.Map; 6 | 7 | public interface HttpResponse { 8 | 9 | int getStatusCode(); 10 | 11 | default ByteBuffer getBody() { 12 | return ByteBuffer.allocate(0); 13 | } 14 | 15 | default HttpVersion getVersion() { 16 | return HttpVersion.HTTP_1_1; 17 | } 18 | 19 | default Map getHeaders() { 20 | return Collections.emptyMap(); 21 | } 22 | 23 | default boolean doUpgrade() { 24 | return false; 25 | } 26 | 27 | public enum HttpVersion { 28 | HTTP_1_1, 29 | EVENT_1_0 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/http/impl/DefaultHttpRequestImpl.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.http.impl; 2 | 3 | import io.github.hapjava.server.impl.http.HttpMethod; 4 | import io.github.hapjava.server.impl.http.HttpRequest; 5 | 6 | class DefaultHttpRequestImpl implements HttpRequest { 7 | 8 | private final io.netty.handler.codec.http.HttpRequest request; 9 | 10 | public DefaultHttpRequestImpl(io.netty.handler.codec.http.HttpRequest request) { 11 | this.request = request; 12 | } 13 | 14 | @Override 15 | public String getUri() { 16 | return request.uri(); 17 | } 18 | 19 | @Override 20 | public byte[] getBody() { 21 | return new byte[0]; 22 | } 23 | 24 | @Override 25 | public HttpMethod getMethod() { 26 | io.netty.handler.codec.http.HttpMethod method = request.method(); 27 | if (method.equals(io.netty.handler.codec.http.HttpMethod.GET)) { 28 | return HttpMethod.GET; 29 | } else if (method.equals(io.netty.handler.codec.http.HttpMethod.POST)) { 30 | return HttpMethod.POST; 31 | } else if (method.equals(io.netty.handler.codec.http.HttpMethod.PUT)) { 32 | return HttpMethod.PUT; 33 | } else { 34 | throw new RuntimeException("Unrecognized method: " + method.toString()); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/http/impl/FullRequestHttpRequestImpl.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.http.impl; 2 | 3 | import io.netty.handler.codec.http.FullHttpRequest; 4 | 5 | class FullRequestHttpRequestImpl extends DefaultHttpRequestImpl { 6 | 7 | private final FullHttpRequest nettyRequest; 8 | 9 | public FullRequestHttpRequestImpl(FullHttpRequest nettyRequest) { 10 | super(nettyRequest); 11 | this.nettyRequest = nettyRequest; 12 | } 13 | 14 | @Override 15 | public byte[] getBody() { 16 | byte[] ret = new byte[nettyRequest.content().readableBytes()]; 17 | nettyRequest.content().readBytes(ret); 18 | return ret; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/http/impl/HttpResponseEncoderAggregate.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.http.impl; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.channel.ChannelHandlerContext; 5 | import io.netty.handler.codec.http.HttpResponseEncoder; 6 | import java.util.Iterator; 7 | import java.util.List; 8 | 9 | public class HttpResponseEncoderAggregate extends HttpResponseEncoder { 10 | 11 | @Override 12 | protected void encode(ChannelHandlerContext ctx, Object msg, List out) throws Exception { 13 | super.encode(ctx, msg, out); 14 | if (out.size() > 0) { 15 | Iterator i = out.iterator(); 16 | ByteBuf b = (ByteBuf) i.next(); 17 | while (i.hasNext()) { 18 | b.writeBytes((ByteBuf) i.next()); 19 | i.remove(); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/json/EventResponse.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.json; 2 | 3 | public class EventResponse extends HapJsonResponse { 4 | 5 | public EventResponse(byte[] body) { 6 | super(body); 7 | } 8 | 9 | @Override 10 | public HttpVersion getVersion() { 11 | return HttpVersion.EVENT_1_0; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/json/HapJsonNoContentResponse.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.json; 2 | 3 | class HapJsonNoContentResponse extends HapJsonResponse { 4 | 5 | public HapJsonNoContentResponse() { 6 | super(new byte[0]); 7 | } 8 | 9 | @Override 10 | public int getStatusCode() { 11 | return 204; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/json/HapJsonResponse.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.json; 2 | 3 | import io.github.hapjava.server.impl.responses.OkResponse; 4 | import java.util.Collections; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | class HapJsonResponse extends OkResponse { 9 | 10 | private static final Map headers = 11 | Collections.unmodifiableMap( 12 | new HashMap() { 13 | private static final long serialVersionUID = 1L; 14 | 15 | { 16 | put("Content-type", "application/hap+json"); 17 | } 18 | }); 19 | 20 | public HapJsonResponse(byte[] body) { 21 | super(body); 22 | } 23 | 24 | @Override 25 | public Map getHeaders() { 26 | return headers; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/pairing/ErrorCode.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.pairing; 2 | 3 | public enum ErrorCode { 4 | OK(0), 5 | UNKNOWN(1), 6 | AUTHENTICATION(2), 7 | BACKOFF(3), 8 | MAX_PEERS(4), 9 | MAX_TRIES(5), 10 | UNAVAILABLE(6), 11 | BUSY(7); 12 | 13 | private final short key; 14 | 15 | ErrorCode(short key) { 16 | this.key = key; 17 | } 18 | 19 | ErrorCode(int key) { 20 | this.key = (short) key; 21 | } 22 | 23 | public short getKey() { 24 | return key; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/pairing/MessageType.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.pairing; 2 | 3 | public enum MessageType { 4 | METHOD(0), 5 | USERNAME(1), 6 | SALT(2), 7 | PUBLIC_KEY(3), 8 | PROOF(4), 9 | ENCRYPTED_DATA(5), 10 | STATE(6), 11 | ERROR(7), 12 | SIGNATURE(0x0a), 13 | PERMISSIONS(0x0b), 14 | FRAGMENT_DATA(0x0c), 15 | FRAGMENT_LAST(0x0d), 16 | FLAGS(0x13), 17 | SEPARATOR(0xff); 18 | 19 | private final short key; 20 | 21 | MessageType(short key) { 22 | this.key = key; 23 | } 24 | 25 | MessageType(int key) { 26 | this.key = (short) key; 27 | } 28 | 29 | public short getKey() { 30 | return key; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/pairing/PairingMethod.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.pairing; 2 | 3 | public enum PairingMethod { 4 | PAIR_SETUP(0), 5 | PAIR_SETUP_WITH_AUTH(1), 6 | PAIR_VERIFY(2), 7 | ADD_PAIRING(3), 8 | REMOVE_PAIRING(4), 9 | LIST_PAIRINGS(5); 10 | 11 | private final byte value; 12 | 13 | PairingMethod(byte value) { 14 | this.value = value; 15 | } 16 | 17 | PairingMethod(int value) { 18 | this.value = (byte) value; 19 | } 20 | 21 | public byte getValue() { 22 | return value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/pairing/ServerEvidenceRoutineImpl.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.pairing; 2 | 3 | import com.nimbusds.srp6.SRP6CryptoParams; 4 | import com.nimbusds.srp6.SRP6ServerEvidenceContext; 5 | import com.nimbusds.srp6.ServerEvidenceRoutine; 6 | import java.math.BigInteger; 7 | import java.security.MessageDigest; 8 | import java.security.NoSuchAlgorithmException; 9 | 10 | class ServerEvidenceRoutineImpl implements ServerEvidenceRoutine { 11 | 12 | @Override 13 | public BigInteger computeServerEvidence( 14 | SRP6CryptoParams cryptoParams, SRP6ServerEvidenceContext ctx) { 15 | 16 | MessageDigest digest; 17 | try { 18 | digest = MessageDigest.getInstance(cryptoParams.H); 19 | } catch (NoSuchAlgorithmException e) { 20 | throw new RuntimeException("Could not locate requested algorithm", e); 21 | } 22 | 23 | byte[] hS = digest.digest(SrpHandler.bigIntegerToUnsignedByteArray(ctx.S)); 24 | 25 | digest.update(SrpHandler.bigIntegerToUnsignedByteArray(ctx.A)); 26 | digest.update(SrpHandler.bigIntegerToUnsignedByteArray(ctx.M1)); 27 | digest.update(hS); 28 | 29 | return new BigInteger(1, digest.digest()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/pairing/UpgradeResponse.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.pairing; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | public class UpgradeResponse extends PairingResponse { 6 | 7 | private final byte[] readKey; 8 | private final byte[] writeKey; 9 | 10 | UpgradeResponse(byte[] body, byte[] readKey, byte[] writeKey) { 11 | super(body); 12 | this.readKey = readKey; 13 | this.writeKey = writeKey; 14 | } 15 | 16 | @Override 17 | public boolean doUpgrade() { 18 | return true; 19 | } 20 | 21 | public ByteBuffer getReadKey() { 22 | return ByteBuffer.wrap(readKey); 23 | } 24 | 25 | public ByteBuffer getWriteKey() { 26 | return ByteBuffer.wrap(writeKey); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/responses/ConflictResponse.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.responses; 2 | 3 | import io.github.hapjava.server.impl.http.HttpResponse; 4 | 5 | public class ConflictResponse implements HttpResponse { 6 | 7 | @Override 8 | public int getStatusCode() { 9 | return 409; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/responses/InternalServerErrorResponse.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.responses; 2 | 3 | import io.github.hapjava.server.impl.http.HttpResponse; 4 | import java.nio.ByteBuffer; 5 | import java.nio.charset.StandardCharsets; 6 | 7 | public class InternalServerErrorResponse implements HttpResponse { 8 | 9 | private final Exception e; 10 | 11 | public InternalServerErrorResponse(Exception e) { 12 | this.e = e; 13 | } 14 | 15 | @Override 16 | public int getStatusCode() { 17 | return 500; 18 | } 19 | 20 | @Override 21 | public ByteBuffer getBody() { 22 | return ByteBuffer.wrap(e.getClass().getName().getBytes(StandardCharsets.UTF_8)); 23 | } 24 | 25 | public Exception getException() { 26 | return e; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/responses/NotFoundResponse.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.responses; 2 | 3 | import io.github.hapjava.server.impl.http.HttpResponse; 4 | 5 | public class NotFoundResponse implements HttpResponse { 6 | 7 | @Override 8 | public int getStatusCode() { 9 | return 404; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/responses/OkResponse.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.responses; 2 | 3 | import io.github.hapjava.server.impl.http.HttpResponse; 4 | import java.nio.ByteBuffer; 5 | 6 | public class OkResponse implements HttpResponse { 7 | 8 | private final ByteBuffer body; 9 | 10 | public OkResponse(byte[] body) { 11 | this.body = ByteBuffer.wrap(body); 12 | } 13 | 14 | @Override 15 | public ByteBuffer getBody() { 16 | return body; 17 | } 18 | 19 | @Override 20 | public int getStatusCode() { 21 | return 200; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/server/impl/responses/UnauthorizedResponse.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.server.impl.responses; 2 | 3 | import io.github.hapjava.server.impl.http.HttpResponse; 4 | 5 | public class UnauthorizedResponse implements HttpResponse { 6 | 7 | @Override 8 | public int getStatusCode() { 9 | return 401; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/services/impl/HAPProtocolInformationService.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.services.impl; 2 | 3 | import io.github.hapjava.characteristics.impl.common.VersionCharacteristic; 4 | 5 | /** This service HAP version. */ 6 | public class HAPProtocolInformationService extends AbstractServiceImpl { 7 | 8 | public HAPProtocolInformationService(VersionCharacteristic versionCharacteristic) { 9 | super("000000A2-0000-1000-8000-0026BB765291"); 10 | addCharacteristic(versionCharacteristic); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/services/impl/ServiceLabelService.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.services.impl; 2 | 3 | import io.github.hapjava.characteristics.impl.common.ServiceLabelNamespaceCharacteristic; 4 | 5 | /** This service describes label scheme. */ 6 | public class ServiceLabelService extends AbstractServiceImpl { 7 | 8 | public ServiceLabelService( 9 | ServiceLabelNamespaceCharacteristic serviceLabelNamespaceCharacteristic) { 10 | super("000000CC-0000-1000-8000-0026BB765291"); 11 | addCharacteristic(serviceLabelNamespaceCharacteristic); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/io/github/hapjava/services/impl/SwitchService.java: -------------------------------------------------------------------------------- 1 | package io.github.hapjava.services.impl; 2 | 3 | import io.github.hapjava.accessories.SwitchAccessory; 4 | import io.github.hapjava.accessories.optionalcharacteristic.AccessoryWithName; 5 | import io.github.hapjava.characteristics.impl.common.NameCharacteristic; 6 | import io.github.hapjava.characteristics.impl.common.OnCharacteristic; 7 | 8 | /** This service describes a binary switch. */ 9 | public class SwitchService extends AbstractServiceImpl { 10 | 11 | public SwitchService(OnCharacteristic onState) { 12 | super("00000049-0000-1000-8000-0026BB765291"); 13 | addCharacteristic(onState); 14 | } 15 | 16 | public SwitchService(SwitchAccessory accessory) { 17 | this( 18 | new OnCharacteristic( 19 | accessory::getSwitchState, 20 | accessory::setSwitchState, 21 | accessory::subscribeSwitchState, 22 | accessory::unsubscribeSwitchState)); 23 | if (accessory instanceof AccessoryWithName) { 24 | addOptionalCharacteristic(new NameCharacteristic(((AccessoryWithName) accessory)::getName)); 25 | } 26 | } 27 | 28 | public void addOptionalCharacteristic(NameCharacteristic name) { 29 | addCharacteristic(name); 30 | } 31 | } 32 | --------------------------------------------------------------------------------