Ejemplo n.º 1
0
	def device_to_dict(self, device, methods_supported, info):
		methods_supported = methods_supported or 0
		
		# We support toggle ourselves, so add it to the supported list
		deviceMethods = device.methods(methods_supported)
		if methods_supported & TELLSTICK_TOGGLE == TELLSTICK_TOGGLE:
			deviceMethods |= TELLSTICK_TOGGLE
		
		dict = {
			'id'        : device.id,
			'name'      : device.name,
			'state'     : device.last_sent_command(methods_supported),
			'statevalue': device.last_sent_value(),
			'methods'   : deviceMethods,
			'type'      : self.device_type_to_string(device.type),
			'online'    : 1,
			'editable'  : self.editable()
		}

		if info:
			dict['protocol'] = device.protocol
			dict['model']    = device.model
			dict['parameter'] = device.parameters()
		else:
			dict['client'] = self.client()
			dict['clientName'] = self.clientName()
			dict = bh.set_attribute(dict)
			
		return dict
Ejemplo n.º 2
0
    def device_to_dict(self, device, methods_supported, info):
        methods_supported = methods_supported or 0

        # We support toggle ourselves, so add it to the supported list
        deviceMethods = device.methods(methods_supported)
        if methods_supported & TELLSTICK_TOGGLE == TELLSTICK_TOGGLE:
            deviceMethods |= TELLSTICK_TOGGLE

        dict = {
            'id': device.id,
            'name': device.name,
            'state': device.last_sent_command(methods_supported),
            'statevalue': device.last_sent_value(),
            'methods': deviceMethods,
            'type': self.device_type_to_string(device.type),
            'online': 1,
            'editable': self.editable()
        }

        if info:
            dict['protocol'] = device.protocol
            dict['model'] = device.model
            dict['parameter'] = device.parameters()
        else:
            dict['client'] = self.client()
            dict['clientName'] = self.clientName()
            dict = bh.set_attribute(dict)

        return dict
Ejemplo n.º 3
0
	def device_to_dict(self, device, methods_supported, info):
		json = {
			'id':         device.id,
			'name':       device.name,
			'state':      device.last_sent_command(methods_supported),
			'statevalue': device.last_sent_value(),
			'methods':    device.methods(methods_supported),
			'type':       self.device_type_to_string(device.type),
			'online':     1,
			'editable':   self.editable()
		}
		
		if info:
			json['protocol'] = None # TODO
			json['model']    = None  # TODO
		else:
			json['client'] = self.client()
			json['clientName'] = self.clientName()
			json = bh.set_attribute(json)
			
		return json