diff --git a/src/zigbee/conbee-to-fimp.go b/src/zigbee/conbee-to-fimp.go index 2189c11..d3d5a0a 100644 --- a/src/zigbee/conbee-to-fimp.go +++ b/src/zigbee/conbee-to-fimp.go @@ -143,6 +143,21 @@ func (cr *ConbeeToFimpRouter) mapSensorEvent(evt *conbee.ConbeeEvent) { val = val/100 msg = fimpgo.NewFloatMessage("evt.sensor.report", "sensor_humid", val, map[string]string{"unit":"%"}, nil, nil) adr = &fimpgo.Address{MsgType: fimpgo.MsgTypeEvt, ResourceType: fimpgo.ResourceTypeDevice, ResourceName: "conbee", ResourceAddress: cr.instanceId, ServiceName: "sensor_humid", ServiceAddress: serviceAddress} + case "vibration": + val, ok := evt.State[k].(bool) + if !ok { + log.Debug("can't parse the vibration value") + continue + } + var status string + if val { + status = "activ" + } else { + status = "deactiv" + } + valS := map[string]string{"event": "tamper_force_open", "status": status} + msg = fimpgo.NewStrMapMessage("evt.alarm.report", "alarm_burglar", valS, nil, nil, nil) + adr = &fimpgo.Address{MsgType: fimpgo.MsgTypeEvt, ResourceType: fimpgo.ResourceTypeDevice, ResourceName: "conbee", ResourceAddress: cr.instanceId, ServiceName: "alarm_burglar", ServiceAddress: serviceAddress} } }else if evt.ResourceType == "lights" { serviceAddress = "l"+evt.Id+"_0" diff --git a/src/zigbee/net-service.go b/src/zigbee/net-service.go index be2aff1..1a1a616 100644 --- a/src/zigbee/net-service.go +++ b/src/zigbee/net-service.go @@ -224,6 +224,23 @@ func (ns *NetworkService) SendInclusionReport(deviceType, deviceId string) error Version: "1", }} + alarmInterfaces := []fimptype.Interface{{ + Type: "in", + MsgType: "cmd.alarm.get_report", + ValueType: "null", + Version: "1", + }, { + Type: "in", + MsgType: "cmd.alarm.clear", + ValueType: "string", + Version: "1", + }, { + Type: "out", + MsgType: "evt.alarm.report", + ValueType: "str_map", + Version: "1", + }} + sceneInterfaces := []fimptype.Interface{{ Type: "in", MsgType: "cmd.scene.set", @@ -334,6 +351,20 @@ func (ns *NetworkService) SendInclusionReport(deviceType, deviceId string) error Interfaces: presenceSensorInterfaces, } + burglarService := fimptype.Service{ + Name: "alarm_burglar", + Alias: "Burglar detection", + Address: "/rt:dev/rn:conbee/ad:1/sv:alarm_burglar/ad:", + Enabled: true, + Groups: []string{"ch_0"}, + Props: map[string]interface{}{ + "sup_events": []string{"tamper_force_open"}, + }, + Tags: nil, + PropSetReference: "", + Interfaces: alarmInterfaces, + } + if deviceType == "lights" { lightDeviceDescriptor := conbee.Light{} resp , err := ns.conbeeClient.SendConbeeRequest("GET", "lights/"+deviceId, nil, &lightDeviceDescriptor) @@ -388,7 +419,10 @@ func (ns *NetworkService) SendInclusionReport(deviceType, deviceId string) error services = append(services,contactService) case "ZHAPresence": presenceService.Address = presenceService.Address + serviceAddres - services = append(services,presenceService) + services = append(services, presenceService) + case "ZHAVibration": + burglarService.Address = burglarService.Address + serviceAddres + services = append(services, burglarService) case "ZHAAlarm": log.Debug(" ZHAAlarm not mapped") case "ZHACarbonMonoxide": @@ -403,8 +437,6 @@ func (ns *NetworkService) SendInclusionReport(deviceType, deviceId string) error log.Debug(" ZHAPressure not mapped") case "ZHAThermostat": log.Debug(" ZHAThermostat not mapped") - case "ZHAVibration": - log.Debug(" ZHAVibration not mapped") case "ZHAWater": log.Debug(" ZHAWater not mapped") }