-
Notifications
You must be signed in to change notification settings - Fork 0
/
ACDevice.py
58 lines (43 loc) · 1.68 KB
/
ACDevice.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
56
57
58
import json
import paho.mqtt.client as mqtt
HOST = "localhost"
PORT = 1883
class AC_Device():
_MIN_TEMP = 18
_MAX_TEMP = 32
def __init__(self, device_id, room):
self._device_id = device_id
self._room_type = room
self._temperature = 22
self._device_type = "AC"
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"
# calling registration method to register the device
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 temperature for the devices
def _get_temperature(self):
pass
# Setting up the temperature of the devices
def _set_temperature(self, temperature):
pass