SmartDeviceView Class Reference
See the Getting Started Guide for a guide to getting started with the smart device package.
Read-only facade over a SmartDeviceStatus snapshot.
Provides efficient ID-based lookups for all component types. Build a SmartDeviceView from a SmartDeviceStatus via SCSmartDevice.get_view().
all_devices_online()
Return True if every configured device is currently online.
Returns:
| Type | Description |
|---|---|
bool
|
True if all devices are online, False if any device is offline. |
get_device_expect_offline(device_id)
Return whether the device is configured to be expected offline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_id
|
int
|
The integer device ID. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the device is expected to be offline, False otherwise. |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the device ID is not found. |
get_device_id(name)
Return the device ID for the given device name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The device name to look up. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The integer device ID, or 0 if not found. |
get_device_id_list()
Return a list of all device IDs.
Returns:
| Type | Description |
|---|---|
list[int]
|
List of integer device IDs for all configured devices. |
get_device_name(device_id)
Return the name of the device with the given ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_id
|
int
|
The integer device ID. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The device name string. |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the device ID is not found. |
get_device_online(device_id)
Return whether the device is currently online.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_id
|
int
|
The integer device ID. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the device is online, False otherwise. |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the device ID is not found. |
get_device_temperature(device_id)
Return the current temperature of the device, if available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_id
|
int
|
The integer device ID. |
required |
Returns:
| Type | Description |
|---|---|
float | None
|
Temperature in degrees Celsius as a float, or None if unavailable. |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the device ID is not found. |
get_device_value(device_id, key_name, default=None)
Return any attribute from a device's normalized snapshot dict.
Use this for standard fields not covered by a dedicated getter (e.g.
"MacAddress", "Uptime") and for custom keys defined in the
app's YAML config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_id
|
int
|
The integer device ID. |
required |
key_name
|
str
|
The dict key to retrieve. |
required |
default
|
Any
|
Value returned when the key is absent. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The value for |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the device ID is not found. |
get_input_id(name)
Return the input ID for the given input name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The input name to look up. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The integer input ID, or 0 if not found. |
get_input_state(input_id)
Return the current state of the input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_id
|
int
|
The integer input ID. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the input is active, False otherwise. |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the input ID is not found. |
get_input_value(input_id, key_name, default=None)
Return any attribute from an input's normalized snapshot dict.
Use this for custom keys defined in the app's YAML config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_id
|
int
|
The integer input ID. |
required |
key_name
|
str
|
The dict key to retrieve. |
required |
default
|
Any
|
Value returned when the key is absent. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The value for |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the input ID is not found. |
get_json_snapshot()
Return a plain-dict snapshot of all component lists.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with keys |
dict[str, Any]
|
and |
get_meter_energy(meter_id)
Return the cumulative energy reading from the meter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meter_id
|
int
|
The integer meter ID. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Energy in watt-hours as a float, or 0.0 if unavailable. |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the meter ID is not found. |
get_meter_id(name)
Return the meter ID for the given meter name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The meter name to look up. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The integer meter ID, or 0 if not found. |
get_meter_power(meter_id)
Return the current power reading from the meter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meter_id
|
int
|
The integer meter ID. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Power in watts as a float, or 0.0 if unavailable. |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the meter ID is not found. |
get_meter_value(meter_id, key_name, default=None)
Return any attribute from a meter's normalized snapshot dict.
Use this for standard fields not covered by a dedicated getter (e.g.
"Voltage", "Current", "PowerFactor") and for custom keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meter_id
|
int
|
The integer meter ID. |
required |
key_name
|
str
|
The dict key to retrieve. |
required |
default
|
Any
|
Value returned when the key is absent. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The value for |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the meter ID is not found. |
get_output_device_id(output_id)
Return the device ID that owns the given output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_id
|
int
|
The integer output ID. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The integer device ID that owns this output. |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the output ID is not found. |
get_output_id(name)
Return the output ID for the given output name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The output name to look up. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The integer output ID, or 0 if not found. |
get_output_state(output_id)
Return the current on/off state of the output.
Returns False if the parent device is offline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_id
|
int
|
The integer output ID. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the output is on, False if off or device is offline. |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the output ID is not found. |
get_output_value(output_id, key_name, default=None)
Return any attribute from an output's normalized snapshot dict.
Use this for standard fields not covered by a dedicated getter (e.g.
"Temperature") and for custom keys defined in the app's YAML config
(e.g. "Group").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_id
|
int
|
The integer output ID. |
required |
key_name
|
str
|
The dict key to retrieve. |
required |
default
|
Any
|
Value returned when the key is absent. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The value for |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the output ID is not found. |
get_temp_probe_id(name)
Return the temperature probe ID for the given probe name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The temperature probe name to look up. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The integer temperature probe ID, or 0 if not found. |
get_temp_probe_reading_time(temp_probe_id)
Return the datetime of the last reading from the temperature probe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temp_probe_id
|
int
|
The integer temperature probe ID. |
required |
Returns:
| Type | Description |
|---|---|
datetime | None
|
A |
datetime | None
|
reading has been recorded yet. |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the temperature probe ID is not found. |
get_temp_probe_temperature(temp_probe_id)
Return the most recent temperature reading from the probe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temp_probe_id
|
int
|
The integer temperature probe ID. |
required |
Returns:
| Type | Description |
|---|---|
float | None
|
Temperature in degrees Celsius as a float, or None if unavailable. |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the temperature probe ID is not found. |
get_temp_probe_value(temp_probe_id, key_name, default=None)
Return any attribute from a temperature probe's normalized snapshot dict.
Use this for custom keys defined in the app's YAML config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temp_probe_id
|
int
|
The integer temperature probe ID. |
required |
key_name
|
str
|
The dict key to retrieve. |
required |
default
|
Any
|
Value returned when the key is absent. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The value for |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the temperature probe ID is not found. |
validate_device_id(device_id)
Check whether a device ID or name refers to a known device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_id
|
int | str
|
Integer device ID or device name string. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the device exists, False otherwise. |
validate_output_id(output_id)
Check whether an output ID or name refers to a known output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_id
|
int | str
|
Integer output ID or output name string. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the output exists, False otherwise. |