A Python implementation of a smart device controller created as part of the EPAI (Extensive Python AI) course. This project demonstrates advanced Python concepts including class attributes, callable classes, and function attributes.
- Class-based smart device implementation
- Device status management and tracking
- Built-in device counter
- Callable class functionality
- Function attributes for device information
- Comprehensive test coverage
The main class that implements smart device functionality:
device = SmartDevice(device_name="Living Room Light", model_number="LRL001", is_online=False)
-
Class Attributes
device_count
: Tracks total number of devices created
-
Instance Attributes
device_name
: Name of the devicemodel_number
: Device model numberis_online
: Device online statusstatus
: Dictionary storing device status attributes
-
Methods
update_status(attribute, value)
: Update device statusget_status(attribute)
: Retrieve status attributestoggle_online()
: Toggle device online statereset()
: Reset device to default state
-
Special Features
- Callable class implementation
device_info
function attribute
# Create a new device
device = SmartDevice("Kitchen Light", "KL100")
# Update device status
device.update_status("battery", 85)
device.update_status("temperature", 24.5)
# Get specific status
battery_level = device.get_status("battery") # Returns 85
# Toggle device online status
device.toggle_online()
# Use callable instance
print(device()) # Prints formatted device name and model
# Get device info using function attribute
info = device.device_info()
The project includes comprehensive tests in test_smart_device.py
. Run tests using:
pytest test_smart_device.py
This project is part of the EPAI course curriculum, demonstrating:
- Object-Oriented Programming in Python
- Class and Instance Attributes
- Special Methods (
__init__
,__call__
) - Function Attributes
- Property Decorators
- Test-Driven Development
- Python 3.6+
- pytest (for running tests)