pycsmeter
¶
Python client for interacting with CS water softener valves via BLE.
Modules:
-
cli–Command line interface for pycsmeter.
-
exceptions–Exceptions for pycsmeter.
-
valve–Valve client for interacting with CS valves.
cli
¶
Command line interface for pycsmeter.
Functions:
-
connect–Test connection to a valve.
-
main–Command line interface for interacting with CS water softener valves.
-
status–Get current status from a valve.
connect
¶
Test connection to a valve.
Parameters:
-
address(str) –The Bluetooth address of the valve (e.g. 00:11:22:33:44:55)
-
password(str) –The valve's connection password
Source code in pycsmeter/cli.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
main
¶
main() -> None
Command line interface for interacting with CS water softener valves.
Source code in pycsmeter/cli.py
65 66 67 | |
status
¶
Get current status from a valve.
Parameters:
-
address(str) –The Bluetooth address of the valve (e.g. 00:11:22:33:44:55)
-
password(str) –The valve's connection password
Source code in pycsmeter/cli.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
exceptions
¶
Exceptions for pycsmeter.
Classes:
-
AuthenticationError–Raised when authentication to the valve fails.
-
DataRetrievalError–Raised when failing to retrieve data from the valve.
-
PacketError–Raised for packet parsing or validation errors.
-
PacketParseError–Raised when a raw packet cannot be parsed.
-
PacketValidationError–Raised when a parsed packet fails validation.
-
ValveConnectionError–Raised when BLE connection fails.
-
ValveError–Base exception for valve-related errors.
AuthenticationError
¶
Bases: ValveError
Raised when authentication to the valve fails.
DataRetrievalError
¶
Bases: ValveError
Raised when failing to retrieve data from the valve.
PacketError
¶
Bases: ValveError
Raised for packet parsing or validation errors.
PacketParseError
¶
Bases: PacketError
Raised when a raw packet cannot be parsed.
PacketValidationError
¶
Bases: PacketError
Raised when a parsed packet fails validation.
ValveConnectionError
¶
Bases: ValveError
Raised when BLE connection fails.
valve
¶
Valve client for interacting with CS valves.
Classes:
-
AdvancedData–Advanced valve status information.
-
DashboardData–Current valve status.
-
Valve–Valve client for interacting with CS valves.
-
ValveData–Complete valve status including dashboard, advanced, and history data.
AdvancedData
dataclass
¶
Advanced valve status information.
DashboardData
dataclass
¶
DashboardData(hour: int, minute: int, battery_voltage: float, current_flow: float, soft_water_remaining: int, treated_usage_today: int, peak_flow_today: float, water_hardness: int, regeneration_hour: int)
Current valve status.
Valve
¶
Valve(address: str)
Valve client for interacting with CS valves.
Parameters:
-
address(str) –The Bluetooth address of the valve (e.g. 00:11:22:33:44:55)
Methods:
-
connect–Connect to the valve via BLE, send authentication using the provided password, and return True if authentication succeeds.
-
disconnect–Disconnect from the valve if currently connected.
-
get_data–Retrieve Dashboard, Advanced, and History packets from the valve, returning a ValveData object. Retries up to three times on failure.
-
id–Return a string identifier for this valve device (its BLE address).
Source code in pycsmeter/valve.py
123 124 125 126 127 128 129 130 131 132 133 134 135 | |
connect
async
¶
Connect to the valve via BLE, send authentication using the provided password, and return True if authentication succeeds.
Parameters:
-
password(str) –The valve's connection password
Source code in pycsmeter/valve.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
disconnect
async
¶
disconnect() -> None
Disconnect from the valve if currently connected.
Source code in pycsmeter/valve.py
173 174 175 176 177 178 | |
get_data
async
¶
get_data() -> ValveData
Retrieve Dashboard, Advanced, and History packets from the valve, returning a ValveData object. Retries up to three times on failure.
Source code in pycsmeter/valve.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
ValveData
dataclass
¶
ValveData(dashboard: DashboardData, advanced: AdvancedData, water_usage_history: list[WaterUsageHistoryItem])
Complete valve status including dashboard, advanced, and history data.
Methods:
-
from_internal–Create ValveData from internal packet types.
-
get_history_for_date–Return the history item for a specific date, if available.
-
get_history_last_n_days–Return the most recent n days of history.
from_internal
classmethod
¶
from_internal(dashboard: DashboardPacket, advanced: AdvancedPacket, water_usage_history: WaterUsageHistoryPacket) -> ValveData
Create ValveData from internal packet types.
Source code in pycsmeter/valve.py
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 | |
get_history_for_date
¶
Return the history item for a specific date, if available.
Source code in pycsmeter/valve.py
108 109 110 111 112 113 | |
get_history_last_n_days
¶
Return the most recent n days of history.
Source code in pycsmeter/valve.py
115 116 117 | |