-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SecuritySystem - Show as Single Tile #125
Comments
In the simulator I suppose you've created a single accessory with multiple services, which can be done using this package as well: let securitySystem = Accessory(info: .init(name: "Multi-Zone", serialNumber: "A1803"),
type: .securitySystem,
services: [
Service.SecuritySystemBase(characteristics: [.name("Zone A")]),
Service.SecuritySystemBase(characteristics: [.name("Zone B")])
])
let device = Device(
bridgeInfo: Service.Info(name: "Bridge", serialNumber: "00001"),
setupCode: "123-44-321",
storage: storage,
accessories: [
securitySystem
]) To include the optional characteristics "status fault" and "status tampered", you have to explicitly add those during initialization: Service.SecuritySystemBase(characteristics: [.name("Zone A"), .statusFault(), .statusTampered()]) |
Hi,
Thanks - that has achieved exactly what I was trying to achieve in the Apple Home interface.
1) How do I now add the logic to the code to handle the actions, etc.
2) I assume I'll know which item (name) is being called
3) How do I change the Tampered() status - will it appear similar to the non optional settings ?
Thanks
Kent.
eg. Before I had set up as six separate accessories as you had worked out:
let officeAlarmEntranceInfo = Service.Info(name: "Entrance", serialNumber: "A1801", manufacturer: "Linux", model: "Touch", firmwareRevision: "10001")
let officeAlarmMeetingInfo = Service.Info(name: "Meeting", serialNumber: "A1802", manufacturer: "Linux", model: "Touch", firmwareRevision: "10001")
let officeAlarmSupportInfo = Service.Info(name: "Support", serialNumber: "A1803", manufacturer: "Linux", model: "Touch", firmwareRevision: "10001")
let officeAlarmDevsInfo = Service.Info(name: "Devs", serialNumber: "A1804", manufacturer: "Linux", model: "Touch", firmwareRevision: "10001")
let officeAlarmOfficeInfo = Service.Info(name: "Office", serialNumber: "A1805", manufacturer: "Linux", model: "Touch", firmwareRevision: "10001")
let officeAlarmServerInfo = Service.Info(name: "Server Room", serialNumber: "A1806", manufacturer: "Linux", model: "Touch", firmwareRevision: "10001")
let officeAlarmEntrance = OfficeAlarmSystem(info: officeAlarmEntranceInfo, name: "entrance", address: alarmaddress, password: alarmpswd )
let officeAlarmMeeting = OfficeAlarmSystem(info: officeAlarmMeetingInfo, name: "meeting", address: alarmaddress, password: alarmpswd )
let officeAlarmSupport = OfficeAlarmSystem(info: officeAlarmSupportInfo, name: "support", address: alarmaddress, password: alarmpswd )
let officeAlarmDevs = OfficeAlarmSystem(info: officeAlarmDevsInfo, name: "devs", address: alarmaddress, password: alarmpswd )
let officeAlarmOffice = OfficeAlarmSystem(info: officeAlarmOfficeInfo, name: "office", address: alarmaddress, password: alarmpswd )
let officeAlarmServer = OfficeAlarmSystem(info: officeAlarmServerInfo, name: "server", address: alarmaddress, password: alarmpswd )
And then I have a OfficeAlarmSystem.swift() file which has the logic, etc.
//
// AlarmSystem.swift
// HAP
//
// Created by Kent on 3/1/2021.
//
import Foundation
import Logging
import HAP
#if os(Linux)
import Dispatch
#endif
fileprivate let logger = Logger(label: "hap.office.officealarmsystem")
class OfficeAlarmSystem: HAP.Accessory.SecuritySystem {
var sensorid = ""
var serveraddress = ""
var serverpassword = ""
init(info: Service.Info, name: String, address: String, password: String) {
super.init(info:info)
logger.info("[Office Alarm System] Init: \(name)")
sensorid = name
serveraddress = address
serverpassword = password
self.securitySystem.securitySystemCurrentState.value = HAP.Enums.SecuritySystemCurrentState.disarm
self.securitySystem.securitySystemTargetState.value = HAP.Enums.SecuritySystemTargetState.disarm
}
… On 5/01/2021, at 12:05 PM, Bouke Haarsma ***@***.***> wrote:
In the simulator I suppose you've created a single accessory with multiple services, which can be done using this package as well:
let securitySystem = Accessory(info: .init(name: "Multi-Zone", serialNumber: "A1803"),
type: .securitySystem,
services: [
Service.SecuritySystemBase(characteristics: [.name("Zone A")]),
Service.SecuritySystemBase(characteristics: [.name("Zone B")])
])
let device = Device(
bridgeInfo: Service.Info(name: "Bridge", serialNumber: "00001"),
setupCode: "123-44-321",
storage: storage,
accessories: [
securitySystem
])
To include the optional characteristics "status fault" and "status tampered", you have to explicitly add those during initialization:
Service.SecuritySystemBase(characteristics: [.name("Zone A"), .statusFault(), .statusTampered()])
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#125 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ANLIE6GXEJ2IA6BX25AYYJDSYJCULANCNFSM4VSGYHKA>.
|
HAP/Sources/HAP/Base/Generated.swift Lines 1459 to 1460 in b1038b5
The default accessory HAP/Sources/HAP/Accessories/SecuritySystem.swift Lines 3 to 7 in 8fbd1a7
In your situation, you're better off not extending class OfficeAlarmSystem : HAP.Accessory {
var zones: Service.SecuritySystemBase[]
init(info: Service.Info) {
zones = [
Service.SecuritySystemBase(characteristics: [.name("Zone A"), .statusFault(), .statusTampered()]),
Service.SecuritySystemBase(characteristics: [.name("Zone B")])
]
super.init(info:info,
type: .securitySystem,
services: zones)
zones[0].statusTampered.value = 1
}
} |
I've created the class (with a couple of modifications)
Then in 'Main.swift' I've created the accessory.
This appears to be working - so now to make it actually do something 👍 Kent. |
I'm setting up a 'SecuritySystem' with 6 zones in it.
When I use the Apple HomeKit Accessory Simulator for the six zones, they appear as a single 'Tile' in the 'Home' app and there is an toggle to 'Show as Single Tile' or 'Show as Separate Tiles'.
I cannot figure out how to recreate this setup using HAP. They always appear as separate tiles and there is no option to 'Show as Single Tile'.
Does anyone know how to create it so that they can be a single 'Tile' ?
Note: I've tried using the same 'serialNumber', etc.
Thanks
Kent.
let zone1Info = Service.Info(name: "Name1", serialNumber: "A1801", manufacturer: "Linux", model: "A", firmwareRevision: "1")
let zone2Info = Service.Info(name: "Name2", serialNumber: "A1802", manufacturer: "Linux", model: "A", firmwareRevision: "1")
let zone3Info = Service.Info(name: "Name3", serialNumber: "A1803", manufacturer: "Linux", model: "A", firmwareRevision: "1")
let zone4Info = Service.Info(name: "Name4", serialNumber: "A1804", manufacturer: "Linux", model: "A", firmwareRevision: "1")
let zone5Info = Service.Info(name: "Name5", serialNumber: "A1805", manufacturer: "Linux", model: "A", firmwareRevision: "1")
let zone6Info = Service.Info(name: "Name6", serialNumber: "A1806", manufacturer: "Linux", model: "A", firmwareRevision: "1")
let zone1 = OfficeAlarmSystem(info: zone1Info, name: "Name1" )
let zone2 = OfficeAlarmSystem(info: zone2Info, name: "Name2" )
let zone3 = OfficeAlarmSystem(info: zone3Info, name: "Name3" )
let zone4 = OfficeAlarmSystem(info: zone4Info, name: "Name4" )
let zone5 = OfficeAlarmSystem(info: zone5Info, name: "Name5" )
let zone6 = OfficeAlarmSystem(info: zone6Info, name: "Name6" )
let device = Device(
bridgeInfo: bridgeInfo,
setupCode: setupCode,
storage: storage,
accessories: [
zone1,
zone2,
zone3,
zone4,
zone5,
zone6
]
The text was updated successfully, but these errors were encountered: