0% found this document useful (0 votes)
60 views5 pages

Project 2

The document outlines a Python assignment for developing a Smart Home Automation System, focusing on device management, energy consumption tracking, and automation features using data structures like lists, tuples, dictionaries, and sets. It includes tasks such as creating and managing smart device lists, tracking energy usage, and implementing functions for calculating energy costs and setting automation rules. Additionally, there is a bonus challenge to create a smart home AI assistant that manages device status updates and automation commands.

Uploaded by

saaaaadiiii6776
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views5 pages

Project 2

The document outlines a Python assignment for developing a Smart Home Automation System, focusing on device management, energy consumption tracking, and automation features using data structures like lists, tuples, dictionaries, and sets. It includes tasks such as creating and managing smart device lists, tracking energy usage, and implementing functions for calculating energy costs and setting automation rules. Additionally, there is a bonus challenge to create a smart home AI assistant that manages device status updates and automation commands.

Uploaded by

saaaaadiiii6776
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Python Assignment: Smart Home

Automation System
�� Scenario:

You are developing a Smart Home Automation System that allows users to control and
monitor various home appliances using Python data structures like Lists, Tuples,
Dictionaries, Sets, and Functions.

Your task is to implement different functionalities step by step.

1. Device Management (Lists & Tuples)


Task 1.1: Create and Manage a List of Smart Devices

● Create a list of at least 5 smart home devices (e.g., "Lights", "Fan", "AC", "Door
Lock", "Thermostat").
● Allow the user to:
○ Add a new device.
○ Remove a device.
○ Sort devices alphabetically.

✍️ Example Output:
Devices: ['Lights', 'Fan', 'AC', 'Door Lock', 'Thermostat'] Updated
Devices: ['Lights', 'Fan', 'AC', 'Door Lock', 'Thermostat',
'Security Camera']
Sorted Devices: ['AC', 'Door Lock', 'Fan', 'Lights', 'Security
Camera', 'Thermostat']

Task 1.2: Store Device Settings Using Tuples

● Define a tuple for each device, containing:


○ Device name
○ Device status (ON/OFF)
○ Device power consumption (in Watts)
● Allow users to view all devices with their status and power consumption.

✍️ Example Output:
Lights: ('Lights', 'ON', 60)
Fan: ('Fan', 'OFF', 40)
AC: ('AC', 'ON', 1500)

2. Energy Consumption Tracker (Dictionaries & Sets)


Task 2.1: Store Device Energy Usage in a Dictionary
● Create a dictionary where:
○ Keys: Smart home devices (e.g., "Lights", "AC", "Fan").
○ Values: Energy usage (in kWh).
● Allow users to:
○ Add new energy usage data.
○ Update existing usage.
○ Remove a device's energy usage.
○ Display total energy consumption.

✍️ Example Output:
Initial Energy Usage: {'Lights': 5, 'AC': 120, 'Fan': 30}
Updated Energy Usage: {'Lights': 5, 'AC': 110, 'Fan': 30,
'Thermostat': 20}
Total Energy Consumption: 165 kWh

Task 2.2: Identify Unique Power-Saving Modes Using Sets

● Create a set to store unique power-saving modes (e.g., "Eco Mode", "Night Mode",
"Away Mode").
● Allow users to:
○ Add a new mode.
○ Check if a mode is available.
○ View all power-saving modes.

✍️ Example Output:
Power-Saving Modes: {'Eco Mode', 'Night Mode'}
New Mode Added: 'Away Mode'
Updated Modes: {'Eco Mode', 'Night Mode', 'Away Mode'}
3. Functions for Smart Home Automation Task
3.1: Create a Function to Calculate Monthly Energy Cost

● Write a function calculate_energy_cost(energy_usage, rate_per_kwh)


that:
○ Takes total energy usage (kWh) and electricity rate per kWh as input.
○ Calculates total monthly cost.

✍️ Example Input & Output:


calculate_energy_cost(165, 0.12)
# Output: "Total Monthly Energy Cost: $19.80"

Task 3.2: Create a Function to Find Common Devices in Two Homes

● Write a function that:


○ Takes two lists of smart devices from two different homes.
○ Returns a set of common devices.

✍️ Example Input & Output:


home1_devices = ['Lights', 'AC', 'Fan']
home2_devices = ['Fan', 'Door Lock', 'Lights']

find_common_devices(home1_devices, home2_devices)
# Output: {'Lights', 'Fan'}

4. Automation Features (Advanced Functions)


Task 4.1: Create an Automation Rule Using Functions

● Write a function set_automation_rule(device, time, action) that:


○ Takes a device name, time, and an action (ON/OFF).
○ Returns a message indicating the automation rule.

✍️ Example Input & Output:


set_automation_rule("Lights", "10:00 PM", "OFF")
# Output: "Automation Rule: Lights will be turned OFF at 10:00 PM."
Task 4.2: Function to Optimize Power Consumption

● Write a function that:


○ Takes a list of devices with their power usage.
○ Turns off devices consuming high power (> 1000W).
○ Returns an updated list of active devices.

✍️ Example Input & Output:


devices = [("Lights", 60), ("AC", 1500), ("Fan", 40), ("Heater",
2000)]
optimize_power(devices)
# Output: ['Lights', 'Fan']

Bonus Challenge (Optional)


�� Smart Home AI Assistant (Using *args & **kwargs)

● Create a function smart_home_assistant(name, *args, **kwargs) where:


○ name: Homeowner's Name.
○ *args: Devices that need status updates.
○ **kwargs: Automation commands (e.g., lights="ON", fan="OFF").
● The function should:
○ Print the devices being checked.
○ Execute automation commands and return updated status.

✍️ Example Input & Output:


smart_home_assistant("Alice", "Lights", "AC", lights="OFF", ac="ON")
# Output:
# Checking status for: Lights, AC
# Lights set to OFF
# AC set to ON

�� Submission Guidelines:
● Complete all tasks and test your code.
● Submit yourAssignment here​
https://forms.gle/w4TnJaAkbnU2Niqh8​
● Include comments explaining your logic.

�� Happy Coding! Make your home smarter with Python! ����

You might also like