-
Notifications
You must be signed in to change notification settings - Fork 0
/
LightDevice.py
55 lines (43 loc) · 1.77 KB
/
LightDevice.py
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
import json
import paho.mqtt.client as mqtt
HOST = "localhost"
PORT = 1883
class Light_Device():
# setting up the intensity choices for Smart Light Bulb
_INTENSITY = ["LOW", "HIGH", "MEDIUM", "OFF"]
def __init__(self, device_id, room):
# Assigning device level information for each of the devices.
self._device_id = device_id
self._room_type = room
self._light_intensity = self._INTENSITY[0]
self._device_type = "LIGHT"
self._device_registration_flag = False
self.client = mqtt.Client(self._device_id)
self.client.on_connect = self._on_connect
self.client.on_message = self._on_message
self.client.on_disconnect = self._on_disconnect
self.client.connect(HOST, PORT, keepalive=60)
self.client.loop_start()
self._register_device(self._device_id, self._room_type, self._device_type)
self._switch_status = "OFF"
def _register_device(self, device_id, room_type, device_type):
pass
# Connect method to subscribe to various topics.
def _on_connect(self, client, userdata, flags, result_code):
pass
# method to process the recieved messages and publish them on relevant topics
# this method can also be used to take the action based on received commands
def _on_message(self, client, userdata, msg):
pass
# Getting the current switch status of devices
def _get_switch_status(self):
pass
# Setting the the switch of devices
def _set_switch_status(self, switch_state):
pass
# Getting the light intensity for the devices
def _get_light_intensity(self):
pass
# Setting the light intensity for devices
def _set_light_intensity(self, light_intensity):
pass