Input¶
Overview¶
Generic monitored input point for sensors, contacts, switches, and other binary detection devices not covered by specialized functions like IntrusionDetector. Provides basic alarm, normal, and fault states for simple monitoring applications.
- Added in: PQ Framework 2.1
- Namespace:
Pq.Adapters.Framework
When to Use¶
- Generic contact sensors (temperature, liquid, etc.)
- Binary switches and push buttons
- Environmental sensors (flood, leak, temperature)
- Industrial sensors requiring simple monitoring
- Any input not specifically covered by IntrusionDetector
Do NOT use for:
- Intrusion detection (use
IntrusionDetectorinstead) - Access control door contacts (use
Door.has_door_contact, or wire aMonitorPoint/InputviaDoor.door_contact) - Tamper switches (use
Tamperfunction)
States¶
Detection States¶
| State | Description | Status String |
|---|---|---|
Clear |
Input in normal state (no alarm condition) | pq.state.detection.clear |
Alarm |
Input activated (alarm condition detected) | pq.state.intrusion.alarm |
Fault |
Input fault detected (wiring, supervision) | pq.state.supervision.fault |
Actions¶
State Transitions¶
Activated(timestamp)
- Description: Input activated (alarm state)
- Target State:
Alarm - Events:
pq.event.detection.activated(Warn) - Usage: Input sensor triggered (e.g., water detected, temperature threshold exceeded)
Deactivated(timestamp)
- Description: Input deactivated (return to normal)
- Target State:
Clear - Events:
pq.event.detection.deactivated(Info) - Usage: Input sensor cleared (e.g., water receded, temperature normal)
Fault(timestamp)
- Description: Input fault detected (wiring issue, supervision failure)
- Target State:
Fault - Events:
pq.event.supervision.fault(Warn) - Usage: Supervision circuit open/short, sensor disconnected
Properties¶
None. All configuration is adapter-specific. Define properties in adapter-registration.yaml if needed (e.g., supervision_type, threshold_value).
YAML Example¶
device_types:
- type_id: WaterLeakSensor
name: "Water Leak Sensor"
functions:
Input:
properties:
supervision_type:
type: "string"
default: "eol"
description: "Supervision: none, eol, deol"
- type_id: TemperatureSwitch
name: "Temperature Switch"
functions:
Input:
properties:
threshold_temp_celsius:
type: "int"
default: 40
description: "Temperature threshold for alarm"
Code Usage¶
public class WaterLeakSensorThing : Thing
{
public InputFunction Sensor { get; }
protected override async Task HandleDeviceEvent(SensorEvent evt, CancellationToken ct)
{
switch (evt.Type)
{
case SensorEventType.WaterDetected:
await Sensor.Activated(evt.Timestamp);
break;
case SensorEventType.WaterCleared:
await Sensor.Deactivated(evt.Timestamp);
break;
case SensorEventType.SupervisionFault:
await Sensor.Fault(evt.Timestamp);
break;
case SensorEventType.FaultRestored:
await Sensor.Deactivated(evt.Timestamp);
break;
}
}
}
Notes¶
- Simple Design: Input function provides minimal state machine for basic monitoring
- No Bypassing: Unlike IntrusionDetector, Input lacks bypass/arm/disarm logic
- Event Severity:
Activatedis Warn level (not Critical), suitable for general monitoring - Fault Clearing: Fault state cleared by calling
Deactivated(), returning to Clear - Supervision: Adapter implements supervision logic based on device capabilities
See Also¶
- Functions: IntrusionDetector - For intrusion detection sensors
- Functions: Output - Companion output control function