import json
import paho.mqtt.client as mqtt
from light_client_configuration import configuration
from broker_configuration import broker_configuration
from light_sensor_configuration import configuration_light_sensor
from Room import Room

#Client INITIALITAZION#
try:
    room = Room(configuration['name'], configuration['area'],
                configuration['length'], configuration['width'],
                configuration['height'])

    for light in configuration['lights']:
        for k in range(light['zones']):
            room.add_lights(light['name'], 'Zone_' + str(k + 1),
                            light['bulbs_per_zone'], light['max_lumen'])

    # for sensor in configuration['sensors']:
    # 	for k in range(sensor['zones']):
    # 		room.add_light_sensor(sensor['name']+'_'+str(k+1),
    # 							 'Zone_'+str(k+1))

    for sensor in configuration['sensors']:
        room.add_light_sensor(sensor['name'],
                              configuration_light_sensor['trace'])

    # for light in room.lights:
    # 	light.show()
    # for sensor in room.sensors:
    # 	sensor.show()