1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
# Status Documentation
The Status module provides classes for handling IOmeter device status information. It includes enums for various device states.
## Classes
### Status
Top-level class for complete device status:
```python
@dataclass
class Status:
meter: Meter
device: Device
typename: str = "iometer.status.v1"
@classmethod
def from_json(cls, json_str: str) -> 'Status':
# Creates Status instance from JSON string
def to_json(self) -> str:
# Converts Status to JSON string
```
### Meter
Represents the meter device:
```python
@dataclass
class Meter:
number: str
```
### Device
Combines bridge, device id and core information:
```python
@dataclass
class Device:
bridge: Bridge
id: str
core: Core
```
### Core
Represents the core device status:
```python
@dataclass
class Core:
connection_status: ConnectionStatus
rssi: int # Signal strength in dBm
version: str # Core firmware version
power_status: PowerStatus
attachment_status: AttachmentStatus
battery_level: Optional[int] = None # Battery percentage if applicable
pin_status: Optional[PinStatus] = None # PIN status if applicable
def to_dict(self) -> dict:
# Converts core data to ordered dictionary
```
### Bridge
Represents the bridge device status:
```python
@dataclass
class Bridge:
rssi: int # Signal strength in dBm
version: str # Bridge firmware version
def __str__(self) -> str:
# Returns formatted string with signal strength and version
```
## Enums
### ConnectionStatus
Represents the device connection state:
```python
class ConnectionStatus(Enum):
CONNECTED = "connected"
DISCONNECTED = "disconnected"
```
### PowerStatus
Represents the device power source:
```python
class PowerStatus(Enum):
BATTERY = "battery"
WIRED = "wired"
```
### AttachmentStatus
Represents physical attachment state:
```python
class AttachmentStatus(Enum):
ATTACHED = "attached"
DETACHED = "detached"
```
### PinStatus
Represents PIN entry state:
```python
class PinStatus(Enum):
ENTERED = "entered"
PENDING = "pending"
MISSING = "missing"
```
### JSON Handling
```python
# Parse from JSON
status = Status.from_json(json_string)
# Convert to JSON
json_string = status.to_json()
```
|